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

Hello, Wonderfl !!!

@author OKI Yoshiya (ceroan)
Get Adobe Flash player
by 448jp 17 Dec 2008
    Embed
/**
 * Copyright 448jp ( http://wonderfl.net/user/448jp )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/aiuo
 */

// write as3 code here..
package {

    /** 
     *  
     * @author OKI Yoshiya (ceroan)
     */  

    import flash.display.*;
    import flash.events.*;
    import flash.text.*;
    import flash.geom.Matrix;

    [SWF(frameRate="2")]  

    public class HelloWonderfl extends MovieClip {

        private var container:Sprite;

        public function HelloWonderfl() {
            container = new Sprite();
            addChild(container);
            stage.addEventListener(MouseEvent.CLICK, onClick);
            addEventListener(Event.ENTER_FRAME, onEnterFrame);
        }

        private function onEnterFrame(e:Event):void {
            var b:Bitmap = capture(getGreeting("Hello, Wonderfl !!!"));
            b.x = (stage.stageWidth + b.width) * Math.random() - b.width;
            b.y = (stage.stageHeight + b.height) * Math.random() - b.height;
            container.addChild(b);
        }

        private function getGreeting(str:String):TextField {
            var myText:TextField = new TextField();
            myText.autoSize = "left";
            myText.selectable = false;
            var tf:TextFormat = new TextFormat();
            tf.font = "Verdana";
            var z:Number = Math.random();
            tf.size = 24 * z;
            myText.defaultTextFormat = tf;
            myText.text = str;
            return myText;
        }

        private function capture(target:DisplayObject):Bitmap {
            var bd:BitmapData = new BitmapData(target.width, target.height, false, 0xFFFF0000);
            bd.draw(target);
            var b:Bitmap = new Bitmap(bd);
            return b;
        }

        private function onClick(e:MouseEvent):void {
            removeChild(container);
            container = new Sprite();
            addChild(container);
        }

    }
}