Jump to content
Search Community

AS3 Determinging Stacking Order of Assets

dada78 test
Moderator Tag

Recommended Posts

Hi guys,

I am new to AS3 and am trying to figure out how I can determine which asset should be loading on top or below the current asset.

 

I would prefer to just have 2 physical mcs on the stage that I could load the assets into and layer them based on my preference.

 

Currently I have the following code and all I would like to do is make the container the assets are being loaded into a real movieclip on the timeline rather than a dynamically created one. How would I change the code in order to accomplish this?

 

Goal: To have img2.jpg loaded below img0.png

 

Thanks!

import com.greensock.*;
import com.greensock.loading.*;
import com.greensock.events.LoaderEvent;
import com.greensock.loading.display.*;

//create a LoaderMax named "mainQueue" and set up onProgress, onComplete and onError listeners
var queue:LoaderMax = new LoaderMax({name:"mainQueue",onProgress:progressHandler,onComplete:completeHandler,onError:errorHandler});


//append several loaders
queue.append( new ImageLoader("imgs/img1.jpg", {name:"photo1", estimatedBytes:22000, container:this, alpha:1, x:0, y:109}) );
queue.append( new ImageLoader("imgs/img0.png", {name:"img0", estimatedBytes:36000, container:this, alpha:1, x:55, y:114}) );
queue.append( new ImageLoader("imgs/img2.jpg", {name:"photo2", estimatedBytes:22000, container:this, alpha:0, x:500, y:109}));


//start loading
queue.load();

function progressHandler(event:LoaderEvent):void
{
	trace("progress: " + event.target.progress);
}

function completeHandler(event:LoaderEvent):void{
	var image2:ContentDisplay = LoaderMax.getContent("photo2");
	TweenLite.to(image2, .5, {alpha:1, x:0, delay:3});
	trace(event.target + " is complete!");
}

Link to comment
Share on other sites

Place any movie clips you want on the stage anywhere you want in any layer and give them any unique instance names, let's say clip1 and clip2

 

Then you just use your instance names as your container properties in the ImageLoaders

 

queue.append( new ImageLoader("imgs/img1.jpg", {name:"photo1", estimatedBytes:22000, container:clip1, alpha:1, x:0, y:109}) );
queue.append( new ImageLoader("imgs/img2.jpg", {name:"photo2", estimatedBytes:22000, container:clip2, alpha:0, x:500, y:109}));
  • Like 1
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...