Jump to content
Search Community

Controlling child index with xmlloader

palofigueiredo test
Moderator Tag

Recommended Posts

Hi,

 

I'm trying to load in a specific display index order some images with xmlloader, but as they load they keep randomly changing order.

 

The only way I can achiev this is by setting maxConnections to 1, wich works fine but the total loading process becomes to long.

 

Is the xml file order relevant?

 

 

What is the correct way to control indexing of loaded children?

 

The code so far:

 

filelist.xml

 

 

<?xml version="1.0" encoding="UTF-8"?>

<data>

<ImageLoader name="bg" url="bg.jpg" load="true" x="0" y="0" />

<ImageLoader name="logo" url="logo.png" load="true" x="100" y="0" />

<ImageLoader name="aside" url="aside.png" load="true" x="100" y="0"/>

<ImageLoader name="main" url="main.png" load="true" x="0" y="0"/>

</data>

 

images.fla

 

 

//common imports needed for LoaderMax basics

 

import com.greensock.*;

import com.greensock.loading.*;

import com.greensock.events.LoaderEvent;

import com.greensock.loading.display.*;

 

 

import flash.display.Sprite;

import flash.display.MovieClip;

 

 

LoaderMax.activate([imageLoader, SWFLoader]);

 

//make sure none of the progress bars are showing;

totalProgressBar_mc.bar_mc.scaleX = 0;

progressBar_mc.bar_mc.scaleX = 0;

 

 

var queue:XMLLoader = new XMLLoader("filelist.xml",{name:"xmlDoc",

maxConnections:1,

onComplete:queueCompleteHandler,

onProgress:queueProgressHandler,

onChildProgress:imageProgressHandler,

onChildComplete:imageCompleteHandler

});

queue.load();

 

function queueProgressHandler(event:LoaderEvent):void

{

totalProgressBar_mc.bar_mc.scaleX = event.target.progress;

}

 

function queueCompleteHandler(event:LoaderEvent):void

{

trace("evertything loaded");

}

 

function imageProgressHandler(event:LoaderEvent):void

{

progressBar_mc.bar_mc.scaleX = event.target.progress;

}

 

function imageCompleteHandler(event:LoaderEvent):void

{

var loadedImage:ContentDisplay = event.target.content as ContentDisplay;

loadedImage.scaleX = loadedImage.scaleY = .5;

loadedImage.alpha = 0;

 

addChild(loadedImage);

 

TweenLite.to(loadedImage, .5, {alpha:1});

}

 

Thanks

Link to comment
Share on other sites

yes, the ImageLoaders will start to load in the order they are created, but since there are multiple connections/streams, it is a bit of a race. There is no forcing the first asset to finish loading before the third. As you discovered, setting maxConnections to 1 is the solution to force sequential loading.

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