Flash Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignFlash Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 27th, 2003, 07:14 PM
shokesy shokesy is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Posts: 62 shokesy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 46 m 42 sec
Reputation Power: 6
simple duplicatemovieclip question.

scenario:

- i have a movie clip called "ball"
- i have a button with the following code:

on(press){
for(n=1; n<=5; n++){
ball.duplicateMovieClip("ball01",n);
ball01._x = 20;
ball01._alpha= 20;

}
}


=============================
I'm trying to learn how to duplicate the clip multiple times (like 5 times. I'm having trouble on what kind of code to write to do this.
any suggestions?

thanksNadvance.

Reply With Quote
  #2  
Old July 29th, 2003, 04:38 AM
jamieB jamieB is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Nov 2002
Posts: 592 jamieB User rank is Sergeant (500 - 2000 Reputation Level)jamieB User rank is Sergeant (500 - 2000 Reputation Level)jamieB User rank is Sergeant (500 - 2000 Reputation Level)jamieB User rank is Sergeant (500 - 2000 Reputation Level)jamieB User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 1 h 56 m 16 sec
Reputation Power: 17
you have to give your new clips unique names, so stick the counter var on the end of the name:

Code:
on(press){ 
for(n=1; n<=5; n++){ 
ball.duplicateMovieClip("ball"+n,n); 
this["ball"+n]._x = 20; 
this["ball"+n]._alpha= 20; 

} 
} 

Reply With Quote
  #3  
Old July 29th, 2003, 03:58 PM
shokesy shokesy is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Posts: 62 shokesy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 46 m 42 sec
Reputation Power: 6
thanks a lot buddy! it works.

my question however, is how the this["ball"+n] syntax works? I know what "this" is, but my understanding of it is it applies to an object refering to itself, but in this case, the code is on the button, so wouldn't the button be considered "this"? i guess its the array like syntax that is confusing me.

but thanks!

Reply With Quote
  #4  
Old July 29th, 2003, 04:23 PM
jamieB jamieB is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Nov 2002
Posts: 592 jamieB User rank is Sergeant (500 - 2000 Reputation Level)jamieB User rank is Sergeant (500 - 2000 Reputation Level)jamieB User rank is Sergeant (500 - 2000 Reputation Level)jamieB User rank is Sergeant (500 - 2000 Reputation Level)jamieB User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 1 h 56 m 16 sec
Reputation Power: 17
code on buttons is in the scope of it's parent timeline, so in this case *this* means root

Reply With Quote
  #5  
Old July 29th, 2003, 05:53 PM
shokesy shokesy is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Posts: 62 shokesy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 46 m 42 sec
Reputation Power: 6
hmm I'm still confused (i'm pretty newbie-ish ;-) ), but i guess i was expecting to see

eval("ball"+n)._x = n*5;
eval("ball"+n)._alpha = 20;

instead of

this["ball"+n]._x = 20;
this["ball"+n]._alpha= 20;

...I guess I just never knew the "this" syntax could be used this way...but im still not sure of the difference???

Reply With Quote
  #6  
Old July 30th, 2003, 04:09 AM
jamieB jamieB is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Nov 2002
Posts: 592 jamieB User rank is Sergeant (500 - 2000 Reputation Level)jamieB User rank is Sergeant (500 - 2000 Reputation Level)jamieB User rank is Sergeant (500 - 2000 Reputation Level)jamieB User rank is Sergeant (500 - 2000 Reputation Level)jamieB User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 1 h 56 m 16 sec
Reputation Power: 17
usinf eval in that way is really a throwback to flash 4 - since 5 it's better to use dot notation and the square brackets, but I think eval would also work.

Reply With Quote
  #7  
Old July 30th, 2003, 04:11 AM
jamieB jamieB is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Nov 2002
Posts: 592 jamieB User rank is Sergeant (500 - 2000 Reputation Level)jamieB User rank is Sergeant (500 - 2000 Reputation Level)jamieB User rank is Sergeant (500 - 2000 Reputation Level)jamieB User rank is Sergeant (500 - 2000 Reputation Level)jamieB User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 1 h 56 m 16 sec
Reputation Power: 17
using eval in that way is really a throwback to flash 4 - since 5 it's better to use dot notation and the square brackets, but I think eval would also work.

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignFlash Help > simple duplicatemovieclip question.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway