A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: HTML giving variable to flash

  1. #1
    Junior Member
    Join Date
    Nov 2008
    Posts
    4

    HTML giving variable to flash

    I am making a forum and I wish to place a flash movie in the posts displaying the posters rank.

    The php will write in html and I can give it the rank title in the html, however how do I get flash to use this info.

    I read somewhere that I can use

    href = "movie.swf?ranktitle=therank"

    within the embeding

    and ranktitle is my variable holding "therank"

    however how do I do this practically, given that I must first declare the variable in flash and it must contain text in order to pass it to the text box.

    cheers for you help

  2. #2
    Senior Member
    Join Date
    Mar 2001
    Posts
    197
    You could use the embed attribute "flash vars" or really the much better method is to use SWF Object as your flash embed method. There are live examples of what you are looking to do in the download:
    http://code.google.com/p/swfobject/downloads/list

  3. #3
    Junior Member
    Join Date
    Nov 2008
    Posts
    4
    cheers, I will use the first method if I can, the second uses a bit too much code to put a swf in every post.

  4. #4
    Junior Member
    Join Date
    Nov 2008
    Posts
    4
    ok, I have found how to pass the variables to flash with actionscript 2 using _root.variable in flash
    and
    variable=hello in html

    however I cant translate to actionscript 3

    if I swap _root for stage (even with the full title) it will throw a undefined property error on input1. This is not a big problem as I can just script in 2 instead of 3 but it would be nice to know why it has a problem.

  5. #5

    Lightbulb

    FlashVars Syntax
    When you put a Flash movie on a html page, you will have an OBJECT and EMBED tag code that is similar to this:

    <OBJECT classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000"
    codebase="http://macromedia.com/cabs/swflash.cab#version=6,0,0,0"
    ID=flaMovie WIDTH=250 HEIGHT=250>
    <PARAM NAME=movie VALUE="flaMovie.swf">
    <PARAM NAME=quality VALUE=medium>
    <PARAM NAME=bgcolor VALUE=#99CC33>
    <EMBED src="flaMovie.swf" bgcolor=#99CC33 WIDTH=250 HEIGHT=250
    TYPE="application/x-shockwave-flash">
    </EMBED>
    </OBJECT>


    Both tags serve the same purpose, to specify a Flash movie. However, most Netscape browsers only understand EMBED tags, while Internet Explorer only understand OBJECT tags. Whenever you specify a Flash movie, you should use both. So, when using FlashVars, there are also two slightly different syntax, one for the OBJECT tag, and the other one for EMBED tag.

    For the OBJECT tag, the syntax is as follows:

    <PARAM NAME FlashVars VALUE=[variable1=value1&variable2=value2&variable3=value3 ...]>

    The param tag must be nested within the OBJECT tag.

    For the EMBED tag, it is as follows:

    <EMBED .... FlashVars=[variable1=value1&variable2=value2&variable3=value3 ...] ...>

  6. #6
    Junior Member
    Join Date
    Nov 2008
    Posts
    4
    I know this mate, the point was AS3 loads the flashvars differently, here is how you obtain them with AS3

    Code:
    function loaderComplete(myEvent:Event)
    {
      var flashVars=this.loaderInfo.parameters; //acquires all flash vars
      var input:String = flashVars.input; //acquires the flash var named input
    }
    this.loaderInfo.addEventListener(Event.COMPLETE, loaderComplete);

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