Shivering movement

Code Actionscript 2.0

Instance action

onClipEvent (enterFrame) {
this._y = this._y + random(3)-1;
this._x = this._x + random(3)-1;
}

Code Actionscript 3.0

addEventListener(Event.ENTER_FRAME, enterFrame); function enterFrame(event:Event) { square.y = square.y + int(Math.random()*3)-1; square.x = square.x + int(Math.random()*3)-1; }

Description

With this script, the position of the square moves randomly in a horizontal and a vertical direction. The function random(3)-1 (int(Math.random()*3)-1 respectively) generates a random number between -1 and 1. This results in a shivering movement.

Download

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


Share