Solved

AS3 loop dynamic var name

Posted on 2011-02-15
1
504 Views
Last Modified: 2012-05-11
Hi,

why won't the below code work?

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


Thanks.
for(var i:int=0; i < e.length; i++)
	{
		//trace(e[i].channel);
		var test[i]:TextField = new TextField();
		test[i].text = e[i].channel;
		addChild(test[i]);
		
	}

Open in new window

0
Comment
Question by:Solutionabc
1 Comment
 
LVL 20

Accepted Solution

by:
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;
                addChild(test);
        }

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;
                addChild(test[i]);
        }

Open in new window

0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

758 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

19 Experts available now in Live!

Get 1:1 Help Now