转换AS2 por AS3 ...请

时间:2011-04-05 12:39:49

标签: actionscript-3 actionscript-2

   oranja.onPress = function(){
       this.startDrag(true);
}
oranja.onRelease = function(){
       this.stopDrag();
       if(this.hitTest(this._parent.trash)){
             trace("trash");
             this.unloadMovie();
       } else {
             trace("no trash");
       }
}

1 个答案:

答案 0 :(得分:1)

我认为你正在寻找这个的AS3版本?这样的事情应该有效:

oranja.addEventListener( MouseEvent.MOUSE_DOWN, this._onPress );
oranja.addEventListener( MouseEvent.MOUSE_UP, this._onRelease );

// called when we mouse down on the oranja clip
private function _onPress( e:MouseEvent ):void
{
    oranja.startDrag( true )
}

// called when we mouse up on the oranja clip
private function _onRelease( e:MouseEvent ):void
{
    oranja.stopDrag();
    if( oranja.hitTest( oranja.parent.trash ) )
    {
        trace( "trash" );

        // remove the event listeners
        oranja.removeEventListener( MouseEvent.MOUSE_DOWN, this._onPress );
        oranja.removeEventListener( MouseEvent.MOUSE_UP, this._onRelease );

        // remove the oranja clip
        oranja.parent.removeChild( oranja );
        oranja = null;
    }
    else
        trace( "not trash" );
}

你应该用oranja_onPress()

替换_onRelease()e.target中的e.currentTarget来电