Skip navigation
SaneDevil
Currently Being Moderated

Cancel a ProgressEvent from another 'loading window'

Aug 15, 2012 2:17 AM

Tags: #air #as3 #event #actionscript3

Hi

 

I'd like to know how, if possible, how to cancel a ProgressEvent.PROGRESS or how do cancel the 'loading' process in general.

I also want to know how to do it from another class, what happens is I create a 'loading window' with a cancel button so you should be able to cancel if the loading is taking too long for your liking.

 

var msg:msgClass = new msgClass();//*********** Creates a window with message if any errors happen.       

var winLoading:winLoadingClass = new winLoadingClass();//*********** Creates a window with a loading bar and cancel button

winLoading.win()//***********activates loading window

 

 

 

dispatcher.addEventListener(ProgressEvent.PROGRESS, progressHandler);

 

dispatcher.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);

 

dispatcher.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);

 

dispatcher.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);

 

dispatcher.addEventListener(Event.COMPLETE, completeHandler)

 

 

function completeHandler(event:Event){winLoading.winClose()}                                                             

 

 

function progressHandler(event:ProgressEvent):void{if (event.bytesLoaded == event.bytesTotal){winLoading.winClose()}}

 

function securityErrorHandler(event:SecurityErrorEvent):void{msg.win('Security Error');}

 

function httpStatusHandler(event:HTTPStatusEvent):void{if (event.status != 200){msg.win('Connection to server lost');}}

 

function ioErrorHandler(event:IOErrorEvent):void{winLoading.winClose();msg.win ('IO Error');}

 

 

Any help will be much appreciated

 
Replies
  • Currently Being Moderated
    Aug 15, 2012 4:44 AM   in reply to SaneDevil

    The Loader class has a close() method.  Look it up in the help documentation if you need more information.  Also, you could remove the progress listener.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points