开发者

Is there a Watch list in Flash CS4's AS3 debugger?

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


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
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