Mike Chambers

code = joy

Getting Return values when calling JavaScript Functions from ActionScript / Flash

with 9 comments

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.

Written by mikechambers

June 22nd, 2005 at 1:41 pm

Posted in General

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

Subscribe to comments with RSS

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

    Fabrizio

    24 Jun 05 at 4:02 am

  2. In your code example for broadcasting an event – you have in the Class MyClass

    //declare EventDispatcher functions
    private function dispatchEvent;
    public function addEventListener;
    public function removeEventListener;

    shouldn’t that be

    private var dispatchEvent:Function;
    public var addEventListener:Function;
    public var removeEventListener:Function;

    Mike

    mike

    24 Jun 05 at 7:43 am

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

    mike chambers

    mesh@macromedia.com

    mike chambers

    24 Jun 05 at 8:53 am

  4. 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

    Mike

    24 Jun 05 at 12:47 pm

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

    chaitanya

    26 Jun 05 at 8:25 am

  6. 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 regard

    and great job when it’ll work for me.

    mrbbp

    27 Jun 05 at 6:16 am

  7. 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.

    mrbbp

    27 Jun 05 at 8:31 am

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

    http://www.wimpyplayer.com/products/mp3/javascript_mp3_player.html

    -mike

    mrgoose

    22 Jul 05 at 10:55 pm

  9. Hi Myke,

    In my actionscript, I have :
    proxy.call(“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.

    Laurent

    27 Jul 05 at 1:53 am

Leave a Reply