views:

129

answers:

1

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

A: 

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
}
o15a3d4l11s2
Thanks o15a3d4l11s2. That's interesting and will be useful if I really need to get stuck into an object to debug it.It would be nice if Adobe could add a watch list back in again, for more casual scenarios, and perhaps also add the ability to mouse over properties and fields in the debugger to see their values.
danyal