(AS3) Assign movieclips keyboard keys

Hello everyone!

Currently I am working on an interactive surface, but I am stuck at a point.
Here's the code so far:

stage.displayState = StageDisplayState.FULL_SCREEN;

MCA. Stop();

mca.addEventListener (MouseEvent.MOUSE_DOWN, adown);

mca.addEventListener (MouseEvent.MOUSE_UP, PUA);

mca.addEventListener (KeyboardEvent.KEY_DOWN, adown2);

mca.addEventListener (KeyboardEvent.KEY_UP, aup2);

mca.buttonMode = true;

mca.mouseChildren = false;

function adown(e:MouseEvent):void

{

var mc:MovieClip = MovieClip (e.currentTarget);

mc.removeEventListener (Event.ENTER_FRAME, rewind);

MC. Play();

mc.addEventListener (Event.ENTER_FRAME, advance);

}

function aup(e:MouseEvent):void

{

var mc:MovieClip = MovieClip (e.currentTarget);

mc.removeEventListener (Event.ENTER_FRAME, advance);

mc.prevFrame ();

mc.addEventListener (Event.ENTER_FRAME, rewind);

}

function advance(e:Event):void

{

var mc:MovieClip = MovieClip (e.currentTarget);

If (mc.currentFrame is mc.totalFrames)

{

MC. Stop();

mc.removeEventListener (Event.ENTER_FRAME, advance);

}

}

function rewind(e:Event):void

{

var mc:MovieClip = MovieClip (e.currentTarget);

If (mc.currentFrame == 1)

{

MC. Stop();

mc.removeEventListener (Event.ENTER_FRAME, rewind);

}

on the other

{

mc.prevFrame ();

}

}

var movieArray:Array = new Array;

movieArray.push (mca);

movieArray.push (mcb);

movieArray.push (mcc);

movieArray.push (mcd);

movieArray.push (CCM);

movieArray.push (mcf);

movieArray.push (CWM);

movieArray.push (mch);

movieArray.push (mci);

movieArray.push (CJD);

movieArray.push (mck);

movieArray.push (mcl);

for (var i: uint = 0; i < movieArray.length; i ++)

{

movieArray [i] .stop ();

movieArray [i] .addEventListener (MouseEvent.MOUSE_DOWN, adown);

movieArray [i] .addEventListener (MouseEvent.MOUSE_UP, PUA);

movieArray [i] .buttonMode = true;

movieArray [i] .mouseChildren = false;

}

What I want is to assign a key specific to a movieclip. For example: when I press the "d" key on my keyboard, I want "mca" to do the same thing that when I press the left button mouse on "mca", then release.

I hope someone can help me!

Thanks in advance!

PS: If something is not clear, I can download the .fla file

Configure a listener to button to the stage and in the case where the handler function have used logic to take action based on what key has been pressed.

stage.addEventListener (KeyboardEvent.KEY_DOWN, processKey);

function processKey(event:KeyboardEvent):void {}

trace (Event.keycode);  Use this line to determine keycodes that you specify

Switch (Event.keycode)
{
box 68: processMCA(). call a function that treats the mca

break;
 
case... etc for other keys

}
}

Tags: Adobe Animate

