this参照テスト

by tepe
♥0 | Line 32 | Modified 2011-02-27 09:54:50 | MIT License
play

ActionScript3 source code

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

package {
    import flash.display.*;
    import flash.text.*;
    public class FlashTest extends Sprite {
        private var txt:TextField = new TextField();
        public function FlashTest() {
            // write as3 code here..
            addChild(txt);
            txt.width = 200;
            txt.text = String(this);
            //testFunc();
            var tc:TestClass = new TestClass();
            txt.appendText("\n"+tc.str);
            
            tc = new TestClass();
            txt.appendText("\n"+tc.str);
            
 

        }
        
        private function testFunc():void{
            txt.appendText(" \n"+String(this));
        }
        
        private function hoge(obj:Object):void{
            for(var str:String in obj){
                txt.appendText(" \n"+str);
            }

        }


    }
    

}

import flash.display.*;
import flash.text.*;

class TestClass extends Sprite {
    public var str:String;
    
    public function TestClass():void{
        str = String(this);
    }

}