View Full Version : FPS Controller and MC controller
jagunco
September 6th, 2003, 11:24 AM
Hello to all, does someone have proto to FPS control and to control the direction of playing one MC, back and forward, i tried to go to proto layer, but what they have is not good
thanks
kode
September 6th, 2003, 12:42 PM
// methods
MovieClip.prototype.playCtrl = function(dir, fps) {
this.stop();
this.play = function() {
var frame = this._currentframe+dir;
if (frame<1) {
frame += this._totalframes;
} else if (frame>this._totalframes) {
frame -= this._totalframes;
}
this.gotoAndStop(frame);
updateAfterEvent();
};
this.$interval = setInterval(this, "play", 1000/fps);
};
MovieClip.prototype.stopCtrl = function() {
clearInterval(this.$interval);
this.play = MovieClip.prototype.play;
delete this.$interval;
};
/* usage
one frame forward at 12 fps:
myMovieClip.playCtrl(1, 12);
two frames backward at 24 fps:
myMovieClip.playCtrl(-2, 24);
stop
myMovieClip.stopCtrl();
*/
Voetsjoeba
September 6th, 2003, 12:56 PM
Kode, what is the $ used for ? Is it to avoid the keyword play ? Or is it just a variable name ?
kode
September 6th, 2003, 01:00 PM
Yeah, that's the main reason. :P
Voetsjoeba
September 6th, 2003, 01:03 PM
Argh :P
Which one is it ? :P
kode
September 6th, 2003, 01:08 PM
The first one. :P
Now that I think about it, I should overwrite the play method to stop people from messing up the code, and then restore it in the stopCtrl method.
PS. Am I going crazy or did you edit your post?
Voetsjoeba
September 6th, 2003, 01:08 PM
Both :P
kode
September 6th, 2003, 01:10 PM
...Yep, that's what I thought. :P
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.