Nick
Nick

Reputation: 19684

Flex - ExternalInterface.Call() always returns 'Undefined'

I am trying to get the value of a global variable from JS. The variable is defined in the HEAD section of my HTML document.

if(ExternalInterface.available){                    
                return ExternalInterface.call("window.myVar.toString()");
            }

As I debug my application this call keeps returning "undefined" but if I make the same call in firebug's console it returns a string as expected. I'm very new to flex so is there something I am missing here?

Upvotes: 2

Views: 789

Answers (3)

mgraph
mgraph

Reputation: 15338

am sure this url will be very helpful to you http://circlecube.com/2008/02/actionscript-javascript-communication/

you need to convert it into as3 because it's in as2

found this in as3 : http://meshfields.de/externalinterface-call-as3-javascript/

Upvotes: 0

Nick
Nick

Reputation: 19684

The problem was ME. When debugging the tool is not being hosted on a webserver, therefore, the JS is not going to work. Duh..

Upvotes: 0

Just try window.myVar.toString , you don't need the parenthesis.

Upvotes: 3

Related Questions