actionscript-book-CustomErrors-com-example-programmingas3-errors-ApplicationError.ax [swf] flex
package { public class @ax-actionscript-book-CustomErrors-com-example-programmingas3-errors-ApplicationError extends Error { internal static const WARNING:int = 0; internal static const FATAL:int = 1; public var id:int; public var severity:int; private static var messages:XML; public function @ax-actionscript-book-CustomErrors-com-example-programmingas3-errors-ApplicationError() { messages = <errors> <error code="9000"><![CDATA[Employee must be assigned to a cost center.]]></error> <error code="9001"><![CDATA[Employee must be assigned to only one cost center.]]></error> <error code="9002"><![CDATA[Employee must have one and only one SSN.]]></error> <error code="9999"><![CDATA[The application has been stopped.]]></error> </errors>; } public function getMessageText(id:int):String { var message:XMLList = messages.error.(applet.class == id); return message[0].text(); } public function getTitle():String { return "Error #" + id; } public function toString():String { return "[APPLICATION ERROR #" + id + "] " + message; } } }
(C) Æliens 27/08/2009
You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.