Groups | Blog | Home
all groups > flash actionscript > april 2005 >

flash actionscript : input text as a variable for dynamic text boxes


chicken king
4/3/2005 8:29:18 PM
hey all... here is what i am trying to do: in frame i want a series of input
text boxes each to be declared as a variable [say line1, line2, line3, etc]
then i what to set a goto command to goto frame 2 in which there are a series
of dynamic text boxes [say t1, t2, t3, etc] what i would like to have happen
is the imput values from line1, line2, line3, etc. in frame 1 to be drawn into
the dynamic text boxes t1, t2, t3, etc. in frame two. i am assuming it is just
a matter of setting the input text boxes as variables and the dynamic text
boxes as different variables and setting t1 = line3 for example. alas i am
having a bit of difficulty with this for some reason. any help from out there
would be appreciated. thanks
kglad
4/3/2005 8:42:20 PM
on frame 1:

for(i=1;i<=3;i++){
this["line"+i]=this["inputTF+i].text; // where you have input textfields with
instance names inputTF1,inputTF2 etc
}

on frame 2:

for(i=1;i<=3;i++){
this["t"+i].text=this["line"+i];
}

p.s. if your input textfield's are still present in frame 2 you can skip
these intermedicate steps using line1, line2 etc
chicken king
4/3/2005 9:03:31 PM
i have tried this, but it does not seem to be working. not sure what i am doing
wrong. i have 3 input text fields in frames 1 and 2 instance-named inputTF1-3
i have 3 dynamic text fields in frames 1 and 2 instance-named t1-3 [i also gave
it a go calling the dyn boxes variables] on frame 1 in a separate layer i
attached the code: for(i=1;i<=3;i++){ this['line'+i]=this['inputTF'+i].text; }
on frame 2 in the same layer as above code i attached the code:
for(i=1;i<=3;i++){ this['t'+i].text=this['line'+i]; } but when i go to frame 2
the text from the input boxes is not transfering to the dynamic boxes i may be
dumb here, but ..... thanks
kglad
4/3/2005 10:57:14 PM
this code:

for(i=1;i<=3;i++){
this["line"+i]=this["inputTF"+i].text;
}

must be executed AFTER text is entered into your input textfields. i infer
there's some way (a button press) that you direct the timeline to move from
frame 1 to 2. at that point you want to execute the for-loop.

in fact, it would be easiest to put that for-loop in a function and call that
function just prior to your gotoAndStop(2) statement:

function textAssign(){
for(i=1;i<=3;i++){
this["line"+i]=this["inputTF"+i].text;
}
}

and the line above gotoAndStop(2), should be:

textAssign();
chicken king
4/3/2005 11:01:39 PM
thank you for the assistance....

kglad
4/3/2005 11:27:09 PM
AddThis Social Bookmark Button