Solved

onChange Listener on "Number"

Posted on 2006-06-16
2
613 Views
Last Modified: 2006-11-18
Is it possible to create a listener on Number object and monitor the number onChange? Something like

var listener:Object = new Object();
listener.onChange = function():Void {
    trace("number changed");
}

var myNumber:Number = new Number();
myNumber.addListener(listener);

myNumber = 5; // this will fire the on change event and trace "number changed"
--------------------------------------------------------------
0
Comment
Question by:Ameristar
2 Comments
 
LVL 34

Accepted Solution

by:
Aneesh Chopra earned 250 total points
ID: 16926254
Hi,

AddListener can only work for existing events

you have to use "watch" to achieve this..

here is the working sample code, open a new FLA and paste the following on first frame
-------------
var myNumber:Number = new Number();
//
valuedChanged = function (prop, oldVal, newVal)
{
      trace("number changed");
      trace("new Value is :"+newVal);
      return newVal;
};
//
this.watch("myNumber", valuedChanged);
//
myNumber = 10;
----------------

Rgds
Aneesh
0
 

Author Comment

by:Ameristar
ID: 16936250
superb! thnx much!
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from 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

Suggested Solutions

I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
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 how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

776 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