• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

transform double click on Z to double click on mouse

Contributor ,
Sep 11, 2013 Sep 11, 2013

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 ?

TOPICS
ActionScript

Views

588

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Sep 11, 2013 Sep 11, 2013

use a double click listener.

Votes

Translate

Translate
Community Expert ,
Sep 11, 2013 Sep 11, 2013

Copy link to clipboard

Copied

use a double click listener.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Sep 13, 2013 Sep 13, 2013

Copy link to clipboard

Copied

LATEST

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();

        }

    }

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines