PDA

View Full Version : duplicating prob


cardin
02-11-2003, 02:25 PM
I am trying to duplicate this movieclip but it seemed not to be working, why?
onClipEvent (enterFrame) {
for (i=1; i<=_root.database.noOfFly; i++) {
duplicateMovieClip ("_root.fly", _root["fly"+i], i);
_root["fly"+i]._x=Math.random()*300;
_root["fly"+i]._y=Math.random()*300;
}
}

annexion
02-11-2003, 05:04 PM
onClipEvent (enterFrame) {
for (i=1; i<=_root.database.noOfFly; i++) {
_root.fly.duplicateMovieClip ( "fly"+i, i);
_root["fly"+i]._x=Math.random()*300;
_root["fly"+i]._y=Math.random()*300;
}
}

Try that. If you are duplicating "fly", and those actions are in "fly" itself then use the following.

onClipEvent (enterFrame) {
for (i=1; i<=_root.database.noOfFly; i++) {
this.duplicateMovieClip ( "fly"+i, i);
_root["fly"+i]._x=Math.random()*300;
_root["fly"+i]._y=Math.random()*300;
}
}

Good luck.

cardin
02-12-2003, 12:35 AM
The duplicatind worked. But the fly kept duplicating all over the place, ten on the stage at any one time. Why?

onClipEvent (enterFrame) {
if (!duplicate) {
for (i=1; i<=_root.database.noOfFly; i++) {
_root.fly.duplicateMovieClip("fly"+i, i);
_root["fly"+i]._x = Math.random()*300;
}
duplicate=true;
}
}


Also, the fly is a animating movieclip, not a standstill one. However, when i used the duplicate movieclips ( I manage to control one or two flies by directly controling its _x, and i saw this ) the duplicated movieclips were staying constantly at frame 1.

cardin
02-12-2003, 05:56 AM
Here's my file if you ever wanna check.