Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Actionscript - numericStepper component + KeyUp

Posted on 2006-05-10
Medium Priority
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 = eventObj.target.value;
            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 = eventObj.target.value.doLater();
            //this.a_emp = doLater();
            stepper_val = eventObj.target.value;
            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
  • 2
  • 2

Author Comment

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

Expert Comment

ID: 16650432

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


Author Comment

ID: 16653215
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".


Accepted Solution

Guic earned 1000 total points
ID: 16653309
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
Aneesh Chopra earned 1000 total points
ID: 16673480

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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
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.
Suggested Courses
Course of the Month13 days, 5 hours left to enroll

580 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