Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variable Problem (what's new)

Status
Not open for further replies.

Astor

Programmer
Jul 3, 2002
12
ES
Hello all,

I have a little problem that is driving me nuts.

I set up a variable in php (print "t1=x&t2=y";)
I've also tried it loading the variables through a txt file (t1=x&t2=y)

I load the variables in Flash:
loadVariablesNum("test.php", 0);

Funny enough, if I use a dynamic text field and use t1 or t2 as a varible it displays the value, which is ok.

The problem is that if I trace the variable or want to use that variable in an if statement it returns "undefined"
trace(t1);
or
if (t1 == x) {do something}

It's almost like I can only load variables to use in dynamic text fields and nothing else!!

I figure this is something really stupid that I'm missing, but I'm at the edge of insanity. Anyone knows what am I doing wrong?

Thanks a lot!
 
common problem

you are trying to get at the variable before it has loaded hence 'undefined'

if you have mx or higher then use loadvars

mydata = new LoadVars();
mydata.onLoad = function(){
trace(mydata.t1);
}
mydata.load("test.php");

will work but id recommend using sendandload

if its older version of flash then loop over frames

frame 1

loadVariablesNum("test.php", 0);
if(t1==undefined){
gotoAndPlay(2);
}else{
trace(t1)
stop();
}

frame 2

gotoAndPlay(1)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top