all groups > flash actionscript > july 2004 >
You're in the

flash actionscript

group:

Variable from text file is inconsistent



Variable from text file is inconsistent Langdon
7/28/2004 8:33:03 PM
flash actionscript: I am trying to load a movie at level 10 based on the value of a variable in a
local text file. I know the variable is being acquired by the Flash movie
because I have a dynamic text field set to display the value of the variable.
However, my if statement only seems to work sometimes.

Here is my actionscript on the main timeline of the movie at level 10:

loadVariablesNum("defaults.txt", 30, "GET");

if (defaultModule == "4") {
loadMovieNum("10_04_01_main.swf", 10);
}

if (defaultModule == "5") {
loadMovieNum("10_05_01_cabin.swf", 10);
}


My text file simply has this:

&defaultModule=5


What am i doing wrong?

Re: Variable from text file is inconsistent Jack.
7/28/2004 9:29:40 PM
use MovieClip.loadVariables to load the data.
MovieClip.onData fires when the data
has completed loading

this.createEmptyMovieClip("loader",100);
loader.loadVariables("defaults.txt");

loader.onData = function(){
if(defaultModule == "4")
loadMovieNum("10_04_01_main.swf", 10);
if(defaultModule == "5")
loadMovieNum("10_05_01_cabin.swf", 10);
};

hth
Re: Variable from text file is inconsistent Jack.
7/28/2004 9:33:38 PM
should'a tested ;)

change that to -
Re: Variable from text file is inconsistent Laiverd.COM
7/28/2004 11:20:14 PM
A variable from an external file may or may not have arrived before you use
it further in actionscript unless you prevent this, by explicitly waiting
for the variables arrival, before you use it. This would probably explain
the inconsistent behavior. So it's not a matter of it showing up; but does
it show up in time. You may wanto to have a look at the LoadVars Object
which has an onLoad ecenthandler to give you control over things in a much
niftier way than is possible with loadVariables.

John

--
----------------------------------------------------------------------------
-----------
RESOURCES
http://groups.google.com/advanced_group_search?hl=en&as_ugroup=*flash
----------------------------------------------------------------------------
-----------
TUTORIALS at
www.laiverd.com
Flash & PHP Emailform
Using textfiles in Flash
----------------------------------------------------------------------------
-----------

Re: Variable from text file is inconsistent Langdon
7/29/2004 12:47:43 PM
AddThis Social Bookmark Button