Advertisement

05.28.2008 at 10:20AM PDT, ID: 23438864 | Points: 500
[x]
Attachment Details

For Loop and Dynamic Variables

Asked by rgarimella in Macromedia Flash

Hi Folks,

I have the following code (AS3 Please), see code snippet.

I have a dynamic variable called totalDistractors which has a value of lets say 4

How do I create a for loop for the below mentioned code so that there are 4 distractors/textField

_distractor1,_distractor2,_distractor3,_distractor4 have text assigned to it

Thanks
RG



Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
var _distractor1Txt:TextField = new TextField();
 
_distractor1Txt.autoSize = TextFieldAutoSize.LEFT;
_distractor1Txt.multiline = true;
 
_distractor1Txt.text = _distractor1;
addChild(_distractor1Txt);
 
 
Need something like this but this does not work
 
for (var i:Number = 1; i < totalDistractors + 1; i++) {
	
var _distractor[i]Txt:TextField = new TextField();
_distractor[i]Txt.multiline = true;
_distractor[i]Txt.text = _distractor1;
addChild(_distractor[i]Txt);
 
}
[+][-]05.28.2008 at 10:40AM PDT, ID: 21662506

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.28.2008 at 12:22PM PDT, ID: 21663453

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.28.2008 at 12:32PM PDT, ID: 21663552

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.28.2008 at 12:57PM PDT, ID: 21663769

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628