dcsimg
A Flash Developer Resource Site

Results 1 to 20 of 20

Thread: Variable Push: is this possible?

  1. #1
    Member
    Join Date
    Oct 2005
    Location
    UK
    Posts
    99

    Variable Push: is this possible?

    i have a swf in an html page called main.htm - is it possible for the flash to read a variable in the page's url. Eg. main.htm?myVars=here_is_some_text

    thanks
    "Today, a young man on acid realized that all matter is merely energy condensed to a slow vibration - that we are all One Consciousness, experiencing itself subjectively. There's no such thing as death, life is only a dream and we're the imagination of ourselves. Here's Tom with the weather..."

    -- Bill Hicks

    www.rapidshare.jp

  2. #2
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    Location
    London, UK
    Posts
    4,876
    yep have a look at flashvars property http://www.adobe.com/cfusion/knowled...fm?id=tn_16417
    Flashmatics | Flashmatics Library (free downloads)
    -----------------------------------------------------
    Latest Projects:
    The Dead Room | Are You Smarter | Prison Break (Frame A Friend) | Beck's Fusions | The 24 Experience

    -----------------------------------------------------
    Flash Certified Developer

  3. #3
    Member
    Join Date
    Oct 2005
    Location
    UK
    Posts
    99

    Thanks

    That's works well but it's not quite what i need - i need the swf to read in from the URL of the html page: eg. index.html?message=hello!

    I suspect i need to find a bit a javascript
    "Today, a young man on acid realized that all matter is merely energy condensed to a slow vibration - that we are all One Consciousness, experiencing itself subjectively. There's no such thing as death, life is only a dream and we're the imagination of ourselves. Here's Tom with the weather..."

    -- Bill Hicks

    www.rapidshare.jp

  4. #4
    Moderator whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,755
    http://board.flashkit.com/board/show...71#post2486501

    and will both tell you how this is done (link in my footer)

    heres an example done for someone else:
    http://www.dmstudios.net/urlTest/url...?frameNumber=4

    the basic javaScript line that you will need to edit to suit YOUR movie properties..
    Code:
    <script language="JavaScript">
    document.write ('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"'+'codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0"'+'width=355 height=255 id=urlTest align=middle><param name=allowScriptAccess value=sameDomain /><param name=movie value="urlTest.swf'+document.location.search+'" /><param name=quality value=high /><param name=bgcolor value=#ffffff /><embed src="urlTest.swf'+document.location.search+'"'+'quality=high bgcolor=#ffffff width=355 height=255 name=urlTest align=middle allowScriptAccess=sameDomain '+'type="application/x-shockwave-flash pluginspage=http://www.macromedia.com/go/getflashplayer" />')
    </script>

  5. #5
    Member
    Join Date
    Oct 2005
    Location
    UK
    Posts
    99

    Superb!

    that's the kiddie...

    thanks!
    "Today, a young man on acid realized that all matter is merely energy condensed to a slow vibration - that we are all One Consciousness, experiencing itself subjectively. There's no such thing as death, life is only a dream and we're the imagination of ourselves. Here's Tom with the weather..."

    -- Bill Hicks

    www.rapidshare.jp

  6. #6
    ___________________
    Join Date
    May 2004
    Posts
    3,174
    you dont need javascript - it's just a property
    Code:
    <param name="FlashVars" value="somevar=someval">

  7. #7
    Member
    Join Date
    Oct 2005
    Location
    UK
    Posts
    99

    ???

    I do need javascript because i need to read the HTML PAGE query string.

    actually, if you just want to push a variable into a flash file it's more browser/version friendly to simply go "myflash.swf?variable1=blah"
    "Today, a young man on acid realized that all matter is merely energy condensed to a slow vibration - that we are all One Consciousness, experiencing itself subjectively. There's no such thing as death, life is only a dream and we're the imagination of ourselves. Here's Tom with the weather..."

    -- Bill Hicks

    www.rapidshare.jp

  8. #8
    Moderator whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,755
    except your calling the .swf......and not the HTML page... sometimes you have hybrid sites...or multiple movies embeded in a page that need to 'feed' of the VAR passed in the URL string.

  9. #9
    Member
    Join Date
    Oct 2005
    Location
    UK
    Posts
    99

    Ahhh... you misunderstand me Whispers

    if i need to read the query string of the page your solution is perfect (tnx again).

    i was just pointing out to moagrius that if you merely want to get a variable value into a swf you don't need the 'flashVars' function, just append the name of the swf with the variable name and value, i've used this since flash 4
    "Today, a young man on acid realized that all matter is merely energy condensed to a slow vibration - that we are all One Consciousness, experiencing itself subjectively. There's no such thing as death, life is only a dream and we're the imagination of ourselves. Here's Tom with the weather..."

    -- Bill Hicks

    www.rapidshare.jp

  10. #10
    ___________________
    Join Date
    May 2004
    Posts
    3,174
    um. ok.

  11. #11
    Senior Member
    Join Date
    May 2005
    Location
    Canada
    Posts
    212
    does anyone know any tutorials on this? i cant get it to work for the life of me

  12. #12

  13. #13
    Senior Member
    Join Date
    May 2005
    Location
    Canada
    Posts
    212
    im having trouble makeing the connection from my one swf to tell it to go to another swf and play a certain frame.
    this is the code im using
    on(press) {
    getURL("http://www.callkarl.ca/main.html?frameName=home");
    }

    and then in the 2nd swf i have

    if (frameName=home) {
    gotoAndStop("mark");
    }

  14. #14
    Moderator whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,755
    ?? and did you edit the source code in the HTML page that HOUSES the .swf that is supposed to grab the VAR from the URL?

  15. #15
    Senior Member
    Join Date
    May 2005
    Location
    Canada
    Posts
    212
    Heres the script you offerd b4

    <script language="JavaScript">
    document.write ('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"'+'codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0"'+'width=100% height=100% id=urlTest align=middle><param name=allowScriptAccess value=sameDomain /><param name=movie value="main.swf'+document.location.search+'" /><param name=quality value=high /><param name=bgcolor value=#ffffff /><embed src="urlTest.swf'+document.location.search+'"'+'qu ality=high bgcolor=#ffffff width=355 height=255 name=urlTest align=middle allowScriptAccess=sameDomain '+'type="application/x-shockwave-flash pluginspage=http://www.macromedia.com/go/getflashplayer" />')
    </script>

    since i have to now fix the embeded issue im using this script and trying to edit it with no luck
    <script type="text/javascript" src="flashobject.js"></script>

    <div id="flashcontent" style="width: 100%px; height: 100%px"></div>

    <script type="text/javascript">
    var fo = new FlashObject("main.swf", "animationName", "100%", "100%", "8", "#FFFFFF");
    fo.addParam("allowScriptAccess", "sameDomain");
    fo.addParam("quality", "high");
    fo.addParam("scale", "default");
    fo.addParam("loop", "false");
    fo.write("flashcontent");
    </script>

    im not really sure which part of have to edit from ur example "main.swf'+document.location.search+'"??

  16. #16
    Moderator whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,755
    I believe these pats (in bold) to be the parts that would be SPECIFIC to your movie..

    Code:
    <script language="JavaScript">
    document.write ('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"'+'codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0"'+'width=100% height=100% id=urlTest align=middle><param name=allowScriptAccess value=sameDomain /><param name=movie value="main.swf'+document.location.search+'" /><param name=quality value=high /><param name=bgcolor value=#ffffff /><embed src="urlTest.swf'+document.location.search+'"'+'quality=high bgcolor=#ffffff width=355 height=255 name=urlTest align=middle allowScriptAccess=sameDomain '+'type="application/x-shockwave-flash pluginspage=http://www.macromedia.com/go/getflashplayer" />')
    </script>
    as far as changing it to work with IE for the embed issue..havent attempted it yet..sorry, not much help.

  17. #17
    Senior Member
    Join Date
    May 2005
    Location
    Canada
    Posts
    212
    thanks for ur help, but i still can't get it to work. as u can prolly tell by now im a huge rook andno very little AS. i made a bare-bones example of what im trying to do. can u look at it and tell me what im doing wrong?
    Attached Files Attached Files

  18. #18
    Moderator whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,755
    well first off (and think is the only thing),..your if(); statement syntax is off.

    should be like:
    Code:
    stop();
    if (frameName=="home") {
    	gotoAndStop("home");
    }
    if (frameName=="info") {
    	gotoAndStop("info");
    }

  19. #19
    Senior Member
    Join Date
    May 2005
    Location
    Canada
    Posts
    212
    THANK YOU. that was it

  20. #20

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