Never ending movement

Code Actionscript 2.0

Instance action

onClipEvent (enterFrame) {
this._x = this._x + 10;
if (this._x > 425) {
this._x = -25;
}
}

Code Actionscript 3.0

addEventListener(Event.ENTER_FRAME, enterFrame); function enterFrame(event:Event) { square.x = square.x + 10; if (square.x > 425) { square.x = -25; } }

Description

With this script, the x-coordinates of the square are increased incrementally. The conditional if statement determines whether the right border of the stage has been reached. If this is the case, the square will be moved to the x position -25, where the movement will begin once again from the left side of the stage.

Download

Right click: Flashfile AS 2.0 | Flashfile AS 3.0 | SWF-File


Share