home *** CD-ROM | disk | FTP | other *** search
- class com.KidFighting.objects.CEffect extends com.KidFighting.objects.CObject
- {
- var _twn;
- var ani;
- var visX;
- var visY;
- var type;
- var owner;
- var _eff_observer;
- var _ch_observer;
- var onMotionUpdated;
- var onMotionStopped;
- var performing;
- var effStartFrame = -1;
- function CEffect()
- {
- super();
- }
- function get looping()
- {
- return this._twn.looping;
- }
- function set looping(lp)
- {
- this._twn.looping = Boolean(lp);
- }
- function init($ani, twn, ch, x, y)
- {
- this.ani = $ani;
- this._twn = new ds.transitions.Tween(null,"_currentframe",null,1,this.ani._totalframes,this.ani._totalframes);
- this._twn.obj = this.ani;
- this._twn.owner = this;
- this.ani.gotoAndStop(1);
- this.ani._visible = false;
- this.visX = x;
- this.visY = y;
- this.ani.type = this.type;
- this.ani.owner = this;
- this.owner = ch;
- this._eff_observer = ds.transitions.TweenObserver.observeTween(this._twn);
- if(twn != null)
- {
- this._ch_observer = ds.transitions.TweenObserver.observeTween(twn);
- this.onMotionUpdated = this.onCharacterMotionUpdated;
- this.addCharacterListener(this);
- }
- else
- {
- this.start();
- }
- this.onMotionStopped = this.onEffectMotionFinished;
- }
- function onCharacterMotionUpdated(twn)
- {
- if(twn.obj._currentframe >= this.effStartFrame && this.effStartFrame != -1)
- {
- this.removeCharacterListener(this);
- if(this.owner.status != "hurt" && this.owner.status != "cought" && this.owner.status != "thown" && this.owner.HP > 0)
- {
- this.start();
- }
- else
- {
- this.onEffectMotionFinished();
- }
- }
- }
- function onEffectMotionUpdated()
- {
- }
- function onEffectMotionFinished(twn)
- {
- if(this._ch_observer)
- {
- this._ch_observer.unobserve();
- this.removeCharacterListener(this);
- }
- this._eff_observer.unobserve();
- if(this.effStartFrame != -1)
- {
- this.removeEffectListener(this);
- this.ani._visible = false;
- }
- this.performing = false;
- this.ani.owner = null;
- this.destroy();
- }
- function start()
- {
- this.ani._x = this.visX;
- this.ani._y = this.visY;
- this.performing = true;
- this.onMotionUpdated = this.onEffectMotionUpdated;
- this.addEffectListener(this);
- this.ani._visible = true;
- this._twn.start();
- }
- function stop()
- {
- this._twn.stop();
- }
- function addCharacterListener(lsn)
- {
- this._ch_observer.addListener(lsn);
- }
- function removeCharacterListener(lsn)
- {
- this._ch_observer.removeListener(lsn);
- }
- function addEffectListener(lsn)
- {
- this._eff_observer.addListener(lsn);
- }
- function removeEffectListener(lsn)
- {
- this._eff_observer.removeListener(lsn);
- }
- function onPauseGame()
- {
- if(this._twn.isPlaying)
- {
- this._twn.pause();
- }
- }
- function onResumeGame()
- {
- this._twn.resume();
- }
- }
-