Skip navigation
Currently Being Moderated

Help with code

Aug 9, 2012 7:57 AM

I am addaptnig some code I got from the Internet. It does what I want, but I need some help to fullly understand how it works. Here it is.

// My main application file:

.....

<logging:GlobalExceptionHandler preventDefault="true" >

                              <logging:LogHandlerAction/>

</logging:GlobalExceptionHandler>

 

 

package

{

    import flash.display.LoaderInfo;

    import flash.events.UncaughtErrorEvent;

   

    import mx.managers.ISystemManager;

 

 

    [Mixin]

    [DefaultProperty("handlerActions")]

    public class GlobalExceptionHandler

    {

        private static var loaderInfo:LoaderInfo;

 

 

        public var handlerActions:Array;

 

 

        public var preventDefault:Boolean = false;

 

 

        public static function init(sm:ISystemManager):void

        {

            loaderInfo = sm.loaderInfo;

        }

 

 

        public function GlobalExceptionHandler()

        {

            loaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UN CAUGHT_ERROR,

                                                            uncaughtErrorHandler);

        }

 

 

        private function uncaughtErrorHandler(event:UncaughtErrorEvent):void

        {

                              for each (var action:GlobalExceptionHandlerAction in handlerActions)

            {

                action.handle(event.error);

            }

 

 

            if (preventDefault == true)

            {

                event.preventDefault();

            }

        }

    }

}

 

package

{

 

    public interface GlobalExceptionHandlerAction

    {

        function handle(error:Object):void;

    }

}

 

package stoneriver.util.logging

{

          import stoneriver.util.logging.ErrorLogger;

    public class LogHandlerAction implements GlobalExceptionHandlerAction

    {

                    private var _log:ErrorLogger =  ErrorLogger.getInstance();

        public function handle(error:Object):void

        {

            if (error is Error)

            {

                                        var errorObj:Error = error as Error;

                                        // This will start logging errors

                                        _log.error(errorObj);

            }

        }

    }

}

 

 

Basically my question is:

How does handlerActions array get its elements?

 

Thanks

 
Replies

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