Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
iTech

Replace Image

Recommended Posts

Is there a way to replace an image that's already loaded where you have the ImageLoader being loaded in a queue and the name of the ImageLoader instance.

 

Can I just use the same ImageLoader instance name?

 

For example:

queue.append( new ImageLoader("img/photo1.jpg", {name:"photo1", container:this, alpha:0, width:250, height:150, scaleMode:"proportionalInside"}) );
queue.append( new ImageLoader("img/photo5.jpg", {name:"photo1", container:this, alpha:0, width:250, height:150, scaleMode:"proportionalInside"}) );

 

photo5 replaces photo1 instead of being placed on top of it.

 

The issue I have is that the images contain transparency and you end up seeing the previously loaded image beneath it. I've never had this problem before because I always used the DisplayObject beneat the image to create a background.

 

Link to comment
Share on other sites

I don't know if I'm exactly following you.

You can use the same ImageLoader to load multiple images, to do that:

someImageLoader.url = "someNewImage.png"
someImageLoader.load(true) // true flushes the existing content

Doe that work for you?

Link to comment
Share on other sites

If it's inside the queue that doesn't work then right?

Link to comment
Share on other sites

It will work fine.

 

 

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


var image:ImageLoader = new ImageLoader("crab.png", {container:this});
var lm:LoaderMax = new LoaderMax();
lm.append(image);
lm.load();


TweenLite.delayedCall(1, changeImage);
//after 1 second change image
function changeImage() {
image.url = "whale.png";
image.load(true);
}
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.
×