| 1397 | | |
|---|
| 1398 | | import flash.events.Event; |
|---|
| 1399 | | import flash.events.IEventDispatcher; |
|---|
| 1400 | | |
|---|
| 1401 | | class ErrorHandler |
|---|
| 1402 | | { |
|---|
| 1403 | | public function ErrorHandler(handler:Function, reset:Boolean, autoTermination:Boolean) |
|---|
| 1404 | | { |
|---|
| 1405 | | this.handler = handler; |
|---|
| 1406 | | this.reset = reset; |
|---|
| 1407 | | this.autoTermination = autoTermination; |
|---|
| 1408 | | } |
|---|
| 1409 | | |
|---|
| 1410 | | public var handler:Function; |
|---|
| 1411 | | public var reset:Boolean; |
|---|
| 1412 | | public var autoTermination:Boolean; |
|---|
| 1413 | | } |
|---|
| 1414 | | |
|---|
| 1415 | | class EventHandler |
|---|
| 1416 | | { |
|---|
| 1417 | | public function EventHandler(dispatcher:IEventDispatcher, type:String, listener:Function, func:Function, useCapture:Boolean, priority:int, useWeakReference:Boolean) |
|---|
| 1418 | | { |
|---|
| 1419 | | this.dispatcher = dispatcher; |
|---|
| 1420 | | this.type = type; |
|---|
| 1421 | | this.listener = listener; |
|---|
| 1422 | | this.func = func; |
|---|
| 1423 | | this.useCapture = useCapture; |
|---|
| 1424 | | this.priority = priority; |
|---|
| 1425 | | this.useWeakReference = useWeakReference; |
|---|
| 1426 | | } |
|---|
| 1427 | | |
|---|
| 1428 | | public var dispatcher:IEventDispatcher; |
|---|
| 1429 | | public var type:String; |
|---|
| 1430 | | public var listener:Function; |
|---|
| 1431 | | public var func:Function; |
|---|
| 1432 | | public var useCapture:Boolean; |
|---|
| 1433 | | public var priority:int; |
|---|
| 1434 | | public var useWeakReference:Boolean; |
|---|
| 1435 | | |
|---|
| 1436 | | public function register():void |
|---|
| 1437 | | { |
|---|
| 1438 | | dispatcher.addEventListener(type, handler, useCapture, priority, useWeakReference); |
|---|
| 1439 | | } |
|---|
| 1440 | | |
|---|
| 1441 | | public function unregister():void |
|---|
| 1442 | | { |
|---|
| 1443 | | dispatcher.removeEventListener(type, handler, useCapture); |
|---|
| 1444 | | } |
|---|
| 1445 | | |
|---|
| 1446 | | private function handler(e:Event):void |
|---|
| 1447 | | { |
|---|
| 1448 | | listener(e, this); |
|---|
| 1449 | | } |
|---|
| 1450 | | } |
|---|