A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: remove eventlisteners

  1. #1
    flash chick
    Join Date
    Oct 2007
    Location
    Cali
    Posts
    37

    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);

  2. #2
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    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.

  3. #3
    half as fun, double the price senocular's Avatar
    Join Date
    Feb 2002
    Location
    San Francisco, CA (USA)
    Posts
    4,358
    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

  4. #4
    flash chick
    Join Date
    Oct 2007
    Location
    Cali
    Posts
    37
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center