Ellipse

Code Actionscript 2.0

Instance action

onClipEvent (load) {
centerx = 200;
centery = 200;
angle = 0;
radiusx = 150;
radiusy = 60;
speed = 5;
}

onClipEvent (enterFrame) {
angle = angle - speed;
this._x = centerx + radiusx * Math.sin(angle * Math.PI / 180);
this._y = centery + radiusy * Math.cos(angle * Math.PI / 180);
}

Code Actionscript 3.0

addEventListener(Event.ENTER_FRAME, enterFrame); var centerx= 200; var centery= 200; var angle= 0; var radiusx = 150; var radiusy = 60; var speed = 5; function enterFrame(event:Event){ angle= angle- speed; square.x = centerx+ radiusx * Math.sin(angle* Math.PI / 180); square.y = centery+ radiusy * Math.cos(angle* Math.PI / 180); }

Description

This script generates an elliptical movement. Two oscillating paths of varying scale are composed onto the horizontal and vertical axis, producing an elliptical movement.

related to: Circular movement

Download

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


Share