Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to Stop Loading in As3 & As2

Community Beginner ,
Dec 28, 2010 Dec 28, 2010

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;

}

TOPICS
ActionScript
2.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Dec 28, 2010 Dec 28, 2010

You can control bytesTotal (LoaderInfo) and then close the Loader ( myLoader.close() ) if it's too heavy...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 29, 2010 Dec 29, 2010

Is Possible in as2. And  Iam not understanding in as3 please write syntax.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Dec 29, 2010 Dec 29, 2010

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 29, 2010 Dec 29, 2010
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines