flash on 2017-2-7
♥2 |
Line 45 |
Modified 2017-02-07 19:40:15 |
MIT License
archived:2017-03-05 05:30:05
ActionScript3 source code
/**
* Copyright tiMMy ( http://wonderfl.net/user/tiMMy )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/KyGF
*/
package {
import flash.events.Event;
import flash.display.Sprite;
public class FlashTest extends Sprite {
protected var fTime: Number = 0;
protected var fDeltaTime: Number = 0;
protected var fX: Number = 0;
protected var fY: Number = 0;
protected var fCircle: Sprite = null;
protected var fFirstDraw: Boolean = true;
public function FlashTest() {
// write as3 code here..
addEventListener( Event.ADDED_TO_STAGE, onAddedToStage );
addEventListener( Event.ENTER_FRAME, onUpdate );
}
protected function onAddedToStage (e: Event): void
{
fDeltaTime = 1/stage.frameRate;
graphics.beginFill(0xF77149, 1);
graphics.lineStyle(2, 0x000000, 0);
graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
graphics.endFill();
fCircle = new Sprite();
fCircle.graphics.beginFill(0xFFFFFF, 0.3);
fCircle.graphics.drawEllipse(-15, -15, 30, 30);
fCircle.graphics.endFill();
graphics.lineStyle(2, 0x000000, 0.5);
addChild ( fCircle );
}
protected function onUpdate( e: Event): void
{
fTime += fDeltaTime;
fX = stage.stageWidth / 2 + Math.cos(fTime) * 40 * (Math.cos(fTime*3) * Math.cos(fTime*3) + 1);
fY = stage.stageWidth / 2 + Math.sin(fTime) * 40 * (Math.cos(fTime*3) * Math.cos(fTime*3) + 1);
fCircle.x = fX;
fCircle.y = fY;
if(fFirstDraw)
{
fFirstDraw = false;
graphics.moveTo( fX, fY );
}
else
graphics.lineTo( fX, fY );
}
}
}