Solved

onChange Listener on "Number"

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
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 use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.

829 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