How can I add a text preloader to this code?

  • papalazarou78
  • Newbie
  • Newbie
  • papalazarou78
  • Posts: 8

Post 3+ Months Ago

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...

Code:
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 can normally add a preloader to movies, but can't seem to put any of it into the existing code without errors or effecting the loading of swf's

Please help me...

Thanks
Wayne
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

obviously ... you don't think outside the box :P
Code: [ Select ]
onClipEvent (enterFrame) {if (!loaded && this._url != _root._url) {
bL = this.getBytesLoaded() ;bT = this.getBytesTotal();
if (bT > 10) // always do this because sometimes bT and bL can be zero
{nPercent = Math.round(bL*100/bT);this.dtext.text = nPercent + " %";
if (bL == bT) {loaded = true;_root.transition.gotoAndPlay("opening");}
}}}
  1. onClipEvent (enterFrame) {if (!loaded && this._url != _root._url) {
  2. bL = this.getBytesLoaded() ;bT = this.getBytesTotal();
  3. if (bT > 10) // always do this because sometimes bT and bL can be zero
  4. {nPercent = Math.round(bL*100/bT);this.dtext.text = nPercent + " %";
  5. if (bL == bT) {loaded = true;_root.transition.gotoAndPlay("opening");}
  6. }}}

where dtext should be the instance of a dynamic text which exists in mcContainer. If you want to place dtext somewhere else, then just refer to it's path (either absolute or relative).
Oh, btw, do you see how nice is the syntax i just wrote? it is so compact ... no space consuming. I hope you enjoy it just as much as i enjoy the java syntax :P
  • papalazarou78
  • Newbie
  • Newbie
  • papalazarou78
  • Posts: 8

Post 3+ Months Ago

Thanks for the reply. I will try this when I get home tonight, and let you know how I get on.
  • papalazarou78
  • Newbie
  • Newbie
  • papalazarou78
  • Posts: 8

Post 3+ Months Ago

I've replaced my code with yours (along with creating a dymanic text field). But it doesn't seem to work? I have named it dtext in the instance name, and when that didn't work, I tried it in var... but still didn't work... am I missing something? I have tried putting the dtext in differnt places too (being sure to match the path in the code). If it helps I could upload my files for you to view?

Thanks
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

sure, give it a try
  • papalazarou78
  • Newbie
  • Newbie
  • papalazarou78
  • Posts: 8

Post 3+ Months Ago

http://www.fullfatdesigns.co.uk/FFD_files.zip

The code you gave me is found in Transition (on MOVS layer) on f22. Its tricky to select the movie, so I normally have to lock and hide all layers above contents.

Thanks for looking.
  • rockafromhell
  • Student
  • Student
  • rockafromhell
  • Posts: 70
  • Loc: Erie,Pa

Post 3+ Months Ago

here go to this site http://www.flashvillage.com download a template their all free they have preloaders and stuff which is all done perfect read the actionscript and stuff figure it out
  • DaLeo
  • Born
  • Born
  • DaLeo
  • Posts: 2
  • Loc: Sri Lanka

Post 3+ Months Ago

If I have not mistaken you have created a pre-loader without any display. simply add a dynamic text box inside your preloader clip. give it a name in the properties inspector (You could also create a dynamic textfield through script)

onClipEvent (enterFrame) {

if (!loaded && this._url != _root._url) {

if (this.getBytesLoaded() == this.getBytesTotal()) {

loaded = true;
_root.transition.gotoAndPlay("opening");

}else{
// assuming that the name of the textfield is "lodAmnt" and it's
// auto size property is set to ture
lodAmnt.text = (getBytesLoaded()*100/getBytesTotal()) + "%";
// you may use a variable to store the value and use math.round()
// to round off the value can use ceil or floor too
}
}
}

Post Information

  • Total Posts in this topic: 8 posts
  • Users browsing this forum: No registered users and 12 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.