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

code on 2008-12-17

Get Adobe Flash player
by risay 17 Dec 2008
// write as3 code here..
package {
    import flash.display.MovieClip;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import org.libspark.thread.*;
    import org.libspark.thread.utils.SerialExecutor;
    import org.libspark.thread.threads.tweener.TweenerThread;
    public class Test extends MovieClip {
        private var box:Sprite;
        public function Test () {
            var bg:Sprite = new Sprite();
            bg.graphics.beginFill(0xffffff);
            bg.graphics.drawRect(0,0,stage.stageWidth,stage.stageHeight);
            bg.graphics.endFill();
            addChild(bg);
            var g:Sprite = new Sprite();
            g.graphics.beginFill(0);
            g.graphics.drawRect(0,0,100,100);
            g.graphics.endFill();
            box = addChild(g) as Sprite;
            init();
            addEventListener(MouseEvent.CLICK, clickHandler);
            addEventListener(Event.UNLOAD, finalize);
            var st:SerialExecutor = new SerialExecutor();
            st.addThread(new TweenerThread(box,{x:(stage.stageWidth-box.width)/2,time:1}));
            st.addThread(new TweenerThread(box,{y:(stage.stageHeight-box.height)/2,time:1}));
            st.start();
         }
        private function init():void {
            if(!Thread.isReady) {
                Thread.initialize(new EnterFrameThreadExecutor());
            }
        }
        private function finalize(e:Event):void {
            removeEventListener(MouseEvent.CLICK, clickHandler);
            removeEventListener(Event.UNLOAD, finalize);
        }
        private function clickHandler(e:Event):void {
            var st:SerialExecutor = new SerialExecutor();
            st.addThread(new TweenerThread(box,{x:mouseX-box.width/2,time:1}));
            st.addThread(new TweenerThread(box,{y:mouseY-box.height/2,time:1}));
            st.start();
        }
    }
}