/*---------------------------------------------------------------------- * (c) 2001, ATOMGAS Luzifer Altenberg * http://atomgas.de luzifer@atomgas.de * Use this code royalty-free as long as you keep this comments there * * LinearTween Class * to create timebased linear tweens * can tween all _properties and variables * * version 1.0 (8.12.2001) * * do not remove this part! /----------------------------------------------------------------------------------------*/ /* needs the ACK.eventEngine to work * http://chattyfig.figleaf.com/ack/ * * test for ACK! */ if(typeof(Object.ACK.eventEngine) != "function"){ trace("------------------------------------------------"); trace("ERROR: ACK.eventEngine is missing!"); trace("download ACK.eventEngine from: http://chattyfig.figleaf.com/ack/"); trace("------------------------------------------------"); } /*----------------------------------------------------------------------------------------*/ //LinearTween Class function LinearTween(){ if(typeof (Object.ee) != "object") Object.ee = new Object.ACK.eventEngine(); } LinearTween.prototype.toString = function(){ return "[LinearTween object]"; }; LinearTween.prototype.isTweening = function(){ return this.$tweenData != undefined ? 1 : 0; }; LinearTween.prototype.tweenTo = function(targetObj,time,callback,callbackArgs){ if(this.isTweening()) Object.ee.removeEventlistener(this.$tweenData.listenerID); this.$tweenData = {}; this.$tweenData.targetObj = targetObj; this.$tweenData.deltaTime= time; //callback function (is called at endLinearTween) this.$tweenData.callback = callback; this.$tweenData.callbackArgs = callbackArgs; this.$tweenData.startTime = getTimer(); this.$tweenData.startObj = {}; for(var i in targetObj){ this.$tweenData.startObj[i] = this[i]; } this.$tweenData.listenerID = Object.ee.addEventlistener("enterFrame",this,"runLinearTween"); }; LinearTween.prototype.runLinearTween = function(){ var runTime = getTimer()-this.$tweenData.startTime; if(runTime < this.$tweenData.deltaTime){ for(var i in this.$tweenData.targetObj){ this[i] = this.$tweenData.startObj[i]+((this.$tweenData.targetObj[i]-this.$tweenData.startObj[i])/this.$tweenData.deltaTime)*runTime; } }else{ this.endLinearTween(); } }; LinearTween.prototype.endLinearTween = function(){ Object.ee.removeEventlistener(this.$tweenData.listenerID); for(var i in this.$tweenData.targetObj){ this[i] = this.$tweenData.targetObj[i]; } //callback if(typeof(this.$tweenData.callback) == "string"){ eval(this.$tweenData.callback)(this,this.$tweenData.callbackArgs); }else{ this.$tweenData.callback(this,this.$tweenData.callbackArgs); } delete this.$tweenData; }; //end LinearTween Class /*-------------------------------------------------------------------------*/ /* * taken from www.quantumwave.com * * MovieClip inheritance of custom classes * * top-level superclass must link back to MovieClip.prototype */ LinearTween.prototype.__proto__ = MovieClip.prototype; /*-------------------------------------------------------------------------*/ /* * movieclip.setClass(c) * Method to set the movie clip to class c */ MovieClip.prototype.setClass = function(c, args) { this.super = c; this.super(args); delete this.super; this.__proto__ = c.prototype; }; /*-------------------------------------------------------------------------*/ trace(">>>tween.as");