Конвертировать AS2 в AS3 ... пожалуйста - PullRequest
0 голосов
/ 05 апреля 2011
   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 Ответ

1 голос
/ 05 апреля 2011

Я думаю, что вы ищете эту версию для 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

...