PDA

View Full Version : Prototype Help



andrthad
January 27th, 2003, 11:16 AM
Hi all,

Working on a flash component and I am having trouble referencing prototype functions. All of this code is in the 1st frame of my component. For example, in the performBuffer prototype I am trying to call the muteSong prototype and the stopBuffer prototype, but I am not having any luck. Any help is appreciated. I can send more of the code if needed.




function JukeBoxClass() {
this.init();
}

JukeBoxClass.prototype = new MovieClip();

JukeBoxClass.prototype.init = function() {
some code
}

JukeBoxClass.prototype.muteSong = function() {
code to mute song
}

JukeBoxClass.prototype.performBuffer = function() {
this.muteSong();
//Check to see if Ten Second Buffer Exists
if(mySong.duration - (10 * 1000) >= mutePosition){
this.stopBuffer();
}

JukeBoxClass.prototype.stopBuffer = function() {
code to stop buffer here
}

JukeBoxClass.prototype.onEnterFrame = function(){
if ((mySong.position == mySong.duration) && (mySong.position > 1000) && (percentLoaded != 100)){
callBuffer = setInterval(this.performBuffer, 100);
}

}

senocular
January 27th, 2003, 01:54 PM
did you initclip and register class?

andrthad
January 27th, 2003, 01:59 PM
Hi Sen,

Thanks for your help. I sure did. At the top I have


#initclip


and then at the bottom I have



Object.registerClass("JukeBox", JukeBoxClass);
#endinitclip

andrthad
January 27th, 2003, 04:29 PM
I guess my main question is just how do you call a prototype function from another prototype function. I always thought it was just this.functionName();. As long as it is in the same class in the same frame of a movieclip. Anybody have some comments.




JukeBoxClass.prototype.muteSong = function() {
this.doStuff();
}

JukeBoxClass.prototype.doStuff = function() {
}

senocular
January 27th, 2003, 07:39 PM
yeah thats pretty much it. I think your problem lies in the setInterval though. If you are applying the interval to an object and one of its methods, use the form
setInterval(object, "method", time)


callBuffer = setInterval(this, "performBuffer", 100);

andrthad
January 28th, 2003, 09:25 AM
Thanks Sen. I will check it out tonight.