flash on 2014-2-5

by imo_
♥0 | Line 45 | Modified 2014-03-03 18:12:34 | MIT License
play

ActionScript3 source code

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

package {
    import flash.text.TextFormat;
    import flash.utils.getTimer;
    import flash.text.TextField;
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
        private var tf:TextField;
        public function FlashTest() {
            tf = new TextField();
            tf.defaultTextFormat = new TextFormat("Courier New", 16);
            tf.width = 465;
            tf.height = 465;
            addChild(tf);
            asdasd();
        }
        
        private function asdasd():void {
            var x:String = "text1";
            
            // x is referred as String
            // print "text1"
            print(
                x
            );
            try {
                throw new Error("hoge", 404);
            } catch (x:Error) {
                
                // x is referred as String
                // print "text1 text2"
                print(
                    x += " text2"
                );
                
                // first x is referred as String, second x is referred as Error
                // print "Error: hoge text3"
                print(
                    x = x + " text3"
                );
                
                // first x is referred as Error, second x is referred as String
                // print "text4 text5"
                print(
                    x.message = (x = "text4") + " text5"
                );
                
                // x is referred as Error whose message is modified
                // print "Error: text4 text5"
                print(
                    x
                );
            }
            
            // x is referred as String
            // print "text4"
            print(
                x
            );
        }
        
        private function print(text:*):void {
            tf.appendText(text + "\n");
        }


    }
}