Go Back   CodingForums.com > :: Client side development > Flash & ActionScript

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-21-2009, 09:08 AM   PM User | #1
forgottenglory
Regular Coder

 
Join Date: May 2006
Posts: 128
Thanks: 3
Thanked 0 Times in 0 Posts
forgottenglory is an unknown quantity at this point
Attaching movieclips using for loop

I've been trying to use a for loop to attach a few movie clips to the stage in vain. I couldn't find any relevant examples in neither my flash manual nor the flash help nor the internet.

I have a few movie clips (let's say five) that I have created manually. I want to attach them to the stage using the for loop.

If I had to attach a single instance, I would do it as follows:

Code:
var pic1:MovieClip = new Pic1();
pic1.x = 10;
pic1.y = 15;
addChild(pic1);
So, I thought that using a for loop would go as follows:

Code:
for (var i:Number = 1; i < 6; i++){
       var ["pic"+i]:MovieClip = new ["Pic"+i]();
       ["pic" + i].x = 10;
       ["pic" + i].y = 15;
       addChild["pic" + i];
}
I come from an AS2 background and this is what I could come up with whilst looking for solutions on the Web. The code doesn't work. Can anybody please tell me what I'm doing wrong and how should the code be amended?

Thanks
forgottenglory is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:42 AM.


Advertisement
Log in to turn off these ads.