|
-
remove eventlisteners
I have images loading from an array. A slideshow. This works fine, but they pile on top of each other. I cannot figure out how to remove them. what's the simplest way to remove them? How do I say - if pic1 is loaded, before loading pic2, remove pic1?
Thanks.
Code:
var aPics:Array=new Array("pic1.jpg","pic2.jpg","pic3.jpg","pic4.jpg","pic5.jpg");
var threeSeconds:Timer=new Timer(3000,aPics.length);
threeSeconds.start();
function slideShow(evt:TimerEvent):void {
var picLoader:Loader = new Loader();
picLoader.load(new URLRequest(aPics[evt.target.currentCount-1]));
picLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
}
function loadComplete(evt:Event):void {
var image:Bitmap=Bitmap(evt.target.content);
image.x=209;
image.y=134;
addChild(image);
}
threeSeconds.addEventListener(TimerEvent.TIMER, slideShow);
-
Declare your loader variable outside the slideshow function so you only have one loader. In slideshow, call picLoader.unload before loading up the next. Also, add the picLoader itself to the stage where you want it rather than adding its content. You shouldn't need a loadComplete at all.
-
half as fun, double the price
Make the image Bitmap persistent; declare it outside of the loadComplete function and immediately add it to the display list. Then in loadComplete simply set its .bitmapData to evt.target.content
-
ok, thank you both, going to try it.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|