Skip to main content
Inspiring
March 31, 2009
Answered

preloader for xml image gallery

  • March 31, 2009
  • 3 replies
  • 3225 views
Hi,

I am a little stuck as to where to begin; I have created a photo gallery and now need to add some preloader capability to it. The images are brought in via XMLList etc... What I have in mind, I would like to display a preloader untill all the images are ready for viewing - not wanting to preload individual images one by one ;)

I also have a document class within the gallery swf file, I beleive that this may cause conflicts with attaching a preloader to frame 1 - I have tried preloading the gallery swf file via a preloader.swf; the end result still leaves me with having to provide a preloader within the gallery swf.

Can anyone point me to any good examples, for me to get on with it. Any help would be really appreciated folks ;)

Kind Regards,

Boxing Boom
This topic has been closed for replies.
Correct answer kglad

you should load your images sequentially, not simultaneously, or you'll have a mess.  you can then display the approximate load progress fraction as:

x/n + bl/(bt*n)

where you have n total images to be loaded, x of them have completely loaded, one is currently loaded (and is bl/bt loaded).

3 replies

Inspiring
April 6, 2009

Hi,

I have provided a small code on my blog to load multiple files using a array but keep in mind that it is just a code written on frame. If you want some classes you could definitely convert the logic in a Class. You could have a look at it here :- Loading multiple files in Flash using ActionScript 3(AS3)

Please let me know if you need some more help on this.

Thanks & Regards
Ankur Arora
Project Leader(Flash and Flex)
Blog: http://flashdeveloper.blogspot.com

Inspiring
April 6, 2009

Hi Ankur,

Many thanks for your response, I will spend time checking out your code. However, from my initial inspection I am not sure if it's related to XML data?

But I have downloaded your files and will certainly study your techniques Code samples on this site are becoming very rare.

Kind Regards,

Boxing Boom

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
April 5, 2009

you should load your images sequentially, not simultaneously, or you'll have a mess.  you can then display the approximate load progress fraction as:

x/n + bl/(bt*n)

where you have n total images to be loaded, x of them have completely loaded, one is currently loaded (and is bl/bt loaded).

Inspiring
April 6, 2009

Hi Kglad,

Thank you for your response: my images are loading sequentially via the following code segment;

//initialize the loader object
   loader=new Loader();
   //add an onInit event to the contentLoadedInfo
   loader.contentLoaderInfo.addEventListener(Event.INIT, onImageLoaded);
   //create the fake holder
   fakeHolder=new Sprite();
   //and add to it the loader
   fakeHolder.addChild(loader);
   //no need to add it to the stage
   //
   //force the resizeHandler to be called
   resizeHandler(null);
  
   //Load the XML file
   xmlLoader=new URLLoader();
   //assign the Complete loading event
   xmlLoader.addEventListener(Event.COMPLETE,parseXML);
   //load the file
   xmlLoader.load(new URLRequest("data.xml"));
   //initialize the url request
   urlRequest=new URLRequest();
  }

What I would like to do now is preload these,

Would the code to acheive this be:

xmlLoader.addEventListener(ProgressEvent.PROGRESS ,onProgress);

private function onProgress(pe:ProgressEvent):void

{

   // this bit is what I do not understand; i.e. your x/n + bl/(bt*n) fraction example

}

Any further help on this on, would be really appreciated Kglad.

Kind Regards,

Boxing Boom

kglad
Community Expert
Community Expert
April 6, 2009

that's code to load your xml.  unless your xml file is large you don't need a preloader for it.

Inspiring
March 31, 2009
Hi All,

Any one?

Boxing Boom
Inspiring
March 31, 2009
Hi All,

Waiting....

Boxing Boom

Inspiring
April 2, 2009
Hi All,

Hmm... this isn't helping!

Regards,

Boxing Boom