In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

FollowMouse3D

Get Adobe Flash player
by fakestar0826 16 Jan 2011
    Embed
/**
 * Copyright fakestar0826 ( http://wonderfl.net/user/fakestar0826 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/vq7H
 */

package {
    import flash.geom.Vector3D;
    import flash.events.Event;
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
        private var _sprite:Sprite;
        private var _angleX:Number = 0;
        private var _angleY:Number = 0;
        private var _angleZ:Number = 0;
        public function FlashTest() {
            // write as3 code here..
            
            _sprite = new Sprite();
            _sprite.graphics.beginFill(0xFF0000);
            _sprite.graphics.moveTo(0, 50);
            _sprite.graphics.lineTo(-25, 25);
            _sprite.graphics.lineTo(-10, 25);
            _sprite.graphics.lineTo(-10, -50);
            _sprite.graphics.lineTo(10, -50);
            _sprite.graphics.lineTo(10, 25);
            _sprite.graphics.lineTo(25, 25);
            _sprite.graphics.lineTo(0, 50);
            _sprite.graphics.endFill();
            addChild(_sprite);
            
            addEventListener(Event.ENTER_FRAME, onEnterFrame);
        }
        
        private function onEnterFrame(e:Event):void
        {
            _sprite.x = 200 + Math.sin(_angleX += 0.11) * 200;
            _sprite.y = 200 + Math.sin(_angleY += 0.07) * 200;
            _sprite.z = Math.sin(_angleZ += 0.09) * 200;
            _sprite.transform.matrix3D.pointAt(new Vector3D(mouseX, mouseY, 0));
        }

    }
}