salve ho creato un applicazione con un canvas nel quale ho messo questi due riferimenti:
mouseDown="handleStartDrag(event);" mouseUp="handleStopDrag(event);"
che quindi richiamano due funzioni che non fanno altro che far partire il drag e farlo finire.
le funzioni sono queste:
private function handleStartDrag(event:MouseEvent):void {
event.preventDefault();
var target : UIComponent = UIComponent(event.currentTarget);
target.startDrag(false);
}
private function handleStopDrag(event:MouseEvent):void {
event.preventDefault();
var target : UIComponent = UIComponent(event.currentTarget);
target.stopDrag();
}
funzionano bene, l'unica cosa che mi chiedo, è perchè una volta rilasciato il mouse l'oggetto trascinato ritorna al punto iniziale, è possibile che rimanga nel punto rilasciato (x e y)?
ho provato impostando la seconda funzione così:
private function handleStopDrag(event:MouseEvent):void {
event.preventDefault();
var target : UIComponent = UIComponent(event.currentTarget);
var newx:Number, newy:Number;
newx = target.x;
newy = target.y;
target.stopDrag();
target.y = newy;
target.x = newx;
}
ma non va comunque.....
![]()
![]()
ciauz
Francesco