Jump to content
Search Community

load then bitmap

ggalan test
Moderator Tag

Recommended Posts

hi, i recently saw this tip for loading

LoaderMax.activate([imageLoader]);

var images:Array = ["1.jpg","2.jpg","3.jpg"];

var queue:LoaderMax = LoaderMax.parse(images, {onComplete:completeHandler}, {container:this, width:100, height:100});
queue.load();

function completeHandler(event:LoaderEvent):void {
   trace("all images loaded!");
}

how would i turn those images into a bitmap after they have been loaded?

Link to comment
Share on other sites

When LoaderMax parses those URLs, it will create an ImageLoader for each one (since they're all JPGs). You can get the ImageLoader associated with any URL like this:

 

var loader:ImageLoader = LoaderMax.getLoader("1.jpg");

 

An ImageLoader's "content" refers to a special Sprite (a ContentDisplay) that serves as a container/wrapper for the raw content (in this case a Bitmap). The nice thing about this ContentDisplay object is it is immediately accessible and handles scaling the raw content into an area you define (if necessary). So I'd recommend always using that "content" in your app. But if you need to get the raw content that's inside that ContentDisplay (the Bitmap), you'd use the "rawContent" like this:

 

var loader:ImageLoader = LoaderMax.getLoader("1.jpg");
var bitmap:Bitmap = loader.rawContent;

 

And by the way, you don't need to use the parse() method - that's just a convenience, but if you want finer control over the loaders that are created, simply create them yourself. You could give each one a name that way and define different x/y coordinates, etc. Maybe in a loop like this:

var images:Array = ["1.jpg","2.jpg","3.jpg"];

var queue:LoaderMax = new LoaderMax({onComplete:completeHandler});
for (var i:int = 0; i     queue.append( new ImageLoader(images[i], {name:"image"+i, container:this, width:100, height:100, x:100 * i}) );
}
queue.load();
function completeHandler(event:LoaderEvent):void {
   trace("all images loaded!");
   var image1:Bitmap = LoaderMax.getLoader("image1").rawContent;
}

 

There's lots of info in the ASDocs: http://www.greensock.com/as/docs/tween/_loadermax.html

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