Copy link to clipboard
Copied
When I click 2 times on the touch "z" (keycode 90) on my keyboard, my item is removed.
I'd like to change it and when we click 2 times with the mouse the item is removed but I can't figure out how to do it... if mouseDown = true ? it does'nt seem to work...
timer=new Timer(500, 1);
stageRef.addEventListener(KeyboardEvent.KEY_UP, removeDraggedItem);
private function removeDraggedItem(e:KeyboardEvent)
{ if(timer.running==true)
{ if(e.keyCode==90)
{ stageRef.removeEventListener(MouseEvent.MOUSE_MOVE, dragItem);
stageRef.removeEventListener(Event.ENTER_FRAME, itemHitTest);
draggedItem.removeEventListener(MouseEvent.MOUSE_DOWN, itemClick);
stageRef.removeChild(draggedItem); toolbar.useText.text = "";
if (stageRef.contains(this)) stageRef.removeChild(this);
Mouse.show();
Engine.playerControl = true; }
} else if(e.keyCode==90) { timer.start(); }
}
I've tried to change (e.keyCode==90) by (e.buttonDown). No errors but nothings is happening when I double click...any idea why ?
use a double click listener.
Copy link to clipboard
Copied
use a double click listener.
Copy link to clipboard
Copied
import flash.utils.Timer;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.events.KeyboardEvent;
var timer:Timer = new Timer(500,1);
stage.addEventListener(KeyboardEvent.KEY_UP, removeDraggedItem);
stage.addEventListener(MouseEvent.CLICK, removeDraggedItem);
function removeDraggedItem(e:Event)
{
if (timer.running == true)
{
if (e.type == "keyUp")
{
if (KeyboardEvent(e).keyCode == 90)
{
trace("Z was doubleclicked");
}
}
else if (e.type == "click")
{
trace("Mouse was doubleclicked");
}
}
else
{
if (e.type == KeyboardEvent.KEY_UP)
{
if (KeyboardEvent(e).keyCode == 90)
{
timer.start();
}
}
else if (e.type == "click")
{
timer.start();
}
}
}