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 World -Char Panel-

Main Class of this program
Get Adobe Flash player
by ayataka 08 Feb 2009
    Embed
package {
    //
    import flash.display.*;
    import flash.text.*;
    import flash.events.*;
    import fl.transitions.*;
    import fl.transitions.easing.*;
    import fl.transitions.TweenEvent;
    import mx.events.*;

    /**
     * Main Class of this program
     */
    [SWF(backgroundColor="#FFFFFF", frameRate=24)]
    public class Main extends Sprite {
        /**
         */
        private var ss:Array;
        private var tf:TextField;

        /**
         * Constructor(Entry Point)
         */
        public function Main() {
            //
            tf = new TextField();
            addChild( tf );
            tf.text = "Please click this screen.";
            tf.autoSize = TextFieldAutoSize.LEFT;
            //
            ss = createCharsSprite("Hello World", 40);
            ss.forEach(function(item:*, i:int, a:Array):void {
                           addChild( item );
                       } );


            //
            stage.addEventListener(MouseEvent.CLICK, clicked);
        }

        /**
         */
        public function clicked(event:Event):void
        {
            ss.forEach(function(item:*, i:int, a:Array):void {
                           var t:Tween;
                           t = new Tween(item, "x", Back.easeOut,
                                         0, i * 40, 2.5 + i * 0.2,
                                         true);
                               new Tween(item, "rotationY", Back.easeOut,
                                         180, 0, 2.5 + i * 0.2,
                                         true);
                           t.addEventListener("motionFinish", finish);
                       } );
        }

        /**
         */
        public function finish(event:Event):void {
            //
            var obj:Object = event.currentTarget.obj;
            new Tween(obj, "x",
                      Back.easeOut, obj.x, 500, 3.5, true);
            new Tween(obj, "rotationY",
                      Back.easeOut, obj.rotationY, -90, 3.5, true);
        }

        /**
         */
        public function createCharsSprite(text:String, size:int):Array {
            //
            var sprites:Array = new Array();
            
            //
            for(var i:int = 0; i < text.length; ++i) {
                //
                var s:StringSprite = new StringSprite(text.charAt(i),
                                             size,
                                             Math.random() * 0xFFFFFF);
                sprites.push( s );
                s.x += (size * i);
                s.y = stage.stageHeight / 2 - size / 2;

                // スペースは無視
                if( text.charAt(i) == " " ) {
                    s.visible = false;
                }
            }

            
            //
            return sprites;            
        }
    }
}


//-------------------------------------------------------------------------
//


//
import flash.display.*;
import flash.text.*;

/**
 */
class StringSprite extends Sprite {
    /**
     */
    public function StringSprite(text:String, size:int, color:uint) {
        //
        var format:TextFormat = new TextFormat();
        format.size = size;
        format.color = 0xFFFFFF;
        var tf:TextField = new TextField();
        tf.text = text;
        tf.autoSize = TextFieldAutoSize.CENTER;
        tf.setTextFormat( format );
        tf.x = size / 2 - tf.width / 2;
        tf.y = size / 2 - tf.height / 2;
        //
        this.graphics.beginFill(color);
        this.graphics.drawRect(0, 0, size, size);
        this.graphics.endFill();
        //
        this.addChild( tf );
    }
}