You can use the EventDispatcher. import mx.utils.Delegate; //import the EventDispatcher class import mx.events.EventDispatcher; class myClass {
private var myxml:XML; //declare the functions private var dispatchEvent:Function; public var addEventListener:Function; public var removeEventListener:Function; public function myClass() { //initialize EventDispatcher EventDispatcher.initialize(this); this.myxml = new XML(); this.myxml.ignoreWhite = true; this.myxml.onLoad = Delegate.create(this,DoSomething); this.myxml.load("test.xml"); } private function doSomething(success:Boolean) { trace("success= "+success); //create the object to be dispatched var myObject:Object = new Object(); //add the type myObject.type = "onXMLLoad"; /* * This property isn't mandatory, but it is recommended * to add it to the object. It tells the user what class * dispatched the event. */ myObject.success = success; myObject.target = this; dispatchEvent(myObject); } } And in your .fla: var foo:myClass = new myClass(); foo.addEventListener("onXMLLoad", this); function onXMLLoad(eObj:Object):Void { trace("Success? "+eObj.success); } Ps: It's a good practice to start your classes with a capital letter (MyClass in stead of myClass). Darren Bowers wrote: > Wat is the easiest way to report back success or failure at the time the > class (myClass) is instantiated? > Since doSomething() has taken control of the load handling, I cant pass a > value back via the constructor function of load success. Any help would be > appreciated. > > import mx.utils.Delegate; > > class myClass > { > > private var myxml:XML; > > public function myClass() > { > this.myxml = new XML(); > this.myxml.ignoreWhite = true; > this.myxml.onLoad = Delegate.create(this,DoSomething); > this.myxml.load("test.xml"); > } > > private function doSomething(success:Boolean) > { > trace("success= "+success); > //do something > } > > } > > ------------------------------------------------------------------------ > > ---------------------------------------------------------------------------- > CAUTION & DISCLAIMER: The information contained in this e-mail message > and/or any accompanying data or documents contain information that is > confidential and subject to legal privilege. The information is intended > only for the recipient named in this message. The sender is excluded from > any liability arising from any further use, dissemination, distribution, > transmission or copying of this information and /or accompanying data by > the recipient. If you are not the intended recipient, you must immediately > erase the information along with all copies of this message and accompanying > data and notify the sender. Views expressed in this message are those of the > original sender, and are not necessarily the views of WestOne Services. > ---------------------------------------------------------------------------- > > > ------------------------------------------------------------------------ > > _______________________________________________ > Flashcoders@chattyfig.figleaf.com > To change your subscription options or search the archive: > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > > Brought to you by Fig Leaf Software > Premier Authorized Adobe Consulting and Training > http://www.figleaf.com > http://training.figleaf.com _______________________________________________ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com