Actionscript - numericStepper component + KeyUp

Posted on 2006-05-10
Last Modified: 2012-06-21

I'm having problems getting the numeric stepper values when I use the keyboard to write the values.
I would like to set the numericstepper value each time I press a number.

I know the arrow keys is a way but I have a wide range of values and don't want to go fom 0 to 99999 using the up arrow key.

this is working:
      var stepper:mx.controls.NumericStepper = this.a_emp;
      var listToStepper:Object = {};
      listToStepper.change = function(eventObj:Object):Void{
            stepper_val =;
            a_emv.value      =      a_val_ini * stepper_val/100;
      stepper.addEventListener("change", listToStepper);

now I need the following too, and it is not working rigth:

      var stepper:mx.controls.NumericStepper = this.a_emp;
      var listToStepper:Object = {};
      listToStepper.keyUp = function(eventObj:Object):Void{
            //stepper_val =;
            //this.a_emp = doLater();
            stepper_val =;
            a_emv.value      =      a_val_ini * stepper_val/100;
            trace("keyUp: " + stepper_val);
      stepper.addEventListener("keyUp", listToStepper);

And the trace output is allways (0) the initial value that is set in the component

Thank you for reading this, and for your help! ;)

Question by:valverde2006

    Author Comment

    Ok, using Enter after write the number, works. It is good but would bee better if it was on KeyUp
    LVL 4

    Expert Comment


    what would you like with the Keyup ? increment your stepper when you have the focus on the stepper, or without the focus ?


    Author Comment

    Hi Guic,

    on keyUp, eg: after pressing the keyboard number 3, I want to set the numericStepper value to 3 without needing to press "Enter".

    LVL 4

    Accepted Solution

    I 'm afraid that is not possible easily.
    Because you need to tell to the application when you have finished to enter your number.

    If you press 2 and after 5 : the question is, do you want the number 2 and after 5 on your Numericstepper or your want 25.

    You can put a setInterval function that will "enter" automatically after 1 second of inactivity.
    So when you will let a intervall of one second between 2 numbers, it will "press Enter" by himself.

    But the users would be surprised !

    LVL 34

    Assisted Solution

    by:Aneesh Chopra

    I assume you numericStepper component instance name is "stepper"

    following code will work for you:
    myKeyListener = new Object();
    myKeyListener.onKeyUp = function() {
          myvalue = String.fromCharCode(Key.getAscii());
          if (myvalue<10) {
                stepper.value = myvalue;


    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
    The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
    The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
    The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now