for..in test

by yd_niku
♥0 | Line 26 | Modified 2012-02-13 19:55:03 | MIT License
play

ActionScript3 source code

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

package {
    import flash.text.TextField;
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
        public function FlashTest() {
            // write as3 code here..
            
            var textField:TextField = new TextField();
            textField.width = stage.stageWidth;
            textField.height = stage.stageHeight;
            
            addChild(textField);
            
            var str :String = "";
            
            Object.prototype.peko = true;
            
            
            var obj:Object = {
                 foo:"foo",
                 bar:"bar",
                 hoge:1   
            };
            
            // OK
            obj.setPropertyIsEnumerable("hoge",false);
            
            // NG
            obj.setPropertyIsEnumerable("peko",false);
            // OK
            Object.prototype.setPropertyIsEnumerable("peko",false);
            
            for (var key:String in obj) {
                str += key + "\n";
            }
            
            textField.text = str;
        }
    }
}