Getting Return values when calling JavaScript Functions from ActionScript / Flash

I added a page to the Flash / JavaScript Integration Kit project documents that shows how to get return values from JavaScript when calling JavaScript functions from Flash.

The same technique works when calling Flash function from JavaScript, by just reversing the code.

You can view the code / example here.

You can find out more about the Flash / JavaScript Integration Kit here.

9 Responses to Getting Return values when calling JavaScript Functions from ActionScript / Flash

  1. Fabrizio says:

    Hello Mike,do you think will be possible a Flash/Javascript synchronous communication in the future? Thanks.

  2. mike says:

    In your code example for broadcasting an event – you have in the Class MyClass//declare EventDispatcher functionsprivate function dispatchEvent;public function addEventListener;public function removeEventListener;shouldn’t that beprivate var dispatchEvent:Function;public var addEventListener:Function;public var removeEventListener:Function;Mike

  3. mike chambers says:

    Good catch. I just updated it and corrected the error.mike

  4. Mike says:

    No worries – I’m good at catching stuff like that. In fact I’d make a great Flash beta tester ;-)yeah I’m not funny!Mike

  5. chaitanya says:

    pls tell about how to add flash files into my web home page pls give some exaples

  6. mrbbp says:

    Sorry Mike i’m certainly a stupid guy but when i include your code (actionscript part) in flash and want to test syntax…Flash, say it enable to include a class like that, have put in an external .as file.if i do that how to call the class ?yes i know this is certainly very easy for your guru level, but not for mine…. ;(please give us a .fla file or a zip file or a better tutorial 😉 (sorry for that).best regardand great job when it’ll work for me.

  7. mrbbp says:

    Well i’ve tested the patterson’s tut and that work’s…don’t know why from scratch that doesn’t work.i’m certainly an idiot.sorry.

  8. mrgoose says:

    Mike,Thought you might like to check out an implementation of the JavaScript -> Flash:

  9. Laurent says:

    Hi Myke,In my actionscript, I have“myjsfunction”,mytext);when the length of mytext is more than 480 chars, the call doesen’t work.What is the maximum length for an argument when calling a javascript function from actioscript ?Can I change it somewhere in the sources ?Thanks a lot for that product…Laurent.