views:

141

answers:

3

Hello, 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" 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?

+2  A: 

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.

poke
But it's auto generated code from Flash. Where do i include it in here? Also object tag should always work why should i use SWFObject? QueryStrings should be accessible in object tag also?The autogenerated code is huge about 320 lines long. :(
Ankit Rathod
If you are using the standard autogenerated code to show your flash content, make sure you pass the flash vars with a new `param` tag for the `object` tag. See [this page](http://kb2.adobe.com/cps/164/tn_16417.html) for instructions.
poke
A: 

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;
}
George Profenza
doesn't help :(.<embed src="loaderInfoExample.swf" FlashVars = "a=123" quality="high" 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" /> <PARAM NAME=FlashVars VALUE="a=123">This is my flash codethis.loaderInfo.addEventListener(Event.COMPLETE, paramsReady);function paramsReady(event:Event):void{userNameTextField.text=this.loaderInfo.parameters.a;}i get error parameter text must be not null. :(
Ankit Rathod
Interestingly when i deleted all autogenerated code and placed simple object tag as :-http://www.permadi.com/tutorial/flashVars/loaderInfoExample.htmlIt works fine!! :):) Now i want to know is there a bug in autogenerated code from flash cs4? i just clicked publish and 300 lines of code got generated and the same query string is not working in that object tag whereas it's working in simple object tag.
Ankit Rathod
+1  A: 

look below in the autogenerated code you have to add the FlashVar there as well in order for it to work

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
bnixx