You are Here:Home>>Old Posts>>Tutorial | Animating with Physics and AS3

Tutorial | Animating with Physics and AS3

Carlos Pinho
By | 2008-06-05T23:38:49+00:00 Jun 5, 2008|Old Posts|

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

About the Author:

Carlos Pinho
A father, a husband and a geek... Carlos was the founder of projects like The Tech Labs and Flash Enabled Blog. He is the founder of TekTuts He is passionate about technologies. Their main skills are in analytics, transport & logistics, business administration. He also writes about programming resources, trends, strategy and web development.

2 Comments

  1. jodi October 4, 2008 at 4:36 am - Reply

    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 October 4, 2008 at 4:36 am - Reply

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

Leave a Reply