home *** CD-ROM | disk | FTP | other *** search
- class GDK.Base extends MovieClip
- {
- var worlds;
- var useMask;
- var onResize;
- var mcMask;
- var engineIntervalID;
- var lastUpdate;
- var onStart;
- var onPause;
- var onResume;
- var onStop;
- var activeWorld;
- var onUpdate;
- var paused = false;
- var width = 100;
- var height = 100;
- var version = "GDK 1,1,10,0";
- function Base()
- {
- super();
- this.worlds = new GDK.Collection();
- if(this.useMask)
- {
- this.setMask(this.attachMovie("Square","mcMask",13421568));
- }
- this.setSize(Math.round(this._xscale),Math.round(this._yscale));
- this._yscale = this._xscale = 100;
- for(var _loc3_ in this)
- {
- if(_loc3_.indexOf("mcDead") != -1)
- {
- this[_loc3_].swapDepths(1048575);
- this[_loc3_].removeMovieClip();
- }
- }
- }
- function setSize(w, h, noEvent)
- {
- if(w == this.width && h == this.height)
- {
- return undefined;
- }
- if(noEvent)
- {
- this.width = w;
- this.height = h;
- }
- else
- {
- this.onResize(this.width = w,this.height = h,this.width,this.height);
- }
- if(this.useMask)
- {
- this.mcMask._xscale = w;
- this.mcMask._yscale = h;
- }
- }
- function start()
- {
- if(this.engineIntervalID)
- {
- return undefined;
- }
- this.lastUpdate = getTimer();
- this.engineIntervalID = setInterval(this,"update",0);
- this.onStart();
- this.update();
- }
- function pause()
- {
- this.paused = true;
- this.onPause();
- this.update();
- }
- function resume()
- {
- this.paused = false;
- this.onResume();
- this.update();
- }
- function stop()
- {
- this.onStop();
- clearInterval(this.engineIntervalID);
- delete this.engineIntervalID;
- }
- function update()
- {
- var _loc2_ = undefined;
- if(this.paused)
- {
- this.lastUpdate = getTimer();
- return undefined;
- }
- this.activeWorld.update(_loc2_ = (this.lastUpdate - (this.lastUpdate = getTimer())) * -0.001);
- this.onUpdate(_loc2_);
- }
- function addWorld(worldObj)
- {
- if(!this.worlds.addMember(worldObj))
- {
- return undefined;
- }
- worldObj.displayNode = this;
- worldObj.engine = this;
- }
- function removeWorld(worldObj)
- {
- if(!this.worlds[worldObj])
- {
- return undefined;
- }
- var _loc2_ = this.worlds.length;
- while((_loc2_ = _loc2_ - 1) > -1)
- {
- if(this.worlds[_loc2_] == worldObj)
- {
- this.worlds.splice(_loc2_,1);
- }
- }
- delete this.worlds[worldObj];
- worldObj.removeFromScene();
- }
- function setActiveWorld(worldObj)
- {
- if(this.activeWorld == worldObj)
- {
- return undefined;
- }
- this.activeWorld.removeFromScene();
- this.activeWorld = worldObj;
- worldObj.addToScene();
- }
- function onUnload()
- {
- this.stop();
- this.setActiveWorld(null);
- }
- }
-