flash on 2010-7-23

by enecre
♥0 | Line 53 | Modified 2010-07-23 12:02:29 | MIT License
play

ActionScript3 source code

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

package {
    import flash.text.TextField;
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
        public function FlashTest() {
            // write as3 code here..
            var tf:TextField = new TextField();
            tf.width = stage.stageWidth;
            tf.height = stage.stageHeight;
            addChild(tf);
            
            var a:A = new A(tf);
            a.F();
            
            var b:B = new B(tf);
            b.F();
            
            var c:A = new B(tf);
            c.F();
            
            var d:A = new B(tf) as A;
            d.F();
        }
        
    }
}
import flash.text.TextField;
class A{
    private var _tf:TextField;
    
    public function A(tf:TextField){
        this._tf = tf;
    }

    public function F():void{
        tr("this is class A.");
    }
    protected function tr(...o:Array):void{
        _tf.appendText(o + "\n");
        _tf.scrollV = _tf.maxScrollV;
    }
}
class B extends A{
    public function B(tf:TextField){
        super(tf);
    }
    override public function F():void{
        tr("this is class B.");
    }

}
class C extends A implements I{
    public function C(tf:TextField){
        super(tf);
    }
    
    public function hoge(moja:int):void{
        tr(moja);
    }

}
interface I{
    function hoge(moja:int):void;
}