• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Set two variables in ActionScript 3 pass to FlashVar

Participant ,
Jan 21, 2009 Jan 21, 2009

Copy link to clipboard

Copied

I have been grappling with this problem for days now. I want to set two variables in a SWF and have them passed to FlashVars PHP page. I can get it to work when I just send one variable with this code:

function loaderComplete(myEvent:Event)
{
var flashVars=this.loaderInfo.parameters;
UserNameTextField.text=flashVars.UserName;
}
this.loaderInfo.addEventListener(Event.COMPLETE, loaderComplete)

And FlashVars passes the variable correctly to the PHP page.
When I add another variable to the ActionScript like this:
function loaderComplete(myEvent:Event)
{
var flashVars=this.loaderInfo.parameters;
CompanyNameTextField.text=flashVars.CompanyName;
UserNameTextField.text=flashVars.UserName;
}
this.loaderInfo.addEventListener(Event.COMPLETE, loaderComplete)

I get the following error:

TypeError: Error #2007: Parameter text must be non-null.
at flash.text::TextField/set text()
at swf_fla::MainTimeline/loaderComplete()

I have no idea of how to correct this being a novice at Flash.
If some kind soul would correct the above code, I would be very grateful.

Thanks in advance for your help - Sam
TOPICS
ActionScript

Views

663

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 21, 2009 Jan 21, 2009

Copy link to clipboard

Copied

Can you show how you're passing the flashvars in? Like is it a url that ends:

whatever.swf?UserName=Sam&CompanyName=LaundonInc



Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jan 21, 2009 Jan 21, 2009

Copy link to clipboard

Copied

Thanks for trying to help. The problem is not in the php page on the browser. The problem is the naming of two variables that gives the error. When I just try to pass one Variable everything works fine, both in Flash and the php page on the browser. With passing two Variables I have not even tried going to the test php on the browser because of the error in Flash.

Sam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 22, 2009 Jan 22, 2009

Copy link to clipboard

Copied

LATEST
I wasn't curious about the php at all. If you do a test in a browser, of:

http://www.yoursite.com/yourfolder/yourflash.swf?a=1&b=2

what would the part after the question mark look like in your case? If you simplify the test to something like that, does it still go wrong?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines