Skip to main content
Known Participant
March 31, 2007
Question

How can I put a text preloader into this code?

  • March 31, 2007
  • 1 reply
  • 243 views
Hi

I've been working on a site where swf's are loaded into main movie with transitions between the sections. I have the following code on the mcContainer...

onClipEvent (enterFrame) {

if (!loaded && this._url != _root._url) {
if (this.getBytesLoaded() == this.getBytesTotal()) {
loaded = true;
_root.transition.gotoAndPlay("opening");
}
}
}


How can I add a text percentage preloader into this code?

I usually use a the following code for preloaders...
myLoaded = Math.round(getBytesLoaded());

myTotal = Math.round(getBytesTotal());
myPercent = myLoaded/myTotal;
myBar._height = myPercent*97;
myText = Math.round(myPercent*100)+"%";
if (myLoaded == myTotal) {
gotoAndStop("Scene 1", "loaded");
} else {
gotoAndPlay("Scene 1", "preloader");
}


... but I'm not sure where to add the code into the exisiting code, as I'm a beginner at AS.

Any help will be greatly recieved.

Thanks
Wayne


This topic has been closed for replies.

1 reply

Inspiring
April 1, 2007
Set up a dynamic text field, call it "myTextField", embed the font, and add this to your preloader code:

myTextField.text = myText;
Known Participant
April 1, 2007
I have tried added that to my existing code (along with added the text and naming it), but it doesn't seem to work. Did you mean for me to add the second bit of code as well? If possible could you please paste the script how it should be??
Thanks. Wayne
kglad
Community Expert
Community Expert
April 1, 2007
don't use scene information to navigate and don't use the goto functions. label your frames, use those labels for navigation and use the goto methods.

call the preloadF() in a loop passing the target movieclip as the parameter in preloadF():