Basic Animation is ActionScripting 3.0
I'm fascinated by animation with scripting so I will present a quick start out tutorial on basic animation technique using ActionScripting 3.0. Let's start and enjoy.
// Copyright by CreativeReform
// All rights reserved
package{
//import statement for the package
import flash.display.Sprite;
import flash.events.Event;
//start of the animation class
//exstends sprites since we will be creating circles
public class Animation extends Sprite{
private var ball:Sprite;
//start of animation function
public function Animation(){
//This function will only call the init() function below
init();
}
private function init(){
//ball is created, colorized set x and y
ball = new Sprite();
addChild(ball);
ball.graphics.beginFill(0xff0000);
ball.graphics.drawCircle(0,0,40);
ball.graphics.endFill();
ball.x = 50;
ball.y = 50;
//we then add eventlistener to call onBallMove function on enterFrame
ball.addEventListener(Event.ENTER_FRAME, onBallMove);
}
private function onBallMove(e:Event):void{
//EnterFrame will advance the ball
ball.x++;
}
}
}