-
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....');
}
-
lemon juice hurts your eyes
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!
-
I tried setting mLoader to null by going:
within my unloadStuff function but it did not work.
-
I uploaded my file online and it worked. Turned out that my coding will work online but not in the Flash IDE.
-
lemon juice hurts your eyes
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|