In as2 it was very easy to access query string just using _root, but this doesn't seem to work on as3.
<embed src="loaderInfoExample.swf?a=123" quality="high"开发者_JS百科 bgcolor="#0000ff" width="250" height="50" name="loaderInfoExample" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" />
How do i access value of a? I tried it with _root as well as in flash client tried this :-
userNameTextField.text=root.loaderInfo.parameters.a;
But both doesn't seem to work. What can be the problem?
It should work. Try using SWFObject to include your flash content correctly and pass the parameter as the flashvars part.
Btw. you also should add some check routine to make sure that root.loaderInfo.parameters.a
is not null
, because assigning null
to a TextField's text
attribute produces an error.
look below in the autogenerated code you have to add the FlashVar there as well in order for it to work
<script language="JavaScript" type="text/javascript">
AC_FL_RunContent(
'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0',
'width', '550',
'height', '400',
'src', 'deleteme',
'quality', 'high',
'pluginspage', 'http://www.adobe.com/go/getflashplayer',
'align', 'middle',
'play', 'true',
'loop', 'true',
'scale', 'showall',
'wmode', 'window',
'devicefont', 'false',
'id', 'deleteme',
'bgcolor', '#ffffff',
'name', 'deleteme',
**'FlashVars', 'tester=test',**
'menu', 'true',
'allowFullScreen', 'false',
'allowScriptAccess','sameDomain',
'movie', 'deleteme',
'salign', ''
); //end AC code
</script>
Try doing that when you're movie is at least inited,
e.g:
this.loaderInfo.addEventListener(Event.INIT, paramsReady);
function paramsReady(event:Event):void{
userNameTextField.text=this.loaderInfo.parameters.a;
}
精彩评论