Similar Questions

  • Satellite U300-152: keyboard keys are mixed up

    I have a newly purchased U300-152 with OS vista home premium 32-bit already installed by the distributor in Saudi Arabia.
    I observe some of the keys on the keyboard are mixed to the top for example shift + 2 should give us @ and shift +' (apostrophe) should give us "(quote), but the reverse is Maj sense + 2 gives me" (quote) and shift +' (apostrophe) gives me @

    Any solution for that to be corrected.
    What should I do?

    Thanks in advance.

    Hey Buddy

    Don t worry, it s not a serious problem ;)
    It seems that you keyboard language settings don't match the keyboard layout.

    You can solve this problem very easily by changing the language settings in the control panel-> Regional Options control & language-> language-> details tab

    I guess that you keyboard language settings are set to English * (UK) * '. '.
    But maybe you should choose an English * (US) * to assign the right signals to the single keyboard keys.

    Check it out ;)

    Welcome them

  • How to assign a keyboard macro to a keyboard shortcut

    Does anyone know how to assign a keyboard macro to a keyboard shortcut?  I'm spoiled CodeWright by, if there is no selected item only when a 'Ctrl c' is issued, CodeWright automatically copy the line that the cursor is located. I'm trying to replicate this feature and the only way I can see it's a macro of the "copy line" keyboard right click on command.  Any thoughts?

    NABI:

    Looks like you're talking about modifying the source code.  I don't know a way to create your own keyboard macro.  You can change the shortcut key assignments (CVI 9.1: Options-> change the shortcut keys), but it seems that you need more than that.

    To make your example (a line no copying), I often have to press Ctrl-O, to cut the current line, immediately followed by a Ctrl-V to restore the original line.  This line is still in the buffer zone of the Clipboard, so I can go where I want the copy of the original line and press Ctrl + V.

    In the event that you do not change the code but create shortcuts for your users in your application, you can catch the EVENT_KEYPRESS in your panel or command callback callback and check for key code combinations.  See the multikey.prj example program comes with CVI and the CVI for EVENT_KEYPRESS help.

  • Record an action and assign a shortcut key F1 (Photoshop CC 2015)

    I want to record a very simple action and assign a shortcut key F1.

    I record the action and choose F1, but it does not work.

    The action works if I play but not if I press the F1 key.

    It going to be fixed?

    I use the CC 2015 (trial!) version and it is not a good sign when I think to buy it.

    Its been a while I have used a Mac, but I'm pretty sure that the BONE protects the function keys. To override the F1 on a Mac, you must hold down the "fn" key and press F1, which I think then behaves like a normal F1 press. Try to start your action by pressing fn - F1.

    It might easier to choose a shortcut different keyboard for your action.

    Terri

  • Assign input (keyboard) to a button

    Hey!
    I have a button called "Enter" and I always need to click on it to use it. Is it possible to assign my keyboard "enter" button?

    Hello

    You can use an evenlistener to check when the Enter key is press...

    stage.addEventListener (KeyboardEvent.KEY_DOWN, enterKeyHandler);

    function enterKeyHandler(event:KeyboardEvent):void {}

    If (event.keyCode == Keyboard.ENTER) {}

    code to run on entry press

    }

    }

    See you soon,.

    Mark

  • After the upgrade to El Capitan 10.11.5 shift, Alt and command of my keyboard keys started to act arbitrarily, they are suspended and are not working properly.

    After the upgrade to El Capitan 10.11.5 shift, Alt and command of my keyboard keys started to act arbitrarily, they are suspended and do not work properly (I already tried several keyboards and is not Firefox or Chrome). This behavior is exacerbated in Illustrator CC, but also affect all programs and even my office. It drives me crazy, does anyone know how I can fix this problem?

    Mi IMac is a 27-inch, late 2013, 3.4 GHz Intel Core i5, and use a Wacom Intuos Pro.

    Could possibly be interfering with the entry Wacom drivers.

    Start safe mode and see if there are still have the problem there. Safe mode is slow and some things do not work, but it prevents some third-party boot loading software. If your keyboard works properly in Mode without fail, this would imply that some third-party software is causing the problem. If so, check the updates.

    It also takes more time to start because the BONE is clean some system caches that can also help.

    Try safe mode if your Mac does not end commissioning - Apple Support

  • I have a MacBook Pro.  Is there a way to implement a rarely used keyboard key that - WHENEVER - it is pressed the computer will insert the string, predetermined character at the cursor position?

    I have a MacBook Pro.  Is there a way to implement a rarely used keyboard key that - WHENEVER - it is pressed the computer will insert the string, predetermined character at the cursor position?

    Yes. You can add in system preferences > keyboard > text.

  • How to assign a macro key to type the email address?

    How can I assign a macro key to type my email address?
    A lot of sites that use under the user name email address required. 24 characters is a lot of typing.
    My OS is Windows 7 Home Premium.

    Try the extension of cuts:

  • How can I assign an F key to type a string of chatracters

    I have to enter the same string of characters often in information boxes. Is it possible to assign a single key to type this string?

    Try instead the extension of cuts:

  • Some keyboard keys do not work on my Satellite L300D

    Hello

    I have the Satellite L300D-242, keyboard key 6-7-R-H-B left and right arrow not working not not on Win 7 32 Bit OS. his job very well if I try the keyboard external usb.
    My question is if I buy the new keyboard problem will be fix or it's something to do with the motherboard?

    Thank you

    Hello

    If everything is ok with the external keyboard, it seems that a few keys on the internal keyboard are faulty. I agree with Timox and swap the keyboard internal which is very cheap and can be done in 10 minutes.

    Do you know where you can order spare parts?
    You can do this if you contact an authorized service provider. You can find a list of the guys here:
    http://EU.computers.Toshiba-Europe.com > support & downloads > find an authorized service provider

  • problem with the 3/square icon on my iMac keyboard key.

    I have a problem with the 3/square icon on my iMac keyboard key. The icon of Fund will not work, I just get # when I use the up and down arrow to the left of the keyboard. A lot of ideas, everyone please?

    I just see the same question and the answer is the book symbol is alt + 3, I have a US keyboard. I wonder why that is? I bought my iMac to John lewis to the United Kingdom. Anyone have the answer for me please?

  • Re: Tilda and Windows Vista (Satellite L40 - 17R) keyboard key

    Hello...

    I have a problem with my laptop Satellite L40 - 17R. I've updated from Windows XP to Vista Business. Almost everything works fine, but I noticed that the Tilda key (~) does not work! the key does nothing.

    I changed the keyboard layout to a lot of other layouts, but no solution.

    Did anyone have any suggestions? !!!

    Hello

    Tilda key (~) is placed as a third symbol - additional symbol on specific keyboard key?

  • How to program my favorites on my Microsoft Laser 5000 keyboard keys?

    How to program my favorites on my Microsoft Laser 5000 keyboard keys?

    Have you had a look at the product guide?

    http://www.Microsoft.com/hardware/en-us/p/wireless-comfort-desktop-5000#support

    All the information you are looking for should be guide on the product. If you can program your favorite keys, product guide should show you how.

  • Keyboard key issues

    I have a laptop (DV6206us) and recently started having some keyboard key issues. For example G, H, BACKSPACE, scroll keys and some other don't type/work in a hurry. The keyboard itself has had a cover transparent latex that I installed the keys because I bought it to protect from spills, dust, etc... After taking a closer look, I noticed that if I press a certain area/s around the keyboard keys are working. But as soon as I release the pressure of the particular region the keys stop working.

    This is an easy fix? Something I can do myself? If this is not the case, what would be the approximate cost for the repair or replacement of the keyboard?

    I suspect that my son (15mos) is at fault. I have a few times caught using my laptop as a step back bag, while the laptop was in the bag. The backpack offers a padding on all sides. But I think that the pressure of him standing / use it as a step caused the keyboard key issues.

    The problem has been resolved with just open up the laptop and fixing the connector loose keyboard cable I found.

  • Why is-strike (shift-") on my keyboard (@) key? When the other my keyboard is (update 2). __

    Why is-strike (shift-") on my keyboard (@) key? When the other my keyboard is (update 2).

    Hi acesdie,

    Probably to do with the language of the keyboard. Shift + 2 is the American keyboard. Go to control panel and click the language and region. In the window of the region and language, click the keyboard and languages and then click on the button "change keyboards. What language is in the box 'default language'? If it's in the United Kingdom and you are not in the United Kingdom, then click the Add button and select English (United States). Click the plus (+) next to the English (United States) option and then click on the plus sign (+) next to the option "keyboard". Here you will see a list of the types of keyboards, i.e. the United States Dvorak, Dvorak to the United States for the left hand, etc. If you have a keyboard to type Dvorak, then select one of them; If this isn't the case, then I suggest to choose the United States (international) or simply WE. Then click on the arrow to the right of the box in the section "default input language" and select English (United States), and then click apply then OK.

    This forum post is my own opinion and does not necessarily reflect the opinion or the opinion of Microsoft, its employees or other MVPS.

    John Barnett MVP: Windows XP Expert associated with: Windows Desktop Experience: Web:http://www.winuser.co.uk;  Web:http://xphelpandsupport.mvps.org;  Web:http://vistasupport.mvps.org;  Web:http://www.silversurfer-guide.com

Maybe you are looking for

  • Problem of security in Croatia

    I bought the Toshiba Satellite A665-145 in Zagreb 20.06.2011 and for two days now I am recording my laptop for the standard warranty as well as for extended I can't do nothing about it. I get the message that I am already registered but I don't have

  • C870D - 10-X satellite keyboard problem, when you press the AltGr key

    When I press a key ONCE everything in now ALT GR for a @ for example, two @ appears. Like that @. I pressed ONCE only. What is going on? It's the same with any key I press: @££ $$ {[]}--------. Yes everyone, except:-(slash) Thank you.

  • 5.6.1 pages how to insert a file name

    In previous versions of Pages I could insert the file name or the full path of a document in the foot. I create multiple documents for our society. This has been invaluable when changes had to be made to a document or form. I can't find this option i

  • video problem

    I can't see some videos. the funny thing is that I could see them yesterday on the same web page, butI had audio, the screen appears in green. I updated the computer yesterday and it worked, but still the same problem

  • My regional language and currency are the bot like UK, but I always get just a dollar sign. How can I change this?

    I have an Acer aspire one laptop, running XP. I tried to change the locale and language such as recommended by others, but it is already set to British English and the currency is already set to books - despite this, I still get a dollar sign.