Solved

onChange Listener on "Number"

Posted on 2006-06-16
2
611 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
3D rotation for a product 3 337
Inserting a pop up image to a scanned PDF 5 435
Array is not working ( AS2 ) 4 146
Flash movie or gif/animation? 3 875
Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
The goal of the tutorial is to teach the user how to how to record live broadcast.
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.

861 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

25 Experts available now in Live!

Get 1:1 Help Now