PDA

View Full Version : using loaded variables HELP 2


dazza
11-26-2005, 12:48 PM
having a problem ...still...with using variables loaded into flash from text file: simple mistake i expect/hope!

loading textfile settings.txt with content: StudText=hello&finished=yes
trying to get flash to see the result "hello" and hopefully then add if statement; if StudText == "hello" make mc visible = true.
problem is i am falling at the first hurdle, text displays fine in textfields but when i trace the content of the textfield it is always 'undefined'
frame 1 of movie :

loadVariables("settings.txt", this);
if (! (finished == "yes")) {
gotoAndPlay("waitForLoad");
}

stop();
frame 2 of movie:

stop();
trace("text: "+r.text);
trace(StudText);
trace(finished);

all traces show undefined despite text info being correctly loaded into the textfield in frame 2. also the Waitforload if statement moves successfully to frame 2 even if statement is changed to finished == "no". I am at a loss - all i want to do is use a text file to set a mc property flash seems to display dynamic text but not recognise the variables -is it a syntax/string problem?.

hope somone can help!

radicalFish
11-28-2005, 04:03 PM
hello

you have to check if the varibales are realy loaded,otherwise they are always undefined if you trace them just after your loadVaribles methode..

and your statement "(! (finished == "yes"))" is true even if 'finished' is 'undefined'...

look this is an example from the Flash_Help:
it uses an emptyMovieClip to hold the varibles
respectivly loads them into it..
it also uses an interval to check if the varibales are loaded, if so it clears the interval (you don't need it any more..)


this.createEmptyMovieClip("target_mc",this.getNextHighestDepth());
loadVariables("settings.txt",target_mc);
function checkParamsLoaded () {
if(target_mc.finished != undefined) {
trace(target_mc.StudText);
trace(target_mc.finished);
//other code like your gotoAndStop statement..
clearInterval(param_interval);
} else {
// trace("not loaded");
}

}
var param_interval:Number = setInterval(checkParamsLoaded, 100);


see?

regards
r.fish

dazza
11-29-2005, 08:44 AM
Great!, that worked, thanks for taking the time to help point me in the right direction:good: