all groups > flash actionscript > october 2006 >
You're in the

flash actionscript

group:

Need Help with this code



Need Help with this code Clandestinex337
10/22/2006 8:50:26 PM
flash actionscript: Alright so i have this code that makes a bottle every two seconds and moves
from the right to left. But once it moves off the screen the bottle gets moved
to the center of the stage and stays there. How can I make this so that it
doesnt stay there and stays off the stage?

[url]http://img.photobucket.com/albums/v398/clandestinex337/test.swf[/url]

also im woundering how i can make the bottles closer together so their isnt
that big of a gap between the other bottles..

Heres the code


i = 100;
while (i>1) {
_root.attachMovie("bottle", "bottle"+i, i);
_root["bottle"+i]._x = 400+(i*100); _
_root["bottle"+i].onEnterFrame=function(){
this._x-=5;
if(this._x<=100){
this._x=100
this.play();
this.onEnterFrame=null;
}
}
i--;
}


I got this code from someone else and i dont really know what each line of
code does so if someone could be so kind to expaine whats going on in this
script?

THANKS
Re: Need Help with this code kglad
10/23/2006 12:27:39 AM
try:



i = 100;
gap = 50; // set the gap to suit your needs.
while (i>1) {
_root.attachMovie("bottle", "bottle"+i, i);
_root["bottle"+i]._x = 400+(i*gap);
i--;
}
this.onEnterFrame = function() {
i = 100;
while (i>1) {
mc = _root["bottle"+i];
mc._x -= 5;
if (mc._x<=0) {
mc.removeMovieClip();
if (i == 1) {
delete this.onEnterFrame;
}
}
i--;
}
};
AddThis Social Bookmark Button