How to Stop Loading in As3 & As2
Copy link to clipboard
Copied
In Stage having two buttons btn, btn1 movieClips. when i click btn load a test.swf file . if the swf file size is too heavy i want to stop the loading, with usind btn1 click. How i can stop the loading . Please provide the solution in AS2 & AS3
var ldr:Loader;
btn.addEventListener(MouseEvent.CLICK,statrLoading);
btn2.addEventListener(MouseEvent.CLICK,stopLoading);
function statrLoading(e:MouseEvent) {
loadStrt();
}
function stopLoading(e:MouseEvent) {
ldr.close();
// it is not Working
}
function loadStrt() {
ldr = new Loader();
var url:String = "test.swf";
var urlReq:URLRequest = new URLRequest(url);
ldr.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,Onprogress);
ldr.load(urlReq);
addChildAt(ldr,1);
}
function Onprogress(e:ProgressEvent) {
txt.text=e.bytesLoaded+" of "+e.bytesTotal;
}

Copy link to clipboard
Copied
You can control bytesTotal (LoaderInfo) and then close the Loader ( myLoader.close() ) if it's too heavy...
Copy link to clipboard
Copied
Is Possible in as2. And Iam not understanding in as3 please write syntax.

Copy link to clipboard
Copied
import flash.display.Loader;
import flash.display.Sprite;
import flash.events.*;
import flash.net.URLRequest;
var url:String = "Image.gif";
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressHandler);
var request:URLRequest = new URLRequest(url);
loader.load(request);
addChild(loader);
function progressHandler(event:ProgressEvent):void
{
if (event.bytesTotal > 10000000)
{
loader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, progressHandler);
loader.close();
}
}
Copy link to clipboard
Copied
Thanks for your support . Actually my question is i am able to show the percentage or frames loaded wile downloading the file.But
I need how to stop the file loading process while clicking on another button. If the user donot want to wait complete loading the file, he want to stop the loading.
I have also write the below code. These code just remove the ProgressEvent but not stop the Loading
ldr.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, progressHandler);
ldr.close()

