HI,
I am trying to call a method defined in flash object from javascript (firefox-3.0/Linux) and getting the exception: "NPMethod called on non- NPObject wrapped JSObject".
If I use eval on window.document.flash_object.func() it throws "NPMethod called on non-NPObject wrapped JSObject".
Where as, if I define a javascript function in side the page as given below:
function myFunc() { return flash_object.func();
}
and later do a eval of window.document.myFunc() it works fine.
I am running the two evals through a test framework called Selenium. [eval(window.document.flash_object.func()) and eval(window.document.myFunc())].
The issues seems to be issue with invoking the flash-object method without passing 'this' reference. Here is sample html/js code to reproduce this issue: "NPMethod called on non-NPObject wrapped 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, question to javascript gurus: Given flash object and a method name, how do I invoke the method on that object. Lets say, a function takes two arguments: a flash object, and a method name as string. I want to do an eval on object.method() inside that function. Is this possible, if so, can you please explain me how this can be done.
As flash object's method is not a standard javascript function, i think its not possible to function binding through bind(). Is there any other alternative?
Thx, Chandra