3D Container

by fakestar0826
♥0 | Line 32 | Modified 2011-01-14 00:56:11 | MIT License
play

ActionScript3 source code

/**
 * Copyright fakestar0826 ( http://wonderfl.net/user/fakestar0826 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/bflX
 */

package {
    import flash.events.Event;
    import flash.text.TextFormat;
    import flash.text.TextField;
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
        
        private var _sprite:Sprite;
        private var _n:Number = 0;
        public function FlashTest() {
            // write as3 code here..
            
            _sprite = new Sprite();
            _sprite.y = stage.stageHeight / 2;
            
            for(var i:int = 0; i < 100; i++)
            {
                var tf:TextField = new TextField();
                tf.defaultTextFormat = new TextFormat("Arial", 40);
                tf.text = String.fromCharCode(65 + Math.floor(Math.random() * 25));
                tf.selectable = false;
                tf.x = Math.random() * 300 - 150;
                tf.y = Math.random() * 300 - 150;
                tf.z = Math.random() * 1000;
                //親のSpriteに対して3次元上に配置。
                _sprite.addChild(tf);
            }
            
            addChild(_sprite);
            addEventListener(Event.ENTER_FRAME, onEnterFrame);

        }
        
        private function onEnterFrame(e:Event):void
        {
            _sprite.x = stage.stageWidth / 2 + Math.cos(_n) * 200;
            _n += 0.05;
        }

    }
}