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

test object animation

Get Adobe Flash player
by alptugan 09 Sep 2010
/**
 * Copyright alptugan ( http://wonderfl.net/user/alptugan )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/waLa
 */

package {
    import flash.display.Sprite;
    import flash.display.Shape;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.EventDispatcher;
    import flash.events.TimerEvent;
    import flash.utils.Timer;
    
    public class PreloaderUranium extends Sprite {
        
        private var T: Timer;
        private var r:Number,c:uint,cCircle:uint;
        private var Mask:Shape;
        private var Ur : Shape;
        public var tex : ABasicTextField;
        
        public function PreloaderUranium(c:uint = 0xffcc00,cCircle:uint = 0x333333, r:Number = 26) {
            // write as3 code here..
            this.c = c;
            this.r = r;
            this.cCircle = cCircle;
            
            
            addEvent(this,Event.ADDED_TO_STAGE,onAdded);
            addEvent(this,Event.REMOVED_FROM_STAGE,onRemoved);
        }
        
        private function onAdded (e:Event):void
        {
            
            this.x = stage.stageWidth >> 1;
            this.y = stage.stageHeight >> 1;
            Ur = new Shape();
            with(Ur.graphics)
            {
                beginFill(cCircle);
                drawCircle(0,0,r >> 1);
                beginFill(c);
                drawRect(0,-r >> 1, r >> 1,  r >> 1);
                drawRect(-r >> 1,0, r >> 1,  r >> 1);
                endFill();
            }
            addChild(Ur);
            Mask = new Shape();
            with(Mask.graphics)
            {
                beginFill(cCircle);
                drawCircle(0,0,r >> 1);
                endFill();
            }
            addChild(Mask);
            Ur.mask = Mask;
            
            T = new Timer(1);
            addEvent(T,TimerEvent.TIMER, SpinTheShape);
            T.start();
            
            ShowTitle();
            removeEvent(this,Event.ADDED_TO_STAGE,onAdded);
            
        }
        
        public function ShowTitle(str:String = " LOADING ", pos:String = "center",bgFill:Boolean = false):void
        {
            tex = new ABasicTextField(cCircle,c,bgFill);
            addChild(tex);

            tex.Tf.htmlText = str;
            
            switch(pos)
            {
                case "center":
                    tex.y = r;
                    tex.x = - tex.width >> 1;
                    break;
                
                case "right":
                    tex.x = r - 5;
                    tex.y = -(tex.height >> 1) ;
                    break;
            }
            
        }
        private function SpinTheShape(e:TimerEvent):void
        {
            var rot :Number = 4;
            Ur.rotation += rot;
        }
        
        private function onRemoved (e:Event):void
        {
            T.stop();
            Ur = null;
            Mask = null;
            removeEvent(T,TimerEvent.TIMER, SpinTheShape);
            removeEvent(this,Event.REMOVED_FROM_STAGE,onRemoved);
        }
        
        private function addEvent(_arg1:EventDispatcher, _arg2:String, _arg3:Function):void{
            _arg1.addEventListener(_arg2, _arg3, false, 0, true);
        }
        private function removeEvent(_arg1:EventDispatcher, _arg2:String, _arg3:Function):void{
            _arg1.removeEventListener(_arg2, _arg3);
        }
    }
}


import flash.display.Sprite;
    import flash.events.Event;
    import flash.text.TextField;
    import flash.text.TextFieldAutoSize;
    import flash.text.TextFormat;
class ABasicTextField extends Sprite
    {
        public var Tf : TextField ;
        public var Ft : TextFormat = new TextFormat();
        public var c : uint;
        public var bg : uint;
        public var bgFill :Boolean;
        
        public function ABasicTextField(c:uint = 0x000000,bg:uint = 0x000000,bgFill:Boolean=true)
        {
            this.c  = c;
            this.bg  = bg;
            this.bgFill = bgFill;
            addEventListener(Event.ADDED_TO_STAGE, init);
        }
        
        private function init(e:Event):void
        {
            removeEventListener(Event.ADDED_TO_STAGE, init);
            Tf  = new TextField();
            
            Tf.selectable           = false;
            Tf.multiline            = false;
            Tf.wordWrap             = false;
            Tf.autoSize             = TextFieldAutoSize.LEFT;
            Tf.background = bgFill;
            Tf.backgroundColor = bg;
            Ft.color                = c;
            Ft.font                 = "Arial";
            Ft.size                 = 9;
            Ft.letterSpacing        = 1;
            Tf.defaultTextFormat    = Ft;
            
            Tf.htmlText = "Dummy Text";
            addChild(Tf);
        }
    }