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

do while中で宣言された変数は型が無視される、でFA?

Get Adobe Flash player
by psyark 14 Jan 2010
    Embed
/**
 * Copyright psyark ( http://wonderfl.net/user/psyark )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/1lFz
 */

// forked from bkzen's forked from: forked from: バグ?
// forked from uwi's forked from: バグ?
// forked from uwi's バグ?
package {
    import flash.display.Sprite;
    import flash.text.TextField;
    import flash.utils.getTimer;
    import flash.utils.describeType;
    public class Test extends Sprite {
        private var _tf : TextField;
  
        public function Test() {
            _tf = new TextField();
            _tf.width = 465;
            _tf.height = 465;
            addChild(_tf);
            
            var s : int = getTimer();
            
            var b : uint;
            do{
                var a:uint; // 宣言された場所が問題
                a = 4 / 3; // 代入された場所は問題ではない
                b = 4 / 3;
                tr(describeType(b).@name);
                tr(describeType(a).@name);
                
                // いれほうだい!おこられない!(・∀・)
                var c:uint = {};
                var d:uint = <xml/>;
                var e:uint = /\w+/;
                var f:uint = new TextField();
            }while(false);
            
            var g : int = getTimer();
            tr((g - s) + " ms");
        }

        private function tr(...o : Array) : void
        {
            _tf.appendText(o + "\n");
        }
    }
}