dcsimg
A Flash Developer Resource Site

Page 2 of 2 FirstFirst 12
Results 21 to 23 of 23

Thread: Loader Event/loading external bitmaps

  1. #21
    ___________________
    Join Date
    May 2004
    Posts
    3,174
    close() will give an error if it's not still grabbing data - at that point, you need unload. i typically use the following when i'm done with a loader:
    PHP Code:
    try {
    loader.close();
    } catch(
    e) { };
    loader.unload(); 
    also note that subsequent calls to load() automatically call unload() first

  2. #22
    Senior Member
    Join Date
    Oct 2009
    Posts
    112
    loader.close() is to close the loaded image

    example:

    use the loader:URLloader function to load the button, perhaps in a button

    Code:
    button.addEventLisener(MouseEvent.CLICK, loadIMAGE);
    function loadIMAGE(e:MouseEvent):void{
       set up vars, url loader      
       (loading url info here);
    }
    
    
    buttonTWO.addEventListener(MouseEvent.CLICK, closeIMAGE);
    function closeIMAGE(e:MouseEvent):void{
          loader.close;
    }
    so when u click the button it loads, when u click the other button, the loaded image dissapears

  3. #23
    ___________________
    Join Date
    May 2004
    Posts
    3,174
    actually, not quite. close() will stop the stream, but not unload it. if it's already completely loaded, close will do nothing and in fact throw an error. unload() is basically just removeChild, and won't stop the data stream.

    if you want to stop a load operation, and are unaware of whether the stream is still active, you'll want to use close() in a try{}, like so:
    PHP Code:
    try {
    loader.close();
    } catch(
    e) {}; 
    that way, if it is still downloading, it'll stop - and if it's done downloading, the error is suppressed. you can call unload() directly after to remove the content object from the loader object (effectively removing it from the display list).

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