Hi
I am trying to call a method defined in a flash object from javascript (firefox-3.0 / Linux) and get an exception: "NPMethod called a non-NPObject wrapped JSObject".
If I use eval on window.document.flash_object.func (), it throws Msgstr "NPMethod called a non-NPObject wrapped with JSObject".
Where as if I define the javascript function on the side as follows:
function myFunc () {return flash_object.func ();
}
and then do eval from window.document.myFunc (), it works fine.
I run two analyzes through a test environment called Selenium. [eval (window.document.flash_object.func ()) and Eval (window.document.myFunc ())].
The problems seem to arise when calling the flash object method without passing the 'this' help. Here is a sample html / js code to reproduce this problem: "NPMethod called a non-NPObject wrapped by JSObject."
<script>
function changeColor() {
mymovie.changeColor();
}
function getColorNP() {
var func = mymovie.getColor;
func();
}
</script>
<button type="button" onclick="getColorNP();">getColorNP</button>
<button type="button" onclick="getColor();">getColor</button>
getColorNP throws the exception
Error: NPMethod called on non-NPObject wrapped JSObject!
Source File: http://my.host/Colors/colors.html
getColorNP throws the exception
Error: NPMethod called on non-NPObject wrapped JSObject!
Source File: http://my.host/Colors/colors.html
Now the question for the javascript guru: Given the flash object and method name, how do I call the method for this object. Suppose a function takes two arguments: a flash object and a method name as a string. I want to do an eval on object.method () inside this function. Is this possible, if so, can you explain to me how this can be done.
Since the flash object method is not a standard javascript function, I think it is not possible to bind the binding using bind (). Is there any other alternative?
thanks Chandra
source
share