wtf?

by yonatan
♥0 | Line 26 | Modified 2010-04-07 08:18:57 | MIT License
play

ActionScript3 source code

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

package {
    import flash.display.Sprite;
    import flash.text.TextField;

    public class FlashTest extends Sprite {
        private var tf:TextField = new TextField;
        
        public function FlashTest() {
            addChild(tf);
            tf.width = tf.height = 465;
            var ary:Array = new Array(4);
            ary.push("foo");

            tf.appendText("Array length: " + ary.length + "\n");
            tf.appendText("\nfor each test:\n");
            for each(var x:* in ary){
                tf.appendText(x + "\n");
            }
            
            tf.appendText("\nfor..in test:\n");
            for (var i:* in ary){
                tf.appendText("index: " + i + " object: " + ary[i] + "\n");
            }
            
            tf.appendText("\nforEach test:\n");
            ary.forEach(function(item:*, ...rest):void {
                    tf.appendText(item + "\n");
                } );
        }
    }
}