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
Solved

AS3 loop dynamic var name

Posted on 2011-02-15
1
510 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Actionscript in Flash 3 70
Run command in each subfolder using batch file 7 68
Chocolatey under PowerShell is not working properly 3 68
Logon script fails 23 45
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
The goal of the tutorial is to teach the user how to how to record live broadcast.
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.

840 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