A Flash Developer Resource Site

Results 1 to 11 of 11

Thread: please help me pass a variable

  1. #1
    Senior Member
    Join Date
    Oct 2002
    Location
    Location Location
    Posts
    161

    please help me pass a variable

    I have an .swf with a few buttons. each button pops open a new html page with another .swf embeded in it. depending on which button is pushed, i need to pass a variable from the original flash file to the one that opens in the new html window.

    I was trying the "myFile.swf?myNumber=26" thing to get the variable from html to the second SWF, but how do I use the first flash file to set that variable? Thanks

  2. #2
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397

  3. #3
    Senior Member
    Join Date
    Oct 2002
    Location
    Location Location
    Posts
    161
    so, from within popup1.swf would I retrieve the variable in mainMovie.swf by using something like:

    var myNumber = movie.GetVariable("/mainMovie.swf:myNumber");

    i'm not sure I understand

  4. #4
    Senior Member
    Join Date
    Oct 2002
    Location
    Location Location
    Posts
    161
    I checked out the link, but I don't understand what to do with the information. Could someone explain in english what to do here. Do I need to somehow refference the original html window, or the original .swf?

  5. #5
    Senior Member pellepiano's Avatar
    Join Date
    Feb 2000
    Location
    Stockholm, Sweden
    Posts
    15,151
    To send a variable to another swf that is not embdded in html just add the variable to the end of the url string

    getURL("myFile.swf?myNumber=26");

    The variable will automatically ne accessible in the receiving swf file.

    To send a variable to a swf embedded in html , the embed code has to be made with some javasvript for it to pass the variable to the swf.
    PHP Code:
    <script language="JavaScript">
    document.write ('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" '
    +'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" '
    +'WIDTH=750 HEIGHT=500> <PARAM NAME=movie VALUE="knock.swf'+document.location.search+'">'
    +'<PARAM NAME=quality VALUE=high>'
    +'<EMBED src="knock.swf' +document.location.search+'" ' 
    +'quality=high  WIDTH=750 HEIGHT=500 '
    +'TYPE="application/x-shockwave-flash"></EMBED></OBJECT>')
    </
    script
    Last edited by pellepiano; 10-12-2003 at 06:34 PM.

    -Pelle Piano
    // Image Gallery
    www.studiobild.com
    // Photo Blog
    http://talesofthepixel.blogspot.com

  6. #6
    Senior Member
    Join Date
    Oct 2002
    Location
    Location Location
    Posts
    161
    getURL("myFile.swf?myNumber=26");

    since the file is an swf instead of html, is there no longer a way to control the size of the new window, scrollbars etc...?

  7. #7
    Senior Member
    Join Date
    Oct 2002
    Location
    Location Location
    Posts
    161
    for instance, the following _doesn't_ work:

    getURL ("javascript:newwin('file2.swf?mynumber=26',width= 320,height=240)");

  8. #8
    Senior Member
    Join Date
    Oct 2002
    Location
    Location Location
    Posts
    161
    ok, figured it out. Thanks for all your help.

  9. #9
    Senior Member pellepiano's Avatar
    Join Date
    Feb 2000
    Location
    Stockholm, Sweden
    Posts
    15,151
    Tis forum changed my code. I changed it back in the previous post.

    -Pelle Piano
    // Image Gallery
    www.studiobild.com
    // Photo Blog
    http://talesofthepixel.blogspot.com

  10. #10
    Senior Member
    Join Date
    Oct 2002
    Location
    Location Location
    Posts
    161
    thanks Pellepiano. does that code go in the first html file, or the one that pops up?

  11. #11
    Senior Member pellepiano's Avatar
    Join Date
    Feb 2000
    Location
    Stockholm, Sweden
    Posts
    15,151
    In the html that should recieve the variables.

    -Pelle Piano
    // Image Gallery
    www.studiobild.com
    // Photo Blog
    http://talesofthepixel.blogspot.com

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