PDA

View Full Version : PreLoader Dilemma


rbeau
03-05-2005, 11:07 PM
Hi All,

I have some preloader code in frame 1 of my main movie. When I run the movie it starts to move in slow motion or something like that. It's pretty weird. Can someone see what I am doing wrong? I could really use the help; I'm pretty frustrated at this point.

The following is the code I have:

stop();
var loadedBytes:Number = _root.getBytesLoaded();
var totalBytes:Number = _root.getBytesTotal();
intro_mc._visible = true;

function flashIntro() {
intro_mc._visible = !intro_mc._visible;
if(loadedBytes == totalBytes && totalBytes > 0) {
clearInterval(toggleIntro);
}
}

this.onEnterFrame = function() {
if(!(loadedBytes == totalBytes && totalBytes > 0)) {
toggleIntro = setInterval(flashIntro, 5);
}else {
_root.gotoAndPlay("Intro");
intro_mc._visible = false;
}
}

////////////////////////////////

Thanks

IceCo
03-05-2005, 11:22 PM
You are repeatedly creating the same setInterval in an onEnterFrame:
toggleIntro = setInterval(flashIntro, 5);

So if the frame is played 100 times during the preload, you will have the same 100 intervals running onStage at the same time.

rbeau
03-05-2005, 11:40 PM
I see what you mean. Thanks for the quick reply!

rbeau
03-05-2005, 11:51 PM
Acutally, I just tried the following and get similar results. Any ideas why?

stop();

var loadedBytes:Number = _root.getBytesLoaded();
var totalBytes:Number = _root.getBytesTotal();
intro_mc._visible = true;

this.onEnterFrame = function() {
if(!(loadedBytes == totalBytes && totalBytes > 0)) {
intro_mc._visible = !intro_mc._visible;
}else {
_root.gotoAndPlay("Intro");
intro_mc._visible = false;
}
}

IceCo
03-09-2005, 06:27 PM
Thatz weird... what is this intro_mc? Maybe try:


var loadedBytes:Number = _root.getBytesLoaded();
var totalBytes:Number = _root.getBytesTotal();
intro_mc._visible = false;

this.onEnterFrame = function() {
if(!(loadedBytes == totalBytes && totalBytes > 0)) {
intro_mc._visible = true;
}else {
_root.gotoAndPlay("Intro");
}
}


But I don't think that helps... I can't see the problem based on the above code.