Jump to content
Search Community

Regarding the demo

nitinmukesh test
Moderator Tag

Recommended Posts

Hi,

 

I was going through the demo code.

 

package demos {
import com.greensock.*;
import com.greensock.easing.*;
import com.greensock.events.LoaderEvent;
import com.greensock.loading.*;

import flash.display.MovieClip;

public class LoaderMax_subload_child extends MovieClip {
	private var _queue:LoaderMax;

	public function LoaderMax_subload_child():void {
		//create an array of image file names
		var urls:Array = ["agencynet.jpg",
						  "buick.jpg",
						  "cocacola.jpg",
						  "cu3er.jpg",
						  "diva.jpg",
						  "dow.jpg",
						  "waterlife.jpg",
						  "happyplanetshots.jpg",
						  "holdencruze.jpg",
						  "ironman.jpg",
						  "mercedes.jpg",
						  "micromaniac.jpg",
						  "overtheatlantic.jpg",
						  "saab.jpg",
						  "silverpistol.jpg",
						  "soft-se.jpg",
						  "target.jpg",
						  "tonydorio.jpg",
						  "prius.jpg"];

		//create the LoaderMax queue into which we'll put the ImageLoaders
		_queue = new LoaderMax({name:"childQueue", requireWithRoot:this.root, maxConnections:1, onChildComplete:_childCompleteHandler});

		//loop through the file names, create an ImageLoader and place it on the stage using special properties like x, y, width, height, etc. The images will also be scaled to fit within the width/height defined.
		for (var i:int = 0; i < urls.length; i++) {
			_queue.append( new ImageLoader(urls[i], {container:this, 
													 x:(i % 5) * 100, 
													 y:int(i / 5) * 64, 
													 width:100, 
													 height:64, 
													 bgColor:0xCCCCCC}) );
		}

		//append a VideoLoader that will continuously loop
		_queue.append( new VideoLoader("video.flv", {container:this, autoPlay:true, repeat:-1, x:400, y:192, width:100, height:64, bgColor:0xCCCCCC}) );

		//prepend all of the urls in the LoaderMax instance with "assets/mid_size"
		_queue.prependURLs("assets/mid_size/");

		//start loading
		_queue.load();
	}

//---- EVENT HANDLERS ----------------------------------------------------------------

	private function _childCompleteHandler(event:LoaderEvent):void {
		trace("loaded " + event.target);
	}

}

}

 

Is it possible to display the images one by one after the loading is complete (_childCompleteHandler) and determine the width/height before adding the element to stage?

Link to comment
Share on other sites

Is it possible to display the images one by one after the loading is complete (_childCompleteHandler) and determine the width/height before adding the element to stage?

Sure. Just don't define a container or width or height (I assume you want to determine with native width/height) in the ImageLoaders, and then do this in the _childCompleteHandler:

 

private function _childCompleteHandler(event:LoaderEvent):void {
   var width:Number = event.target.content.width;
   var height:Number = event.target.content.height;
   addChild(event.target.content);
}

 

Does that answer your question?

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