Cuando cargamos una pelicula externa dentro de una pelicula principal, la velocidad de fotogramas de la pelicula cargada se adapta a la velocidad de la pelicula principal, y esto nos dará problemas de sincronización si estamos importando pelicuals a diferentes velocidades.
Supongamos que tenemos esta animación:
Código :
class FrameRate extends MovieClip {
function FrameRate(clip, fps) {
clip.stop();
if (clip.__fpsInt__ != undefined) {
clearInterval(clip.__fpsInt__);
delete clip.__fpsInt__;
}
clip.__nextFrame__ = function(ptr) {
if (ptr._currentframe < ptr._totalframes) {
ptr.nextFrame();
} else {
ptr.gotoAndStop(1);
}
updateAfterEvent();
};
clip.__fpsInt__ = setInterval(clip.__nextFrame__, Math.round(1000 / fps), clip);
}
}
Código :
var carga:MovieClipLoader = new MovieClipLoader();
carga.loadClip("ani1.swf", contenedor1);
carga.loadClip("ani2.swf", contenedor2);
ani1 = new FrameRate(contenedor1, 12);
Código :
MovieClip.prototype.frameRate = function(fps) {
this.stop();
if (this.__fpsInt__ != undefined) {
clearInterval(this.__fpsInt__);
delete this.__fpsInt__;
}
this.__nextFrame__ = function(ptr) {
if (ptr._currentframe<ptr._totalframes) {
ptr.nextFrame();
} else {
ptr.gotoAndStop(1);
}
updateAfterEvent();
};
this.__fpsInt__ = setInterval(this.__nextFrame__, Math.round(1000/fps), this);
};
Código :
#include "frameRate.as"
var carga:MovieClipLoader = new MovieClipLoader();
carga.loadClip("ani1.swf", contenedor1);
carga.loadClip("ani2.swf", contenedor2);
contenedor1.frameRate(12);
Código :
//this.__fpsInt__ = setInterval(this.__nextFrame__, Math.round(1000/fps), this); this.__fpsInt__ = setInterval(this.__nextFrame__, 1000/fps, this);//Así mejor
Código :
MovieClip.prototype.frameRate = function(fps) {
this.stop();
if (this.__fpsrevInt__ != undefined) {
clearInterval(this.__fpsrevInt__);
delete this.__fpsrevInt__;
}
this.__prevFrame__ = function() {
if (this._currentframe != 1) {
this.prevFrame();
} else {
this.reverseComplete();
this.gotoAndStop(this._totalframes);
}
updateAfterEvent();
};
this.__fpsrevInt__ = setInterval(this.__nextFrame__, 1000/fps, this);
};
zah :
Código :
MovieClip.prototype.rewindAnimation = function(fps) {
this.stop();
if (this.__fpsrevInt__ != undefined) {
clearInterval(this.__fpsrevInt__);
delete this.__fpsrevInt__;
}
this.__prevFrame__ = function(ptr) {
if (ptr._currentframe != 1) {
ptr.prevFrame();
} else {
ptr.reverseComplete();
ptr.gotoAndStop(ptr._totalframes);
}
updateAfterEvent();
};
this.__fpsrevInt__ = setInterval(this.__prevFrame__, 1000/fps, this);
};
Código :
MovieClip.prototype.rewindAnimation = function(fps) {
this.stop();
if (this.__fpsrevInt__ != undefined) {
clearInterval(this.__fpsrevInt__);
delete this.__fpsrevInt__;
}
this.__prevFrame__ = function(ptr) {
if (ptr._currentframe != 1) {
ptr.prevFrame();
} else {
clearInterval(ptr.__fpsrevInt__);
delete ptr.__fpsrevInt__;
}
updateAfterEvent();
};
this.__fpsrevInt__ = setInterval(this.__prevFrame__, 1000/fps, this);
};