Skip to main content
Inspiring
May 24, 2009
Question

Numeric Stepper Component--putting it on a Tween breaks it. Why?

  • May 24, 2009
  • 2 replies
  • 1530 views

This script is straight out of the ActionScript 2.0 docs.  It works as advertised when it is on the root level stage.

But if I put it on a tweened layer (so I can move it onto the screen with some other stuff), it no longer works.

Anybody know why and how to make it work?

/**
Requires:
- NumericStepper component on Stage (instance name: my_nstep)
- Label component on Stage (instance name: my_label)
*/

var my_nstep:mx.controls.NumericStepper;
var my_label:mx.controls.Label;

my_label.text = "value = " + my_nstep.value;

//Create listener object.
var nstepListener:Object = new Object();
nstepListener.change = function(evt_obj:Object) {
my_label.text = "value = " + evt_obj.target.value;
};

//Add listener.
my_nstep.addEventListener("change", nstepListener);

:<)Thanks!

This topic has been closed for replies.

2 replies

McFriscoAuthor
Inspiring
May 24, 2009

Yes, the instances are named at both ends.

Do I need to refer to the instance differently because it's in a tween?

Ned Murphy
Legend
May 24, 2009

It's possible.  I'm not sure what you mean by saying it's ina tween is what I'm thinking you mean.  Can you describe what your main timeline looks like and where the code you show is located?

McFriscoAuthor
Inspiring
May 24, 2009

I drag a numeric stepper component onto the stage.  Also a label component.  Name both the instances.

If I run the movie with the script in the previous post, it works OK at this point.  However,

lets say I want to move the stepper and the label onto the screen with some other screen elements such as a page background.

So, I add a key frame 15 frames in, move my stepper, label  and background to the desired location, and then do "Create Motion Tween" so they move across the screen.  I make sure I have the script and the instances named at both ends of the tween.

When I test the movie, the component no longer works.

This not only breaks the numeric stepper, but list box, check box....I haven't tried any other components, but I'll bet it none of them will work ths way.

Ned Murphy
Legend
May 24, 2009

Do you have instance names assigned at both ends of the tween, and have the code that works for it on the far end where it gets used?