Simple Animation Question
hey everyone!
i still new in process of learning flash, far has been great fun. problem relates animation uses x , y axis.
for(loop =0; loop < 5; loop++){
boxname = "box" + loop;
attachmovie("box", boxname, 10 * loop);
var randomplace:number= random(500) + 550;
var numx:number = randomplace;
var numy:number = random(100);
var myspeed:number = random(10) + 5;
_root[boxname]._x = numx;
_root[boxname]._y = numy;
_root[boxname].onenterframe = function(){
this._x-= myspeed;
if(this._x < 0)
this._x= random(500) + 550;
}//end function
}//end inside loop
what code above displaying small boxes moving right screen left, , come again (like loop suppose) , each time 'box' re-appear, starts off @ random place @ top of screen.
now pritty same, want make it drops top screen bottom. ( snow falling sky). can't ahead around x / y axis , confuses me.
also, size of frame 550x400
any fantastic!
use:
var gravity:number = 3;for(loop =0; loop < 5; loop++){
boxname = "box" + loop;
var mc:movieclip = attachmovie("box", boxname, 10 * loop);
mc._x = (550-mc._width)*math.random();;
mc._y = 100*math.random();
mc.speed =10*math.random()+ 5; // if want objects have different "drift" value
mc.onenterframe = function(){
this._x-= this.speed;this._y += gravity;
if(this._x < 0||this._y>stage.height){
this._x= 550;this._y = 0;
}
}
}//end inside loop
More discussions in Adobe Animate CC - General
adobe
Comments
Post a Comment