Groups | Blog | Home
all groups > flash actionscript > august 2004 >

flash actionscript : Loading Variables


Happy Camper
8/4/2004 10:16:10 PM
Heh, I am creating recipe cards that my family can dynamically add their
recipes too. So the initial Flash file loads up "recipes/recipe1.txt",
everything works wonderfully... then when you push a button, "next recipe", I
have this code on it...

Code:

on(release){
if(recipe_no < lastRecipe){
loadVariables ("recipes/recipe" + [recipe_no + 1] + ".txt",
this);
}else{
_root.warning_txt = "That's all the recipes for now.";
}
}

"recipe_no" is a variable defined in the text file... recipe1.txt = 1,
recipe2.txt = 2, etc. "lastRecipe" is defined in the Flash file to reflect the
last recipe number.

So, the text variables are not changing when I push that button, is there some
kind of refresh, or watch I need to run as well?

Thanks!

http://www.dragonfly-design.net/family/recipes.html
kglad
8/4/2004 10:47:52 PM
it's not clear what your problem is although i have a feeling that it may be a
variable defined in one of your text files that you think is non-string and
flash thinks is a string. to clarify your situation, you have several text
files in your recipes directory. they are named recipe1.txt,
recipe2.txt,...,recipeX.txt, where X=lastRecipe.

now, you are using recipe_no which "...is a variable defined in the text
file... recipe1.txt=1, recipe2.txt=2, etc". and your quotes makes no sense. a
text file, like recipe1.txt cannot be assigned a value of 1. please clarify.
Happy Camper
8/4/2004 11:44:48 PM
I have attached the .TXT file if you would like to look at it...

In the text file, "recipe2.txt" I have the following variables defined...
&title_txt= [text is here]&
&ingredients_txt= [text is here]&
&recipe_txt= [text is here]&
&recipe_no=2&
&from_txt=Ellen&

As you can see the variable "recipe_no" is equal to 2 in the file named
"recipe2.txt", that's what I meant by "recipe2.txt=2"...

The compatible dynamic text boxes in Flash are named exactly as they appear in
the text file. They are named in the variable box, as I am publishing in Flash
5.

On the first frame of the movie (it is only one frame) on a separate layer I
have...

loadVariables ("recipes/recipe1.txt", this);
lastRecipe = 3;

Hope that helps, please let me know if I can clarify anything else.
kglad
8/5/2004 12:14:57 AM
so, as mentioned above, recipe_no=2 when read from a text file is interpreted
by flash as recipe_no="2". and recipe_no+1 = "21" NOT recipe_no+1=3. to
remedy use:

if(Number(recipe_no)<lastRecipe){
loadVariables ("recipes/recipe"+(Number(recipe_no)+1)+".txt", this);
}
Happy Camper
8/5/2004 12:31:08 AM
kglad
8/5/2004 3:19:06 AM
AddThis Social Bookmark Button