|
|
|
Como alterar a velocidade de um movieclip sem alterar a taxa de quadros por segundo (frame rate)?
| |
por João Neto
Eu criei um método para a classe MovieClip que consegue modificar a velocidade do MovieClip independente do frame-rate do filme, mas se o frame-rate for muito baixo o método não será muito eficiente...
seuMC.playFPS( 60 );
// Onde 60 é o frame-rate que vc quer para o seuMC
seuMC.stopFPS();
// Para parar...
ou
seuMC.playFPSRev( 60 );
seuMC.stopFPS();
// Para parar...
// No seu primeiro frame:
var proto = MovieClip.prototype;
proto.playFPS = function( newFPS ){
if ( this.$interval == null ){
this.$nextFrame = function( obj ){
if ( obj._currentframe == obj._totalframes ) obj.gotoAndStop( 1 );
else obj.nextFrame();
updateAfterEvent();
}
this.$interval = 900 / newFPS;
if ( this.$TimeFPS != undefined ) clearInterval( this.$TimeFPS );
this.$TimeFPS = setInterval( this.$nextFrame , this.$interval , this );
this.$nextFrame();
this.stop();
}
}
proto.playFPSRev = function( newFPS ){
if ( this.$interval == null ){
this.$prevFrame = function( obj ){
if ( obj._currentframe == 1 ) obj.gotoAndStop( obj._totalframes );
else obj.prevFrame();
updateAfterEvent();
}
this.$interval = 900 / newFPS;
if ( this.$TimeFPS != undefined ) clearInterval( this.$TimeFPS );
this.$TimeFPS = setInterval( this.$prevFrame , this.$interval , this );
this.$prevFrame();
this.stop();
}
}
proto.stopFPS = function(){
clearInterval( this.$TimeFPS );
delete this.$interval;
if ( this.$nextFrame != null ) delete this.$nextFrame;
if ( this.$prevFrame != null ) delete this.$prevFrame;
}
João Neto
|
|
|
|
|
|
|
|