
This tutorial is for anyone who wants to learn how to animate objects with the help of some simple physics. All done by Actionscript 3.0 of course.
Tags: Actionscript 3, Adobe, animating, AS3, code, developing, Flash, how to, physics, Source, Tutorial
ShareThis
October 4th, 2008 at 4:36 am
I am so confused how I can use an illustrator file (image) with an as file (movement). Here is the as file to animate a simple red ball
package
{
import flash.display.Sprite;
import flash.events.Event;
public class Bobbing extends Sprite {
private var ball:Ball;
private var angle:Number = 0;
private var centerY:Number = 200;
private var range:Number = 50;
private var speed:Number = .1;
public function Bobbing() {
init();
}
private function init():void {
ball = new Ball();
addChild(ball);
ball.x = stage.stageWidth / 2;
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
public function onEnterFrame(event:Event):void {
ball.y = centerY + Math.sin(angle) * range;
angle += speed;
}
}
}
October 4th, 2008 at 4:36 am
package
{
import flash.display.Sprite;
import flash.events.Event;
public class Bobbing extends Sprite {
private var ball:Ball;
private var angle:Number = 0;
private var centerY:Number = 200;
private var range:Number = 50;
private var speed:Number = .1;
public function Bobbing() {
init();
}
private function init():void {
ball = new Ball();
addChild(ball);
ball.x = stage.stageWidth / 2;
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
public function onEnterFrame(event:Event):void {
ball.y = centerY + Math.sin(angle) * range;
angle += speed;
}
}
}