A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Stop A Loader From Loading?

  1. #1

    Stop A Loader From Loading?

    I am creating an image gallery where the user can select from several thumbnail images. Once selected, the thumbnails will enlarge and load the full sized image. My problem is that while the user is waiting for the full sized image to load, he may decide to close that image and view another image. I am trying to find a way to stop a loader from loading.

    Here is the code I have used. My problem is that even though the user has clicked on the unloadBtn, the loader continues to load the file. Is there a way to disable that?

    Code:
    import flash.net.URLRequest;
    import flash.display.Loader;
    import flash.events.Event;
    import flash.events.ProgressEvent;
    
    loadBtn.buttonMode = true;
    loadBtn.addEventListener(MouseEvent.CLICK, loadStuff);
    
    unloadBtn.buttonMode = true;
    unloadBtn.addEventListener(MouseEvent.CLICK, unloadStuff);
    
    var mLoader:Loader = new Loader();
    
    function loadStuff(e:MouseEvent){
    	var mRequest:URLRequest = new URLRequest('a.swf');
    	mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
    	mLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler);
    	mLoader.load(mRequest);
    }
    
    function onCompleteHandler(loadEvent:Event){
    	addChild(loadEvent.currentTarget.content);
    	loadEvent.currentTarget.content.x = 0;
    	loadEvent.currentTarget.content.y = 0;
    }
    
    function onProgressHandler(mProgress:ProgressEvent){
    	var percent:Number = mProgress.bytesLoaded/mProgress.bytesTotal;
    	trace('Percent Loaded: ' + percent);
    }
    
    function unloadStuff(e:MouseEvent):void{
    	mLoader.unload();
    	mLoader.close();
    	trace('Unloading....');
    }
    ~~~~~jOn waZ hErE~~~~~

  2. #2
    lemon juice hurts your eyes florianvanthuyn's Avatar
    Join Date
    Jul 2005
    Location
    Merelbeke, Belgium
    Posts
    546
    Try setting mLoader to null and see if that solves your problem
    Florian Vanthuyne

    WAR AGAINST SOLVED THREADS
    mark yours as Resolved under Thread Tools!

  3. #3
    I tried setting mLoader to null by going:

    Code:
    mLoader = null;
    within my unloadStuff function but it did not work.
    ~~~~~jOn waZ hErE~~~~~

  4. #4
    I uploaded my file online and it worked. Turned out that my coding will work online but not in the Flash IDE.
    ~~~~~jOn waZ hErE~~~~~

  5. #5
    lemon juice hurts your eyes florianvanthuyn's Avatar
    Join Date
    Jul 2005
    Location
    Merelbeke, Belgium
    Posts
    546
    yeah, it probably got loaded so fast locally that turning it off was impossible
    Florian Vanthuyne

    WAR AGAINST SOLVED THREADS
    mark yours as Resolved under Thread Tools!

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