AS3 loop dynamic var name

Posted on 2011-02-15
Last Modified: 2012-05-11

why won't the below code work?

I keep getting this error:
syntax error: expecting semicolon before leftbracket.

for(var i:int=0; i < e.length; i++)
		var test[i]:TextField = new TextField();
		test[i].text = e[i].channel;

Open in new window

Question by:Solutionabc
1 Comment
LVL 20

Accepted Solution

ChristoferDutz earned 500 total points
ID: 34897754
Either you do this:
for(var i:int=0; i < e.length; i++)
                var test:TextField = new TextField();
                test.text = e[i].channel;

Open in new window

or this:
var test:Array = new Array();
for(var i:int=0; i < e.length; i++)
                test[i] = new TextField();
                test[i].text = e[i].channel;

Open in new window


Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Python multiple IF statements 4 76
need a quick help to fix the script logic 4 63
Control Number of Log Files -Perl 7 55
Need script to search multiple files in one drive 13 35
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now