flash on 2009-6-29

by takawo
配列操作について
♥0 | Line 45 | Modified 2009-06-30 17:26:16 | MIT License
play

ActionScript3 source code

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

package {
//配列操作について

    import flash.display.Sprite;
    import flash.events.MouseEvent;
    import flash.text.TextField;
    import flash.text.TextFormat;
    
    [SWF(width = "465", height = "465", backgroundColor="0xffffff")]
    public class ArrayTest extends Sprite 
    {
        
        public function ArrayTest() 
        {
            _array = new Array();
            _textArray = new Array();
            for(var i:uint = 0; i < 100; i++)
            {
                  _array.push(i);
            }
            _array.reverse();
            for(var n:uint = 0; n < 100; n++)
            {
                var tf:TextField = new TextField();
                var txtFormat:TextFormat = new TextFormat();
                txtFormat.align = "center";
                tf.setTextFormat(txtFormat);

                addChild(tf);
                _textArray.push(tf);
                tf.text = _array[n];
                tf.x = Math.floor((n % 10) * 46.5);
                tf.y = Math.floor(int(n / 10) * 46.5);                  
            }
            
            stage.addEventListener(MouseEvent.CLICK,onClickHandler);
            stage.buttonMode= true;
            stage.useHandCursor = true;
        }
        private var _array:Array;
        private var _textArray:Array;
        
        private function onClickHandler(event:MouseEvent):void
        {
            _array.reverse();
            for(var n:uint = 0; n < 100; n++)
            {
                _textArray[n].text = _array[n];
            }
         
        }
    }
}

Forked