Skip to main content
Inspiring
August 17, 2013
Question

Help with a preloader in AS3

  • August 17, 2013
  • 1 reply
  • 3091 views

Hi,

I upload a website and I have problems with the preloader did it in AS3. It starts after two or three minutes. I have a MC with an animation of 100 frames and the dynamic text of the percent. The preloader is located in the 1 frame to the 10, I mean, first frame with the actions and the other three layers (text, MC and background) with a lenght of 10. The movie has 525 frames. Here is the code:

stop();

addEventListener(Event.ENTER_FRAME, lodeando);

function lodeando(event:Event):void

{

          var bytesTotales = stage.loaderInfo.bytesTotal;

          var bytesCargados = stage.loaderInfo.bytesLoaded;

          var porcentaje = Math.round(bytesCargados * 100 / bytesTotales);

          textoPorcentaje.text = porcentaje + "% Cargados";

          cargaAnimada_mc.gotoAndStop(porcentaje);

          if (bytesCargados == bytesTotales)

          {

                    removeEventListener(Event.ENTER_FRAME, lodeando);

                    gotoAndPlay(2);

                    textoPorcentaje.text = "";

                    removeChild(textoPorcentaje);

                    removeChild(cargaAnimada_mc);

          }

}

Please, Could you help me?.

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
August 17, 2013

your preloader will start to display AFTER all embedded fonts are loaded and AFTER all items exported for use with actionscript are loaded unless you take specific steps to prevent those objects from loading in frame 1.  ie, you must mark classes to export in a frame other than 1 (file>publish settings>swf>advanced as settings) and you must untick those library items you do not want to export in frame 1.

Inspiring
August 17, 2013

Thanks kglad, Please, Could you explain it more detailed?, I do not understand at all. Sorry. I go to file>publish settings> but there are not a swf>advanced as settings. In the settings are only the formats and flash tabs. I use a CS4 version. I change the frame 1 in export document class to 10 and the preloader takes a lot of time and it produces the following errors:

ReferenceError: Error #1065: No se ha definido la variable sprite3_4.

ReferenceError: Error #1065: No se ha definido la variable sprite2_5.

ReferenceError: Error #1065: No se ha definido la variable sprite3_4.

ReferenceError: Error #1065: No se ha definido la variable sprite2_5.

How can I untick those library items that I do not want to export in frame 1?.

kglad
Community Expert
Community Expert
August 18, 2013

you have to fix those errors, first.

click file>publish settings>swf and tick "permit debugging".  retest.

the problematic line numbers that contain those undefined variables will be in the new error messages.