PDA

View Full Version : creating movement



jimw00d
March 19th, 2003, 05:08 PM
Avoiding tweening what method can I use to get a shape to move from off the stage on the right to a position centre stage. I want to control the speed of the movement and I want to stop the movement after a defined period.

I have tried to use for loops and if conditionals but neither work.

I want the movement to execute on a button press.

i.e. on(press){
movement function ()
}

etc

Can anyone help on this

cheers

eyeinfinitude
March 20th, 2003, 07:39 AM
You can try something like this, maybe it will give you some idea. I attached an example. =)

jimw00d
March 20th, 2003, 08:06 AM
I was thinking of something more like this.

Although I can't figure out how to return the red block to its original position, when say, another button is pressed.

Any ideas??

kode
March 20th, 2003, 09:06 AM
take eg's file and throw this code in it :)

MovieClip.prototype.move = function(x) {
this.onEnterFrame = function() {
if (Math.ceil(this._x) != x) {
this._x += (x-this._x)/10;
} else {
this._x = x;
delete this.onEnterFrame;
}
}
}
buttonMC.onRelease = function() {
!clicked ? box.move(430) : box.move(170);
!clicked ? clicked=true : clicked=false;
}
something like that?