Hi Jon, Event bubbling exists specifically for display objects. It is generally used for events like mouse clicks and keyboard presses. A limited subset of Flex events bubble so that they can be intercepted all the way up the display list.
There is some good documentation on this at the link below: http://livedocs.macromedia.com/labs/1/flex20beta3/wwhelp/wwhimpl/common/ html/wwhelp.htm?context=LiveDocs_Parts&file=00000475.html If you really need bubbling, then you will need to put your object on the display list. Alternatively you can use a solution that doesn't require bubbling. The simplest solution would be to create your listener directly on your WebServiceCheck object. I've pasted a demo app that may be helpful. Create a new project, and place both files in the project's root directory. The project shows event capturing from instances of a custom class. CustomObject1 is not placed on the display list; customObject2 is placed on the display list in actionscript; and customObject3 is placed on the display list in MXML. When you run it you will see that bubbling up to the Application only happens for customObjects 2 and 3. Since customObject1 is not on the display list, the only way to receive events dispatched from it is to create an event listener directly on the object. Note that I have used UIComponent as the base class for my custom class rather than Sprite because it is more compatible with the other flex classes. If you are creating objects that dispatch events but do not use bubbling, then you do not need to descend from UIComponent. For example, Validator descends directly from EventDispatcher. Paul ========= Main.mxml ========== <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="*" layout="horizontal" creationComplete="initialise()"> <mx:Script> <![CDATA[ import mx.controls.List; public var customObject1 : CustomClass = new CustomClass(); public var customObject2 : CustomClass = new CustomClass(); public function initialise() : void { this.addEventListener( CustomClass.MY_CUSTOM_EVENT, appListener ); vBox1.addEventListener( CustomClass.MY_CUSTOM_EVENT, vBoxListener1 ); vBox2.addEventListener( CustomClass.MY_CUSTOM_EVENT, vBoxListener2 ); vBox3.addEventListener( CustomClass.MY_CUSTOM_EVENT, vBoxListener3 ); customObject1.addEventListener( CustomClass.MY_CUSTOM_EVENT, objListener1 ); customObject2.addEventListener( CustomClass.MY_CUSTOM_EVENT, objListener2 ); customObject3.addEventListener( CustomClass.MY_CUSTOM_EVENT, objListener3 ); // Make customObject2 a child of vBox2 - this puts it into the display list vBox2.addChild( customObject2 ); } public function appListener( event : Event ) : void { if ( event.target == customObject1 ) { text1.text += "Application's event listener fired\n" } else if ( event.target == customObject2 ) { text2.text += "Application's event listener fired\n" } else if ( event.target == customObject3 ) { text3.text += "Application's event listener fired\n" } } public function vBoxListener1( event : Event ) : void { text1.text += "VBox1's event listener fired\n" } public function vBoxListener2( event : Event ) : void { text2.text += "VBox2's event listener fired\n" } public function vBoxListener3( event : Event ) : void { text3.text += "VBox3's event listener fired\n" } public function objListener1( event : Event ) : void { text1.text += "Object1's event listener fired\n" } public function objListener2( event : Event ) : void { text2.text += "Object2's event listener fired\n" } public function objListener3( event : Event ) : void { text3.text += "Object3's event listener fired\n" } ]]> </mx:Script> <mx:VBox id="vBox1"> <mx:Label text="Object1 is not on DisplayList"/> <mx:Button label="Generate Event" click="customObject1.generateEvent()"/> <mx:TextArea height="500" width="300" id="text1"/> </mx:VBox> <mx:VBox id="vBox2"> <mx:Label text="Object2 was added to DisplayList"/> <mx:Button label="Generate Event" click="customObject2.generateEvent()"/> <mx:TextArea height="500" width="300" id="text2"/> </mx:VBox> <mx:VBox id="vBox3"> <!-- Custom Class instantiated as a child of vBox3 in MXML --> <comp:CustomClass id="customObject3" includeInLayout="false" visible="false"/> <mx:Label text="Object3 was created on DisplayList in MXML"/> <mx:Button label="Generate Event" click="customObject3.generateEvent()"/> <mx:TextArea height="500" width="300" id="text3"/> </mx:VBox> </mx:Application> ============== CustomClass.as ============== package { import mx.core.UIComponent; import flash.events.Event; public class CustomClass extends UIComponent { public static const MY_CUSTOM_EVENT : String = "MyCustomEvent"; public function generateEvent() : void { dispatchEvent( new Event( MY_CUSTOM_EVENT, true, false ) ); } } } -----Original Message----- From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Jon Hirschi Sent: Saturday, June 24, 2006 12:54 AM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] how do you dispatch event from a custom class? is there anyway to enter an event into the event stream without a class being a display object? ie, not having it in the display list? --- Ralf Bokelberg <[EMAIL PROTECTED]> wrote: > Either by instantiating it in mxml or explicitely by > adding it using > container.addChild. > Cheers, > Ralf. > > On 6/24/06, Jon Hirschi <[EMAIL PROTECTED]> > wrote: > > > > I tried what you said and attempted to have the > > WebServiceCheck itself dispatch the event, > however, it > > doesn't dispatch anything into the event stream, > even > > attaching an event listener to the variable return > > variable doesn't do anything. > > > > How do I make it part of a displaylist?? > > > > --- Ralf Bokelberg <[EMAIL PROTECTED]> > wrote: > > > > > Hello Paul > > > > > > In your code you are creating a separate > > > EventDispatcher, which is not > > > part of any displaylist. If you let your > > > WebServiceCheck dispatch the > > > event instead, it should work. At least as long > as > > > it is part of a > > > displaylist. > > > > > > Cheers, > > > Ralf. > > > > > > On 6/23/06, Jon Hirschi <[EMAIL PROTECTED]> > > > wrote: > > > > > > > > Hi Paul, > > > > > > > > So I'm putting my event listener in the > > > application > > > > core. What I would like is for this event to > > > enter > > > > the event stream and bubble up to the > application > > > > core. Currently, it doesn't look like it even > > > makes > > > > it out of the document that I'm in. I'm not > even > > > sure > > > > that it gets populated outside of the class > > > itself. > > > > > > > > What i'd really like is to have this event > entered > > > > automatically into the event stream with out > > > having to > > > > have an event repeater. > > > > > > > > --- Paul Williams <[EMAIL PROTECTED]> wrote: > > > > > > > > > Hi Jon, > > > > > > > > > > Sprite extends EventDispatcher, so you don't > > > need to > > > > > instantiate another > > > > > EventDispatcher in your class. > > > > > > > > > > Instead, try the following: > > > > > > > > > > this.dispatchEvent(new > > > > > Event("AuthenticationFailed",true,false)); > > > > > > > > > > If you still have problems can you let us > know > > > what > > > > > object you are > > > > > creating your event listener on? > > > > > > > > > > Paul > > > > > > > > > > -----Original Message----- > > > > > From: flexcoders@yahoogroups.com > > > > > [mailto:[EMAIL PROTECTED] On > > > > > Behalf Of Jon Hirschi > > > > > Sent: Thursday, June 22, 2006 9:45 PM > > > > > To: flexcoders@yahoogroups.com > > > > > Subject: [flexcoders] how do you dispatch > event > > > from > > > > > a custom class? > > > > > > > > > > > > > > > I have a custom class that I want to be able > to > > > > > dispatch an event. However, it's not > entering > > > the > > > > > event into the event stream, I don't even > think > > > the > > > > > event is getting out of the class. I have > > > bubbles > > > > > set > > > > > to true. does anyone know how to get the > event > > > > > entered into the event stream... the docs > aren't > > > > > very > > > > > explicit on this subject.... > > > > > > > > > > ie > > > > > > > > > > code to call my class... > > > > > > > > > > private function > > > > > handleLBResponse(eventObj:ResultEvent):void > { > > > > > var > > > tempArray:Array; > > > > > var > > > checkResult:WebServiceCheck = new > > > > > WebServiceCheck(); > > > > > if > > > > > > > > > > > > > > > (checkResult.checkServiceReturnStatus(eventObj,true)) > > > > > > > > > > { > > > > > > tempArray > > > = > > > > > > > > > > > > > > > mx.utils.ArrayUtil.toArray(eventObj.result.lbvServerTos); > > > > > if > > > (tempArray.length > 1) { > > > > > > > > dpLBVServerData.source = > > > > > tempArray; > > > > > } else > { > > > > > > > > > > dpLBVServerData.removeAll(); > > > > > } > > > > > } else { > > > > > > > > dpLBVServerData.removeAll(); > > > > > } > > > > > > > > > > } > > > > > > > > > > > > > > > > > > > > > > > > > ------------------------------ > > > > > code in the class > > > > > > > > > > ----------------------------------- > > > > > > > > > > package comp.webconfig.services { > > > > > > > > > > import flash.display.Sprite; > > > > > import mx.rpc.events.ResultEvent; > > > > > import mx.controls.Alert; > > > > > import flash.events.Event; > > > > > import flash.events.EventDispatcher; > > > > > > > > > > public class WebServiceCheck extends > > > Sprite { > > > > > > > > > > > > > > > > > > > > public var isSuccess:Boolean; > > > > > public var statusType:String; > > > > > public var message:String; > > > > > public var rawMessage:String; > > > > > > > > > > public function > WebServiceCheck() > > > { > > > > > > > > > > } > > > > > > > > > > public function > > > > > > > > > > > > > > > checkServiceReturnStatus(resultToCheck:ResultEvent,alertOnError:Boolean= > > > > > false):Boolean > > > > > { > > > > > var myMessage:String; > > > > > var isSuccess:Boolean > = > === message truncated === __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links ------------------------ Yahoo! Groups Sponsor --------------------~--> Great things are happening at Yahoo! Groups. See the new email design. http://us.click.yahoo.com/TISQkA/hOaOAA/yQLSAA/nhFolB/TM --------------------------------------------------------------------~-> -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/flexcoders/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/