Solved

AS3 loop dynamic var name

Posted on 2011-02-15
1
516 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

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 last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.

628 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