How do I access flashvars in AS3, and add them to an existing text field?

て烟熏妆下的殇ゞ 提交于 2019-12-01 17:51:41
robertp

Try this: stage.loaderInfo.parameters.yourparam or stage.loaderInfo.parameters["yourparam"]

Can you post your html code, so we can see how you pass the flashvars to Flash.

beatstream

I've been wasted all the day long for that...

AS3:

var uid:String;
// your code
this.loaderInfo.addEventListener(Event.COMPLETE, loaderComplete);
// your code
function loaderComplete(e:Event=null):void
{
    var fv = stage.loaderInfo.parameters;
    uid = fv['uid'] || "'uid' not found";
}

HTML:

<object type='application/x-shockwave-flash' data='/flash/yourSWF.swf' width='320' height='240'>
<param name='wmode' value='transparent' />
<param name='FlashVars' value='uid=yourData' />
<param name='movie' value='/flash/yourSWF.swf' />
</object>
santhu

If you are still having this problem, follow below lines. I used flash vars, they work fine for me.

My html script was:

<html>
<body>
<div id="flashContent">
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"FlashVars="uid=123&name=santhu" width="100%" height="100%" id="index" align="middle">
  <param name="movie" value="index.swf" />
  <param name=FlashVars value="uid=123&name=santhu">
  <!--[if !IE]>-->
   <object type="application/x-shockwave-flash" data="index.swf" 
            FlashVars="uid=123&name=santhu"  width="100%" height="100%">
     <param name="movie" value="index.swf" />
     <param name=FlashVars value="uid=123&name=santhu">
  <!--<![endif]-->
  <!--[if !IE]>-->
   </object>
  <!--<![endif]-->
</object>
</div>
</body>
</html>

and my AS code to load vars is

this.root.loaderInfo.addEventListener(Event.COMPLETE, SWFLoadComplete);
private function SWFLoadComplete(e:Event)
{
  obj=this.root.loaderInfo.parameters;
  trace(obj.uid , obj.name);  // outputs: 123 santhu
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!