One possible use for this example is to simulate a fly, randomly buzzing around a room. : Oscillation « Animation « Flash / Flex / ActionScript

Home
Flash / Flex / ActionScript
1.Animation
2.Array
3.Class
4.Data Type
5.Development
6.Function
7.Graphics
8.Language
9.Network
10.Regular Expressions
11.Statement
12.String
13.TextField
14.XML
Flash / Flex / ActionScript » Animation » Oscillation 
One possible use for this example is to simulate a fly, randomly buzzing around a room.
 
package {
    import flash.display.Sprite;
    import flash.events.Event;
    
    public class Main extends Sprite {
        private var _sprite:Sprite= new Sprite(  );
        
        public function Main(  ) {
            _sprite.graphics.beginFill(0xffffff100);
            _sprite.graphics.drawCircle(0025);
            _sprite.graphics.beginFill(0x000000100);
            _sprite.graphics.drawCircle(2005);
            _sprite.x = 100;
            _sprite.y = 100;
            addChild(_sprite);
            addEventListener(Event.ENTER_FRAME, onEnterFrame);
        }
        
        public function onEnterFrame(event:Event):void {
            var dx:Number = mouseX - _sprite.x;
            var dy:Number = mouseY - _sprite.y;
            var radians:Number = Math.atan2(dy, dx);
            _sprite.rotation = radians * 180 / Math.PI;
        }
    }    
}

        
Related examples in the same category
1.Oscillation Animation
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.