Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Zeke Sikelianos

« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS 

Display FPS in Flash Movie

_root.createEmptyMovieClip("movFrameRate",100); 

_root.movFrameRate.onEnterFrame = function() { 
this.t = getTimer(); 
this.frameRate = Math.round(1000 / (this.t - this.o)); 
//trace(this.frameRate); 
this.o = this.t; 
}

Adjust FPS with Actionscript

// Usage 

// sets _root.yourMC fps to 100 playing forward, but none of the child mcs, that will stop on the last frame 
// _root.yourMC.engineTune(100) 

// sets _root.yourMC fps to 20 playing forward, including the child mcs 
// _root.yourMC.engineTune(20, true) 

// sets _root.yourMC fps to 50 playing backward if the currentframe is greater than 20, without altering the child mcs 
// _root.yourMC.engineTune(50, false, "down", 20)

MovieClip.prototype.engineTune = function(fps, inherit, dir, endF) { 
   var intv, mc, d, end; 
   intv = 1000/fps; 
   d = (dir == "down") ? -1 : 1; 
   if (!endF) end = (dir == "down") ? 1 : this._totalframes;    
   clearInterval(this.tuneUpID); 
   this.tuneUpID = setInterval(fineTune, intv, this, d, this._currentframe, end); 
   if (inherit) { 
      for (var i in this) { 
         if (typeof (this[i]) == "movieclip") { 
            clearInterval(this[i].tuneUpID); 
            this[i].tuneUpID = setInterval(fineTune, intv, this[i], d, this[i]._currentframe, end); 
         } 
      } 
   } 
   function fineTune(mc, d, sf, end) { 
      _if = (sf<end) ? mc._currentframe < end : mc._currentframe > end 
      if (_if) { 
         mc.gotoAndStop(mc._currentframe+d); 
      } else { 
         clearInterval(mc.tuneUpID); 
      } 
   } 
}; 


« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS