all groups > flash actionscript > april 2006 >
You're in the

flash actionscript

group:

change var using equation


change var using equation jondro
4/29/2006 5:21:49 PM
flash actionscript:
Hi I hope you can help:
I have a dynamic textbox with the var set to "pres" and a text file named
"bio.txt" which contains the following variables:

&pres=something
&page= test
&page1=something else
&page2=etc.

When i click the button called "next_btn" for the first time I want it to
change the var 'pres' to 'page1', and then the second time to 'page2' and so
on. So the textbox should display "something" when it loads and then after
clickin the button it should display "something else".

here is the actionscript:

loadVariablesNum("bio.txt", 0);
n=1;
next_btn.onRelease = function() {
nextImage();
pres=page+n;
n++;
trace(pres);
};

When it loads the dynamic textbox displays "something" but when i click the
button it should display the var 'page1' which is "something else" but instead
it displays "test 1". Why won't "something else" come up when I click the
button??? If you need a simple fla file to work with i will be happy to make
one. Thanks...

Re: change var using equation kglad
4/29/2006 5:40:54 PM
that's probably not going to work the way you want. while you can redefine the
variable associated with a textfield by assigning its variable property, after
doing so you'll need to redefine the string the variable stores in order for
you textfield to "see" that value.

why not just use the text property of text fields and use:


yourTextVarA=[pres,page,page1,page2]; // defined after your variables have
loaded. so, you'll probably want to use a data handler.
n=0;
next_btn.onRelease = function() {
nextImage();
yourTF.text=yourTextVarA[n];
n++;
};
AddThis Social Bookmark Button