Question
Random Moving Words
Hello All!
I'm about 2 hours into ActionScript 3 ... and to flash.. haha! I'm trying to have words move/appear randomly in different locations and I found some code online for something that is very similar to what I want but it is in AS2. Can someone please help me translate. I've started attempting a translation but I think a pro would do it better. If you need the translation I've got so far I can post it later.
This is the AS2 code:
for(i=0;i<5;i++) {
var t = this.attachMovie("ball","ball"+i,i);
t._x = Math.random()*450;
t._y = Math.random()*400;
t.dx = Math.round(Math.random()*450);
t.dy = Math.round(Math.random()*400);
t._xscale = Math.random()*300+40;
t._yscale = t._xscale;
t.onEnterFrame = mover;
}
function mover() {
this._x += (this.dx-this._x)/2;
this._y += (this.dy-this._y)/2;
if(Math.round(this._x) == this.dx) {
this.dx = Math.round(Math.random()*450);
this.dy = Math.round(Math.random()*400);
}
}
I'm about 2 hours into ActionScript 3 ... and to flash.. haha! I'm trying to have words move/appear randomly in different locations and I found some code online for something that is very similar to what I want but it is in AS2. Can someone please help me translate. I've started attempting a translation but I think a pro would do it better. If you need the translation I've got so far I can post it later.
This is the AS2 code:
for(i=0;i<5;i++) {
var t = this.attachMovie("ball","ball"+i,i);
t._x = Math.random()*450;
t._y = Math.random()*400;
t.dx = Math.round(Math.random()*450);
t.dy = Math.round(Math.random()*400);
t._xscale = Math.random()*300+40;
t._yscale = t._xscale;
t.onEnterFrame = mover;
}
function mover() {
this._x += (this.dx-this._x)/2;
this._y += (this.dy-this._y)/2;
if(Math.round(this._x) == this.dx) {
this.dx = Math.round(Math.random()*450);
this.dy = Math.round(Math.random()*400);
}
}