TCM
TCM

Reputation: 16920

How do i access query string in flash action script 3.0?

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?

Upvotes: 1

Views: 1993

Answers (3)

bnixx
bnixx

Reputation: 11

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>

Upvotes: 1

George Profenza
George Profenza

Reputation: 51847

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;
}

Upvotes: 0

poke
poke

Reputation: 388313

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.

Upvotes: 2

Related Questions