Tutorial | Animating with Physics and AS3
by Carlos Pinho, June 5th, 2008

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.

Read Tutorial

Tags: , , , , , , , , , ,

No Responses to “Tutorial | Animating with Physics and AS3”

  1. jodi Says:

    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;
    }
    }
    }

  2. jodi Says:

    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;
    }
    }
    }

Let leave a Comments for this post.