Solved

onChange Listener on "Number"

Posted on 2006-06-16
2
617 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

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 live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
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.

713 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