flash on 2013-3-8

by nkheart4
♥0 | Line 48 | Modified 2013-03-08 18:20:41 | MIT License
play

ActionScript3 source code

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

package {
    import flash.text.TextField;
    import flash.events.Event;
    import flash.display.Sprite;
    public class Main extends Sprite {
        private var txt:TextField;
        
        public function Main() {
            txt = new TextField();
            addChild(txt);
            txt.width = txt.height = 500;
            
            var b:B = new B();
            addChild( b );
            b.x = 150;
            b.y = 150;
            
            var c:C = new C();
            b.addChild(c);
            
            b.name = "MC_b";
            c.name = "MC_c";
            
            b.addEventListener( Event.COMPLETE , evt );
            
        }
        
        private function evt(e:Event):void{
            txt.appendText("event run \n");
            txt.appendText("target = "+e.target.name+" \n");
            txt.appendText("currentTarget= "+e.currentTarget.name+"\n");
        }

    }
}
import flash.events.Event;


import flash.display.Sprite;
import flash.events.MouseEvent;

class B extends Sprite{
  public function B(){
      this.graphics.beginFill(0xFF0000);
      this.graphics.drawCircle(0,0,100);
  }
}


class C extends Sprite{
    public function C(){
        this.graphics.beginFill(0xFFCC00);
        this.graphics.drawCircle(0,0,50);
        this.addEventListener(MouseEvent.CLICK , onClick ); 
    }
    private function onClick( e:MouseEvent ):void{
        this.scaleX -= 0.1;
        this.scaleY -= 0.1;
        this.dispatchEvent(new Event( Event.COMPLETE , true ));
    }

}