Keyboard for icon carousel event listener

I'm trying to create a "carousel of icon" that slips around the direction given by a keyboard (arrow keys) input.

Here's what I mean;

... < icon 1 > | < icon 2 > | < icon 3 >...

When the user presses the arrow button to the right, the icons will slide to the right.

< icon 3 > | < icon 1 > | < icon 2 >

When the user presses the arrow key to the left, the same thing happens in the opposite direction. The icon in the middle is always the one who is "selected".

Every icon I have on a separate layer, because the motion tween is possible with only one symbol per layer. Under each layer icon I the movement designed to the way I like using interpolation, and it works fine when you just "Press enter"... but I would like the user to be able to control the direction backward with the arrow keys.

The AS3.0 code I have for each layer is as follows:

Stop();

function playMov(event:KeyboardEvent):void

{

if(Event.keycode == Keyboard.Left) play();

}

icon.addEventListener (KeyboardEvent.KEY_DOWN, playMov);

(icon refers to any instance name, I chose for the specific icon / layer)

No, they cannot be exchanged.

You must apply a keylistener to the scene.  That is to say, try:

stage.addEventListener (KeyboardEvent.KEY_DOWN, playMov);

Tags: Adobe Animate

Similar Questions

  • Assignment of a keyboard for a button event?

    Hello

    I'm cord umbilical new flash cs4 (as3) and I want to know how I can make one a keyboard event activates a button to press. Specifically, I do a table of harmony where you click on a button and a sound is played. I want to make sure when you press a key ON the keyboard, so then the sound is played.

    P.S. I would really just a straight answer and possibly a code I could copy and paste.

    I use Flash CS4 with Actionscript 3.0

    Thank you!

    You cannot push a button using code.  You could create the button as a movieclip and make the animate like it is pushed, but the keyboard code would need to trigger the so.

  • Global keyboard event listener?

    Is it possible to create a global keyboard event listener that is unrelated to a window, button, or other user interface element?  The best I could get to add the event to the window listener.  This only works if the window is active.  If the user clicks outside the window and then the receiver for the keyboard does not work.  In addition, when the dialog box appears first of all, it won't work until after the user has made some type of interaction with the window.  I want is to have keyboard shortcuts for users that work regardless of the place where they clicked on the screen, even if the dialogue window is not 'active'.  Is this possible?

    Here is the code I use to the receiver of keyboard for the window.

    mywindow.addEventListener ("keydown", function (k) {keyListen(k)});
    function keyListen(k){if(k.keyName=="Z"){alert("Do stuff here");}}
    

    I don't think that you can create listeners of world events, as for the first appearance of the dialog box, I solved this problem in my script: scripts buliarca BCM_ExtendShortcuts UI by a button activates the event listener to this button. A problem with attach listeners to window, it's in CC2015 events can only be attached to controls and not windows. Setting for windows works in CS6...

  • Strange problem with the keyboard event listener

    I have a full screen touch app. To close the application, I set an event listener on keyboard for the key "0". I don't want the press user due to some restrictions Alt + F4 key combination. Problems begin when the application loses focus. Here's the code;

    protected function onComplete(event:FlexEvent):void
    {

    this.setFocus ();
    this.addEventListener (KeyboardEvent.KEY_DOWN, trapKeys, true, 0, true);

    }

    private void trapKeys(e:KeyboardEvent):void {}

    If (e.keyCode == 96) {}
    This.Close ();
    }

    Else if (e.keyCode == 48) {}
    This.Close ();
    }

    }

    When the user change the screen to a different with Alt + TAB application, or any other combination of keys flex app loses focus and does not work when he turns back to my app "0". How can I solve this problem?

    Thanks in advance.

    Hi, Ahmed.

    I have absolutely no problem with the solution you are trying to set up - you use mode full-screen interactive mode of keyboard?

    Please consider:

    on full add keyboard listener

    protected function applicationCompleteHandler(event:FlexEvent):void

    {

    this.stage.addEventListener (KeyboardEvent.KEY_DOWN, trapKeys);

    };

    //

    protected function applicationActivateHandler(event:AIREvent):void

    {

    If (this.stage)

    {

    switch the State to display full-screen when activated

    If (this.stage.displayState! = StageDisplayState.FULL_SCREEN_INTERACTIVE)

    {

    this.stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;

    };

    };

    };

    //

    private var exitHandled:Boolean = false;

    on NUMBER_0 | NUMPAD_0 exit-close

    protected function trapKeys(event:KeyboardEvent):void

    {

    If ((event.keyCode is Keyboard.NUMBER_0

    || event.keyCode is Keyboard.NUMPAD_0)

    (& this.exitHandled == false)

    {

    exitHandled = true;

    this.stage.removeEventListener (KeyboardEvent.KEY_DOWN, trapKeys);

    This.Close ();

    };

    }

    (Note: applicaton of the events 'applicatonComplete' and "applicationActivate" are routed to over managers)

    Kind regards

    Peter

  • How can I create an event listener for the change of variable shared or similar?

    Hello

    I have a 'big' 6 devices communicating measurement system via the TCP protocol. The system is designed to use REST (the representative State transfer) with JSON (JavaScript object notation).

    Now, I need to add labview program to this environment. I've implemented a solution to 'work' with the help of this forum. Thank you for this! Now, I need to do better (currently no timestamps, large delays, etc.).

    I currently have a web service deployed using http-get as input. My web service .vi is just passing the web entrance to shared variables that are then questioned in real measurement program. Reason is that when I put the measurement program directly to the web service, it does not (something about rights and dependencies). Measurement program includes one third of the owners (Instron) drivers. Also I would not direct access via the network to our mechanical testing device potentially dangerous.

    Now, I want to change the message from the web services .vi commensurate .vi. Currently I have a loop of 10ms to query for changes in the shared variable. Is there a better way to do this? I thought create a listener to the shared variable change events.

    In addition, if you have any ideas (preferably, working code example) how to make the interface between labview and TCP-JSON I would really appreciate it.

    BR,

    Juha

    Currently in LabVIEW, the only way to create an event listener or event NSV is to use the DSC toolkit.  Most of the time the DSC is a very expensive tool that simply encapsulates the functionality that is built into the motor of the PSP and OAS and which is accessible to anyone who can program in LabWindows/CVI.

    http://zone.NI.com/reference/en-XX/help/370051P-01/CVI/libref/cvicnvcreatesubscriber/

    If you want to collaborate, I would like to create a small library of LV that would create a base SV events using a vi LV reminder or possibly passing return user LV event which is how works the DSC toolkit.  I asked OR several times to explain how do this and they're very tight discreet about it.  I guess that they do not want to give users LV less reason to buy the DSC.

  • event listener for when the Panel is open?

    is there an event listener for when a CEP Panel is open.

    I have a persistent Panel the onload works only when the Panel is opened for the first time. I want to keep persistent, but I want to know when the Panel is open again

    Maybe I've misunderstood something, because my English is bad. Unfortunately the listener for events at the opening of the Panel, I also have not found, I had to go through the back door.

  • How to define the event listener AFTER_ACTIVATE for each document

    Well, I want to be able to connect an AFTER_ACTIVATE event listener to any document that is created or opened. Is anyway to do this?

    "update of certain variables"? You mean, like global variables in a persistent script?

    I suggest that you could much better be architecting your script differently.

    Maybe to have a global object that your script consults the active document, instead of using a global variable.

    Or put your data inside the document with. insertLabel().

    Global variables are generally a bad idea. In this case, it seems that you are trying to mimic the local scope by using event handlers, and this sounds a bit scary for me.

  • ActionScript 3 - several variables for event listener.

    OK, I have a question (of course this is the reason why I'm here).  I put emphasis on PHP a lot lately and just had a customer who requires an MP3 play several songs so I had to whip on my rusty actionscript skills.  I have the complete player and it does not work as you wish.  The downside is that there are several pieces.  I use separate functions for each song and separate event listeners.  My main question is there a way to combine these functions into one and just use the event listener to pass another variable to functions?  Here is a sample of one of the code for Song1.  I would like to do so anywhere there is Song1 in the code, I can make a variable so I can put for example (Song2, Song3, Song4, etc..)  In this way, I can have one or two functions to manage all the songs instead of having to copy, paste and then search and replace.

    Thanks for the help!

    // Song 1
    var Song1:Sound = new Sound();
    pbSong1.source = Song1;
    //pbSong1.visible = false;
    var Song1Loaded:Boolean = false;
    
    pbSong1.addEventListener(Event.COMPLETE, Song1LoadComplete);
    btnSong1Play.addEventListener(MouseEvent.CLICK, Song1Play);
    btnSong1Stop.addEventListener(MouseEvent.CLICK, Stop);
    
    function Song1Play(event:MouseEvent) {
         if (Song1Loaded == true) {
              sndchnlMain.stop();
              sndchnlMain = Song1.play();
         } else {
              pbSong1.visible = true;
              Song1.load(new URLRequest("media/music/Song1.mp3"));
         }
    }
    
    function Song1LoadComplete(event:Event) {
         trace("Size of file: " + Song1.bytesTotal);
         Song1.close();
         Song1Loaded = true;
         if(sndchnlMain) {
              sndchnlMain.stop();
         }
         sndchnlMain = Song1.play();
         pbSong1.visible = false;
    }
    

    You can code

    function SongPlay(event:MouseEvent) {var songNum:int = Number(event.currentTarget.name.split(btnSong).join("").split("Play").join(""));      if (SongLoaded) {  // use one booleanSongLoaded=false;           sndchn.stop();  // use one soundchannel
             sndchn = this["Song"+songNum].play();
         } else {
              pbSong1.visible = true;
              this["Song"+songNum].load(new URLRequest("media/music/Song"+soundNum+".mp3"));
         }
    }
    
    
  • Keyboard event listener does not work in the browser

    Is there a reason why a keyboard event listener would not work if the flash is embedded in an HTML element? The rest of my game runs well in the background, but I can't launch the movieClip "nextCar." My code is below, if that makes a difference...

    goNow function (event: KeyboardEvent): void {}
    thisOtherKey = event.keyCode;
    If (thisOtherKey == 32) {}
    nextCar.gotoAndPlay (2);
    parkingQue.play ();
    tent ++;
    }
    }
    stage.addEventListener (KeyboardEvent.KEY_DOWN, goNow);

    This is perhaps a silly question, but have you tried to click on your swf file once it opens in the browser and then try the keyboard controls?

    I don't know any problems that may cause debugging workwhen event listeners, but not in a browser.  So I think that maybe your just not well centered on the swf.

  • Detection and event listener? Is there such a thing?

    I was wondering if I have a Stanley event (mouse, keyboard and enterframe,... event) who goes off, and when he finished his event.

    something that is able to detect the finished event listener and fire on another series event.

    It works more like MOTION_FINISH in TweenEvent, but it is only available for TweenEvent only, what happens if I want to detect a mousclick, keyboard enterframe or even touch event?

    Is there such a thing? Thanks in advance.

    If you have an event listener to catch the occurrence of an event, normally have a function handler for this listener such as additional measures can be implemented.

    If an event is detected, the event listener has finished processing it, as soon as it started.  It intercepts the event occerence and triggers it corresponding to the handler function to take action.  There is no delay in this transformation.

    Events are instantaneous occurrences, they are not something that happens over time.  Even the MOTON_FINISH event occurs as soon as the Tween ends its movement.   If you look to the top of the event class in the help, early documents, you will find a long list of all the event subclasses that are extensions of it.  And each of these subclasses are likely to have a list of constants.  MOTION_FINISH, CLICK, ENTER_FRAME, etc. are all constants, and each of them represents the end of a particular set of treatments.  A CLICK event occurs when a MOUSE_UP event occurring after an event MOUSE_DOWN... each of them happens to an instance of time, not over time.

  • How can I add an event listener

    I tried to add an event listener for this object:

    < mx:Button id = "calculateButton".
    label =""
    toolTip =""
    styleName = "enable".
    Click = "swapToResultsState ()" "
    rollOverEffect = "{glowButton}".
    = Red "-100" horizontalCenter = "0".
    tabIndex = "85" / >

    by using this code:

    calculateButton.addEventListener (KeyboardEvent.KEY_DOWN, swapToResultsState);

    who gave this error:

    Several markers to this line :-1120: access of undefined property calculateButton. -1120: access
    undefined property swapToResultsState.

    What I am doing wrong?

    Keyboard events spread so you do not need to forward.  Just can't do anything if keyCode is 9

  • My keyboard for my Acer aspire switch 10 has completely stopped working

    I use my Acer 10 for about six months and had improved to win 10 just now with no problems.  This morning the keyboard stopped working.  I checked the Tablet contacts, clean them with a brush and a cleaning and not restarted, no chance.  The keyboard when it starts allows me to enter the PIN code and I have a USB mouse attached to the keyboard that works, but none of the keys work when I am connected to Windows. If the screen times out and I try to enter the PIN code again, nothing.   I can navigate around using the mouse, but not have the ability to enter information on keyboard.  I'm stumped and would apprecaite any suggestions welcome.  Acer has been great so far?

    I solved the problem!  It turns out it is 10 Windows that caused the problem.  Filter keys were turned on somehow and they disable the keyboard for users with disabilities. I discovered this on another machine when it happened too, but this time a unrecognized icon appeared in my system tray.  The icon has been for these filter keys and when I turned off their keyboard is back.  How this stupid thing got switched on I don't have a clue.  The original pc with the problem did not show a filter key icon in the system tray, so I was puzzled, did not know they existed.  Something for others to check if this is the case for them.  Thanks for your help.

  • How in fact blackberry event listener

    Hi, m havin a little doubt

    Cvent JDE listener how actually works?

    They keep listening in the background for the event

    OR

    When the event occurs, then the OS itself call all the event listener for this event?

    I think that he shud of same way java event listeners work:

    Follow the link

    http://www.JavaWorld.com/JavaWorld/javaqa/2000-08/01-QA-0804-events.html

  • How to create the scroll to the menu icon click event bar

    How to create the scroll to the menu icon click event bar

    (as the "field of scrolling image")

    In my opinion, it is better for you to try something to help implementation of your solution to ask for the code.

    For example, create a few BitmapFields with icons that act as buttons.  There is source for this sort of thing on the forum if you look at, I think, looking FRO Image button, icon or Bitmap button.

    Once you have these buttons work, add these in a HorizontalFieldManager.

    Good luck.

  • Freedom Pro keyboard for blackBerry Smartphones

    I recently bought a freedom Pro keyboard for my Blackberry Storm 9530 smartphone, which is running v5.0... 0,328 (Platform 4.2.0.128). Using the browser on the Blackberry, I logged onto their site otadrivers and downloaded the driver v5.0 for my phone.

    But when I tried to install the driver, I got a message, I thought just information, indicating that permissions were not required to be set for this application. When it was installed and I clicked on the app, it repeats the message and would not go.

    After trying to run the application several times, I finally gave up and tried to delete the app (thought to try to re - install), the icon has not disappeared. But clicking on it now gave me an error of missing handle (like the operating system thought that the application has been deleted.) I tried to re-boot the phone (by removing the battery while the phone is turned on) but nothing has changed and the app did not work.

    What should I do now? I don't really want to clear the memory if I can help it.

    Thanks for any help.

    Well, I couldn't understand anything else, so I have deleted all my apps "outside" of the security wiper and then re-installed using the keyboard. Worked like a charm! Don't know how to find out which app has been the cause of the problem tho. Maybe I need to know, but...

Maybe you are looking for