Passing parameters to a Flash 9 ActionScript 3 SWF file

9 actionscript,as3,flash,work  |   August 9, 2007  |     2534

Hi everyone, I found this blog entry which shed light on how to pass variables to your SWF this way :

[code]
light.swf?artist=yolanda&page=12
[/code]

Here is some usefull function you can use. Put it in your Document Class. For those who don’t know what that is, just put it on the stage on Frame 1 then.

So it’s quite simple to use it:

Voilà!

Inspiration

I used these articles as inspiration. Make sure you READ the FIRST COMMENT of the post since it outlines an important omission from the author.

link to Theo’s Blog entry

Cheers!

Comments
  • August 25, 2009 at 10:25 am

    rgnblck

    Thank you! You just saved my life.

  • August 31, 2009 at 6:24 pm

    Greg

    I’m trying to pass a variable like this from as3
    private var _movie:String=”mymovie.swf”
    var mRequest:URLRequest = new URLRequest(“swfloader.swf?m=”+_movie);

    But I get a url not found error, not because it doesn’t find mymovie.swf, but it can’t load swfloader.swf at all, I don’t understand why.
    If I remove the “?m=+_movie” then it works, but of course it doesn’t load the final movie…

  • September 5, 2009 at 3:20 am

    Ashish

    Really Cool
    Thanks for solution!!!!!!!!11

  • October 1, 2009 at 11:55 am

    Bernardo Pereira

    Another interesting thing I found out is that you can add the code ‘+document.location.search+’ to the JavaScript that calls the swf file, so that you don’t need to hardcode the variable in the html. The result is something like this:

    ‘src’, ‘swf_file_name’+document.location.search+”,
    ‘movie’, ‘swf_file_name’+document.location.search+”,

  • December 8, 2009 at 7:19 am

    mickey

    really preciated!!!!! mate!

  • January 20, 2010 at 7:08 am

    Alex

    Thanks, finally i found it 🙂 you saved some hours for me

  • April 19, 2010 at 9:55 pm

    DCuche

    you made my day (or nigth).

    =)

  • July 25, 2010 at 5:08 am

    koko

    thx a lot..

  • August 6, 2012 at 3:48 am

    Ramon Fincken

    Is this injection safe?

Leave a Reply