module tool { author suo
     export class InteractiveObject { protected _root : egret . DisplayObject ; protected _mouseDownHandler : Handler = null ; protected _mouseUpHandler : Handler = null ; protected _mouseOutsideHandler : Handler = null ; protected _mouseDownAndMoveHandler : Handler = null ; protected _mouseClickHandler : Handler = null ; protected _touchCancleHandler : Handler = null ; public constructor ( root ) { if ( root == null ) { console . assert ( false , "请检查传入参数是否为egret.DisplayObject!" ) ; } this . _root = root ; this . _root . addEventListener ( egret . TouchEvent . TOUCH_BEGIN , this . onMouseDown , this ) ; this . _root . addEventListener ( egret . TouchEvent . TOUCH_END , this . onMouseUp , this ) ; this . _root . addEventListener ( egret . TouchEvent . TOUCH_RELEASE_OUTSIDE , this . onMouseOustide , this ) ; this . _root . addEventListener ( egret . TouchEvent . TOUCH_MOVE , this . onMouseDownAndMove , this ) ; this . _root . addEventListener ( egret . TouchEvent . TOUCH_TAP , this . onMouseClick , this ) ; this . _root . addEventListener ( egret . TouchEvent . TOUCH_CANCEL , this . onTouchCancle , this ) ; } protected onMouseDown ( e , data = null ) { if ( this . _mouseDownHandler != null ) { this . _mouseDownHandler . runWith ( e ) ; } } protected onMouseUp ( e ) { if ( this . _mouseUpHandler != null ) { this . _mouseUpHandler . runWith ( e ) ; } } /**
         * 取消触摸
         */ protected onTouchCancle ( e ) { if ( this . _touchCancleHandler ) { this . _touchCancleHandler . runWith ( e ) ; } } protected onMouseOustide ( e ) { if ( this . _mouseOutsideHandler != null ) { this . _mouseOutsideHandler . runWith ( e ) ; } } protected onMouseDownAndMove ( e ) { if ( this . _mouseDownAndMoveHandler != null ) { this . _mouseDownAndMoveHandler . runWith ( e ) ; } } protected onMouseClick ( e ) { if ( this . _mouseClickHandler != null ) { this . _mouseClickHandler . runWith ( e ) ; } } public dispose ( ) { this . _root . removeEventListener ( egret . TouchEvent . TOUCH_BEGIN , this . onMouseDown , this ) ; this . _root . removeEventListener ( egret . TouchEvent . TOUCH_END , this . onMouseUp , this ) ; this . _root . removeEventListener ( egret . TouchEvent . TOUCH_RELEASE_OUTSIDE , this . onMouseOustide , this ) ; this . _root . removeEventListener ( egret . TouchEvent . TOUCH_MOVE , this . onMouseDownAndMove , this ) ; this . _root . removeEventListener ( egret . TouchEvent . TOUCH_TAP , this . onMouseClick , this ) ; this . _root . removeEventListener ( egret . TouchEvent . TOUCH_CANCEL , this . onTouchCancle , this ) ; if ( this . _mouseDownHandler != null ) { this . _mouseDownHandler . recover ( ) ; this . _mouseDownHandler = null ; } if ( this . _mouseUpHandler ) { this . _mouseUpHandler . recover ( ) ; this . _mouseUpHandler = null ; } if ( this . _mouseOutsideHandler ) { this . _mouseOutsideHandler . recover ( ) ; this . _mouseOutsideHandler = null ; } if ( this . _mouseDownAndMoveHandler ) { this . _mouseDownAndMoveHandler . recover ( ) ; this . _mouseDownAndMoveHandler = null ; } if ( this . _touchCancleHandler ) { this . _touchCancleHandler . recover ( ) ; this . _touchCancleHandler = null ; } if ( this . _root instanceof egret . MovieClip ) { this . _root . stop ( ) ; } this . _root = null ; } public set mouseDownHandler ( value ) { this . _mouseDownHandler = value ; } public set mouseUpHandler ( value ) { this . _mouseUpHandler = value ; } public set mouseOutsideHandler ( value ) { this . _mouseOutsideHandler = value ; } public set mouseDownAndMoveHandler ( value ) { this . _mouseDownAndMoveHandler = value ; } public set mouseClickHandler ( value ) { this . _mouseClickHandler = value ; } public set touchCancleHandler ( value ) { this . _touchCancleHandler = value ; } public get root ( ) : egret . DisplayObject { return this . _root ; } /**
         * 设置是否可见
         */ public set visible ( value ) { this . _root . visible = value ; } /**
         * 获得x坐标
         */ public get x ( ) : number { return this . _root . x ; } /**
         * 设置x坐标
         */ public set x ( value ) { this . _root . x = value ; } /**
         * 获得y坐标
         */ public get y ( ) : number { return this . _root . y ; } /**
         * 设置y坐标
         */ public set y ( value ) { this . _root . y = value ; } /**
         * 获得宽
         */ public get width ( ) : number { return this . _root . width ; } /**
         * 获得高
         */ public get height ( ) : number { return this . _root . height ; } } }