Oh and the last part, dispatching the event: from BaseMain.as:
dispatchEvent( { type:SOMETHING_COMPLETE } ); hth, On 2/16/07, John Grden <[EMAIL PROTECTED]> wrote:
I'm not sure if you're asking for this level of explanation or not Jason, but this might help: I use a BaseClass.as to extend so that I can dispatch events via GDispatcher: import com.blitzagency.xray.logger.XrayLog; import com.gskinner.events.GDispatcher; /** * @author John Grden */ class com.tomsnyder.util.BaseClass { // Public Properties: public var addEventListener:Function; public var removeEventListener:Function; public var removeAllEventListeners:Function; // Private Properties: private var dispatchEvent:Function; private var log:XrayLog; function BaseClass() { GDispatcher.initialize(this); log = new XrayLog(); } } So, with this, I just create a new class that extends BaseClass, and bingo, I have eventDispatching capabilities: import com.tomsnyder.util.BaseClass; /** * @author John Grden */ class BaseMain extends BaseClass { public static var SOMETHING_COMPLETE:String = "somethingComplete"; function BaseMain() { super(); } } Now, I can just as easily add my listener from another class that has access to BaseMain: BaseMain.addEventListener(BaseMain.SOMETHING_COMPLETE, Delegate.create(this, somethingCompleteHandler)); private function somethingCompleteHandler(e:Object):Void { trace(log.debug("somethingCompleteHandler called", e)); } For scope, just use mx.utils.Delegate or Steve Websters delegate Does that help or am I missing your question? John On 2/16/07, Merrill, Jason <[EMAIL PROTECTED]> wrote: > > OK, I'm pretty good at Actionscript 2.0, but something I never really > understood and now need to. > > Core question: How do I make an event in a custom class, and how do I > make a listener in another class listen for the event? > > EventBroadcaster in the help docs seems to only show how to use it with > Adobe classes and components. Docs on listener are the same. I know how > > to set up listeners for other events, like keypresses and mouse > rollovers. Easy enough. But my problem is this (see comments in code > below): > > class com.boa.projects.iqrcgenerator.components.AdminData{ > > private var userData:Object; > > public function wsUserDataByLOB(lobDbId:Number):Void{ > var getUserListResult:Object = new Object(); > getUserListResult = > generatorWebService.GetUserList (lobDbId); > getUserListResult.onResult = function(oUser){ > //this works fine, > //I can capture this event result here, > //but how do I notify another class? > //also what about scope here? > //how to set userData as oUser result? > //can I fire an event in my AdminData > //class from here? > } > } > > public function getUserData():Object{ > //can't let user get this data > //until Webserive event is done. > return userData; > } > } > > Thanks, > > > Jason Merrill > Bank of America > Learning & Organizational Effectiveness > > > _______________________________________________ > 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 > -- [ JPG ]
-- [ JPG ] _______________________________________________ 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