home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Acao / kung_fu.swf / scripts / __Packages / ds / transitions / TweenObserver.as < prev   
Encoding:
Text File  |  2006-06-13  |  2.1 KB  |  81 lines

  1. class ds.transitions.TweenObserver
  2. {
  3.    var _listeners;
  4.    var observingTween;
  5.    var tweenEnterFrame;
  6.    var nextFrame;
  7.    var _observer;
  8.    var broadcastMessage;
  9.    static var __initBeacon = mx.transitions.OnEnterFrameBeacon.init();
  10.    static var __initBroadcaster = mx.transitions.BroadcasterMX.initialize(ds.transitions.TweenObserver.prototype);
  11.    function TweenObserver()
  12.    {
  13.    }
  14.    static function observeTween(twn)
  15.    {
  16.       var _loc1_ = new ds.transitions.TweenObserver();
  17.       _loc1_.observe(twn);
  18.       return _loc1_;
  19.    }
  20.    static function unobserveTween(twn)
  21.    {
  22.       return Boolean(twn._observer.unobserve());
  23.    }
  24.    function observe(twn)
  25.    {
  26.       if(twn._observer != undefined)
  27.       {
  28.          twn._observer.unobserve();
  29.       }
  30.       this._listeners = [];
  31.       this.observingTween = twn;
  32.       this.observingTween._listeners.unshift(this);
  33.       this.observingTween._observer = this;
  34.       this.tweenEnterFrame = this.observingTween.onEnterFrame;
  35.       this.observingTween.onEnterFrame = function()
  36.       {
  37.          this.nextFrame();
  38.          this._observer.onEnterFrame();
  39.       };
  40.    }
  41.    function unobserve()
  42.    {
  43.       if(this.observingTween._observer == this)
  44.       {
  45.          this.observingTween.removeListener(this);
  46.          this._listeners = [];
  47.          this.observingTween.onEnterFrame = this.tweenEnterFrame;
  48.          return true;
  49.       }
  50.       return false;
  51.    }
  52.    function onEnterFrame()
  53.    {
  54.       this.broadcastMessage("onMotionUpdated",this.observingTween);
  55.    }
  56.    function toString()
  57.    {
  58.       return "[TweenObserver]";
  59.    }
  60.    function onMotionLooped()
  61.    {
  62.       this.broadcastMessage("onMotionLooped",this.observingTween);
  63.    }
  64.    function onMotionYoyo()
  65.    {
  66.       this.broadcastMessage("onMotionYoyo",this.observingTween);
  67.    }
  68.    function onMotionStarted()
  69.    {
  70.       this.broadcastMessage("onMotionStarted",this.observingTween);
  71.    }
  72.    function onMotionFinished()
  73.    {
  74.       this.broadcastMessage("onMotionFinished",this.observingTween);
  75.    }
  76.    function onMotionStopped()
  77.    {
  78.       this.broadcastMessage("onMotionStopped",this.observingTween);
  79.    }
  80. }
  81.