Reputation: 4215
Is a watch list hidden away somewhere in the AS3 debugger in Flash CS4?
Sorry for asking a simple question like this here - I did spend a while looking around the net first. It's much easier to find the watch list in the AS2 debugger.
Thanks, Dan
Upvotes: 1
Views: 795
Reputation: 4059
Whis AS3, there is no more watch list. Adobe Livedoc suggests to use the Proxy pattern with setter and getter.
Here is a class that does the same as the watch object and is easier to use than the proxy:
package
{
import flash.events.Event;
import flash.events.EventDispatcher;
public class Model extends EventDispatcher
{
public static const VALUE_CHANGED:String = 'value_changed';
private var _number:Number = Number;
public function Model():void
{
trace('The model was instantiated.');
}
public function set number(newNb:Number):void
{
_number=newNb;
this.dispatchEvent(new Event(Model.VALUE_CHANGED));
}
public function get number():Number
{
return _number;
}
}
}
The _number
variable and variable type can be replaced by whatever type is needed.
The usage:
var objectToWatch:Model = new Model();
objectToWatch.addEventListener(Model.VALUE_CHANGED, onValuedChanged);
function onValuedChanged(e:Event) {
//do what you need here
}
Upvotes: 1