Solved

onChange Listener on "Number"

Posted on 2006-06-16
2
608 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
Comment Utility
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
Comment Utility
superb! thnx much!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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 …
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
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.

772 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

15 Experts available now in Live!

Get 1:1 Help Now