Skip to main content
Participant
March 17, 2010
Question

Preloader idiot

  • March 17, 2010
  • 1 reply
  • 217 views

Hey,

I am terrible at Actionscript. I shouldn't use it, but because I built my enitre site in Flash I need to use it. I need to create a preloader that when it's done loading,  the loading bar dissapears and a Enter button appears.It's loading the entire site, and I'm using 2.0.


stop();
onEnterFrame = function(){
     if (_root.getBytesLoaded() == _root.getBytesTotal()){
          delete onEnterFrame;
          gotoAndStop(2);
     }
}

That is what I'm using to load my enitre site. It works, but of course there is no loading bar and I have no idea how to attach one. Further more you can tell it jumps to frame two when what I really want is for it to bring up an Enter button so the viewer can choose when to enter and go to frame 2.

Hope this all makes sense. Thanks for the help.

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
March 17, 2010

create an enter button, place it on-stage and give it an instance name (say enterBtn).  you'll disable its visible property until loading is complete and your preloader is removed so, take that into account.

for your loading bar, create a movieclip that contains a rectangle stroke with a fill.  convert the fill to a movieclip (with registration point along its left edge) and assign an instance name (say fillMC).

you can then place your loading bar on-stage and give it an instance name (say loadbarMC).  you can then use:

enterBtn._visible=false;
enterBtn.onRelease=function(){
this._visible=false;
gotoAndStop(2);
}
loadbarMC.fillMC._width=0;

stop();
onEnterFrame = function(){
loadbarMC.fillMC._width = _root.getBytesLoaded()*loadbarMC._width/_root.getBytesTotal();
     if (_root.getBytesLoaded() == _root.getBytesTotal()){
          delete onEnterFrame;
loadbarMC.swapDepths(getNextHighestDepth());
loadbarMC.removeMovieClip();
enterBtn._visible=true;
     }
}