Using attachMovie() & duplicateMovieClip
Author: Bill Trikojus
![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|||||
|
|
|||||
![]() |
|
|
|
|
![]() |
|
|
|
|
![]() |
|
|
You can download this attachMovie example from here. Two more things about attachMovie. Using the square bracket syntax about can get pretty messy if you need to do lots of things to your newly attached clip, so to clean the code store the new clip in a temporary variable and then use that variable to set the new clips properties like this: for(i=0;i<20;i++){ You can also attach events to the new clips as soon as they are attached to the stage.
When using this temporary var syntax, please note that there is no point trying to do things to 'newClip' after you have exited the for loop - newClip will only be storing the last clip that was attached. |
|
|
|
|||
|
|
|||
Share
Like this? Click a link below to share it...Subscribe and Download

Comments
2008-05-24: Ravinder Kumar said:Hey, very good examples here it is really helpfull to understand the functions like duplicateMovieClip() and other.
Thaxxxxx
2008-06-21: Indyaner said:
Not one of the Downloadlinks from above works. =(
2008-06-21: Bill Trikojus said:
download links should be ok now
cheers
2008-06-27: rupu said:
this example is extraordinary.
but the thing is
when I create duplicate movie clip it goes only x-axis. actually when duplicateMovieClip touch the end of the stage I want it comes to next row.
Please tell me solution
2008-06-28: Bill Trikojus said:
The most common way of create a grid of dynamic clips is to use a for loop inside a for loop - one for rows and one for columns
eg
// AttachMC Grid Layout Code
// Jesse Stratford, www.actionscripts.org
rows = 10;
cols = 15;
height = 10;
width = 10;
count = 10;
for (var r = 1; r<=rows; r++) {
for (var c = 1; c<=cols; c++) {
count++;
name = 'clip'+r+'_'+c;
_root.attachMovie('myClip', name, count);
with (_root[name]) {
_x = c*width;
_y = r*height;
}
}
}
cheers
2009-01-14: Tracey said:
Bill Trikojus, I was wondering if you could do the same grid pattern but place the movie clips beginning in the center and going out with an equal number of circles around the center point?
2009-05-12: Junior said:
very, very very very goooooooood!
thank you!
2009-06-27: manas said:
how i download?
2010-07-22: hicham said:
very good.
2010-09-04: surya said:
nice examples..................
2010-10-04: Sam said:
I loaded this the made it start of with 7,000 particles and made the stage 50 by 40, and set the bouncing to the smaller stage, and it crash my adobe flash!!!
2010-12-04: Marcus said:
Thank you a lot my friend, very clear instructions, really helpful.
2011-06-09: Santiago Sanchez said:
Hey, thank you so much, this really helped. I'm making a balancing game for my High School CS Class final, and I need to create falling objects to fall onto the balance. This is perfect! THANK YOU!
Post a comment
Garbage posts and SPAM will be deleted.




