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

Everything is Object in ActionScript

Get Adobe Flash player
by jozefchutka 09 Feb 2011
    Embed
/**
 * Copyright jozefchutka ( http://wonderfl.net/user/jozefchutka )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/fR8o
 */

package {
    import flash.display.Sprite;
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;
    import flash.text.TextField;
    
    public class FlashTest extends Sprite {
        public function FlashTest() {
            stage.scaleMode = StageScaleMode.NO_SCALE;
            stage.align = StageAlign.TOP_LEFT;
            
            var tf:TextField = new TextField();
            tf.width = stage.stageWidth;
            tf.height = stage.stageHeight;
            tf.text = "";
            tf.wordWrap = true;
            tf.multiline = true;
            addChild(tf);
            
            // anything is Object
            tf.appendText([] is Object ? "Array is Object\n" : "Array is not Object\n");
            tf.appendText(tf is Object ? "TextField is Object\n" : "TextField is not Object\n");
            tf.appendText(this is Object ? "Sprite is Object\n" : "Sprite is not Object\n");
            tf.appendText(int(1) is Object ? "int is Object\n" : "int is not Object\n");
            tf.appendText(Number(1) is Object ? "Number is Object\n" : "Number is not Object\n");
            tf.appendText("string" is Object ? "String is Object\n" : "String is not Object\n");
            tf.appendText(<xml /> is Object ? "XML is Object\n" : "XML is not Object\n");
            tf.appendText(false is Object ? "Boolean is Object\n" : "Boolean is not Object\n");
            tf.appendText(Number.NaN is Object ? "NaN is Object\n" : "NaN is not Object\n");
            tf.appendText(/./i is Object ? "RegExp is Object\n" : "RegExp is not Object\n");
            tf.appendText(trace is Object ? "Function is Object\n" : "Function is not Object\n");
            tf.appendText(Class is Object ? "Class is Object\n" : "Class is not Object\n");
            tf.appendText(new <int>[] is Object ? "Vector is Object\n" : "Vector is not Object\n");
            
            // ... but null!
            tf.appendText(null is Object ? "null is Object\n" : "null is not Object!!!\n");
        }
    }
}