dcsimg
A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Passing var to Flash thru query string doesn't work

  1. #1

    Passing var to Flash thru query string doesn't work

    Hi everyone at FlashKit,

    I want to pass a variable to my Flash .swf file through a query string.

    In my Flash movie I have an animation of 2 goats fighting, I want the query string to tell the movie to skip to the end of the movie if variable goats==attacked. I used the following ActionScript:
    Code:
    if (goats=="attacked") {
    _root.goatanimation.gotoAndStop("end");
    }
    The problem is that no matter whether I attach the query string goats=attacked at the end of the html address or not the movie never skips to the end.

    Many thanks,

    Leao
    Last edited by Leao; 10-15-2009 at 01:11 PM.

  2. #2
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    try setting the var:

    PHP Code:
    var goats:String _root.goats
    nice rooster ;-)

    gparis

  3. #3
    Thanks, I'll give it a go. I succeeded also doing it another way by embedding the .swf file with the variable attached to the end of the embedded object's name.
    Last edited by Leao; 10-15-2009 at 01:11 PM.

  4. #4
    Senior Member
    Join Date
    Jan 2003
    Location
    Nebraska
    Posts
    448
    HTML link didn't work for me. However if it works directly, perhaps you are doing it a little wrong. Flash won't read the query string from the browser, but from the embed area like:

    movie="blah.swf?variable=something"

    Or whatever type of embed you are doing. You need to put the query string right after .swf, not just in the url of the page.
    ecards - My full flash site.

  5. #5
    Thanks, I put the variable after .swf in the HTML via PHP and it works now.
    IL HAMDILLILAH!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center