Skip to main content
Inspiring
July 15, 2009
Answered

Using flashvars to access variables from html to swf

  • July 15, 2009
  • 2 replies
  • 873 views

Hi, In many tutorial i have find how to use FlashVars in embed or object tag of html. I used the FlashVars in an html file as follows:

<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="312" height="319" id="rot14-07-09" align="middle">
    <param name="allowScriptAccess" value="sameDomain" />
    <param name="allowFullScreen" value="false" />
   <param name="FlashVars" value="userName=sreelash" />
    <param name="movie" value="rot14-07-09.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />    <embed src="rot14-07-09.swf" quality="high" bgcolor="#ffffff" width="312" height="319" name="rot14-07-09" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" FlashVars="userName=sreelash"/>
    </object>

Then in the fla I tried to display the userName in a text field. But its displaying undefined. Should I define any method in fla to access the FlashVars variable.

Regards,

    Sreelash.

This topic has been closed for replies.
Correct answer kglad

you need to add flashvars to your AC_FL_RunContent() function, too.

2 replies

Inspiring
July 21, 2009

If you are not using the AC_FLRuncontent then when you are referencing the flash var in actionscript I find I always have to use the _level0 before the variable like:

trace(_level0.userName);

SreelashAuthor
Inspiring
July 22, 2009

thanks a lot kglad and Maxmanh, it is working now.

Regards,

Sreelsh

kglad
Community Expert
Community Expert
July 23, 2009

you're welcome.

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
July 15, 2009

you need to add flashvars to your AC_FL_RunContent() function, too.