Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to fix: "NPMethod called on non-NPObject wrapped JSObject" error?
    primarykey
    data
    text
    <p>HI,</p> <p>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".</p> <p>If I use eval on window.document.flash_object.func() it throws "NPMethod called on non-NPObject wrapped JSObject".</p> <p>Where as, if I define a javascript function in side the page as given below:</p> <p>function myFunc() { return flash_object.func();</p> <p>}</p> <p>and later do a eval of window.document.myFunc() it works fine.</p> <p>I am running the two evals through a test framework called Selenium. [eval(window.document.flash_object.func()) and eval(window.document.myFunc())].</p> <p>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".</p> <pre><code>&lt;script&gt; function changeColor() { mymovie.changeColor(); } function getColorNP() { var func = mymovie.getColor; func(); } &lt;/script&gt; &lt;button type="button" onclick="getColorNP();"&gt;getColorNP&lt;/button&gt; &lt;button type="button" onclick="getColor();"&gt;getColor&lt;/button&gt; 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 </code></pre> <p>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.</p> <p>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?</p> <p>Thx, Chandra</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload