Jump to content
Search Community

nothing showing until all are loaded

chefkeifer test
Moderator Tag

Recommended Posts

I am wondering if the first image is not showing until all the images are loaded. It really takes a long time for you to see the first image. There are 19 images in the xml file and i want that first image to show while the rest are loading. How do i achieve this.

http://

www.atvrednecknationals.com is the site and you will see in the top a blank white screen and then after about 20 seconds the slideshow starts with the first image.

 

 

here is the code

 

import com.greensock.loading.*;
import com.greensock.events.*;
import com.greensock.*;
import flash.display.Sprite;

LoaderMax.activate([imageLoader]);  

var loader:XMLLoader = new XMLLoader("../xml/headerPics.xml", {onComplete:completeHandler, estimatedBytes:50000}); 
loader.load();

function completeHandler(event:LoaderEvent):void {     
var imageSeconds:Number = 2;
var transitionSeconds:Number = 1;

  var xmlQueues:LoaderMax = LoaderMax.getLoader("xmlQueues");
  var images:Array = xmlQueues.content;
  TweenMax.allTo(images, 0, {autoAlpha:0, x:-450});

  addChild(images[0]);


  TweenMax.to(images[0], transitionSeconds, {autoAlpha:1});

  var sequence:TimelineMax = new TimelineMax({delay:transitionSeconds, repeat:-1});

  for (var i:int = 1; i < images.length; i++) {
       addChild(images[i]);
	sequence.append( new TweenMax(images[i], transitionSeconds, {autoAlpha:1}), imageSeconds);

	sequence.append( new TweenMax(images[i - 1], 0.01, {autoAlpha:0}) );
  }

  sequence.append( new TweenMax(images[0], 0.01, {autoAlpha:1}), imageSeconds);
  sequence.append( new TweenMax(images[images.length - 1], transitionSeconds, {autoAlpha:0}) );
} 

Link to comment
Share on other sites

Yep, the way you coded this, you've got ALL of the images loading before the XMLLoader can dispatch its COMPLETE event. That's because you set load="true" in the node that contains all the images in your XML. LoaderMax/XMLLoader is doing exactly what you asked, but it should be easy to change. Just remove the load="true" on the node and put it instead on the first image like this:

 























 

That way, when XMLLoader dispatches its COMPLETE event, only the first image will have loaded. Then don't forget to start the queue loading in the background as soon as the XMLLoader completes. Like this:

 

function completeHandler(event:LoaderEvent):void { 
   ...
  var xmlQueues:LoaderMax = LoaderMax.getLoader("xmlQueues");
  xmlQueues.load();
  ...
}

 

And don't worry about the fact that the first image has already loaded when you call xmlQueues.load() - LoaderMax is smart enough to notice that and not waste time attempting to load the first image again. It'll skip right over it.

 

Make sense?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...