Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 05-18-2007, 11:52 AM   #1
jettamonkey
Registered User
 
Join Date: May 2007
Posts: 3
Default Referring to dynamically named movie clips in actionscript

Hi there

Basically, I'm really confused about the syntax for referring to a movie clip which you've created in a for loop, and named accordingly, like so:


for(i = 1; i < 8; i++){
j = "holder"+i;
createEmptyMovieClip(instanceName=j,i);
loadMovie(i+".png",j);
j._x = 30 + (i*80);
}


So, that all works fine, except for the last line :

j._x = 30 + (i*80);


Obviously I want to set each mc's x to a different position, but I guess I must just not be referring to it correctly? Which is weird, because the loadMovie(i... thing works fine. What I'm doing at the moment is setting it manually after the for loop but that's so dumb when I could cut down 14 lines of code to 2 lines (I'm doing both the x and y co-ords).

Any help appreciated!
jettamonkey is offline   Reply With Quote
Old 05-18-2007, 12:03 PM   #2
saravanan
You have the power
 
saravanan's Avatar
 
Join Date: Jun 2006
Location: Chennai(Now @ Bangalore),India
Posts: 716
Send a message via MSN to saravanan
Default

for (i=1; i<8; i++) {
j = "holder"+i;
createEmptyMovieClip(instanceName=j, i);
loadMovie(i+".jpg", j);
_root[j]._x = 30+(i*80);
}
saravanan is offline   Reply With Quote
Old 05-18-2007, 12:23 PM   #3
inhan
it's all about patience
 
inhan's Avatar
 
Join Date: Jun 2005
Location: istanbul
Posts: 6,696
Default

ActionScript Code:
for (var i:Number = 1; i < 8; i++) {     var j:String = "holder" + i;     var mc:MovieClip = createEmptyMovieClip(j, i);     mc.loadMovie(i + ".png");     mc._x = 30 + (i * 80); }
__________________
Ali Inhan
Turkish graphic and web designer
an Apple fan
www.aliinhan.com
inhan is offline   Reply With Quote
Old 05-18-2007, 12:31 PM   #4
jettamonkey
Registered User
 
Join Date: May 2007
Posts: 3
Default

Wow thank you both so much! It was driving me out of my mind. Ty for the speedy replies too.
jettamonkey is offline   Reply With Quote
Reply


Thread Tools
Display Modes 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 Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Trouble with attachMovie and dynamically created Movie clips hgzee ActionScript 2.0 1 12-14-2006 07:53 AM
moving movie clips with actionscript 2 Kenzo ActionScript 2.0 3 11-01-2006 07:08 PM
Dynamically placed movie clips stretching?? jared123 ActionScript 2.0 0 10-14-2006 05:25 PM
Loading images in different frames.. nchagial ActionScript 2.0 22 12-21-2005 08:06 AM
Problem With Loading MovieClip Into SUB movie JakeMX Components 2 07-28-2004 10:07 PM


All times are GMT. The time now is 02:44 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.