This metadata makes it available in mxml: [Event(name="userSubmit", type="events.UserEvents")]
But the syntax UserEvents.USER_SUBMIT requires a contant in that class: public class UserEvents extends Event { public static const USER_SUBMIT:String = "userSubmit"; Using a constant like that just ensures you won't misspell "userSubmit". Tracy Spratt, Lariat Services, development services available _____ From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of Alan Rother Sent: Monday, May 04, 2009 8:15 PM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] Newbie question: Custom Components and Custom Events This is the entire UserEvents class as the example showed me how to build it. I'm guessing that the declaration for my event is supposed to be in here, but in the demo we actually created it in the component we were loading. How and where do I add it to the UserEvents class and why does it work when I call it from MXML but not from AS? //File: UserEvents.as package events { import flash.events.Event; import vo.User; public class UserEvents extends Event { public var user:User; public function UserEvents(type:String, bubbles:Boolean=false, cancelable:Boolean=false) { super(type, bubbles, cancelable); } } } //Script Code from Component <mx:Metadata> [Event(name="userSubmit", type="events.UserEvents")] </mx:Metadata> <mx:Script> <![CDATA[ import vo.User; import events.UserEvents; import mx.managers.PopUpManager; private function onClick():void { var event:UserEvents = new UserEvents("userSubmit"); var user:User = new User(); user.fname = fname.text; user.lname = lname.text; user.email = email.text; event.user = user; dispatchEvent(event); } ]]> </mx:Script> -- Alan Rother Adobe Certified Advanced ColdFusion MX 7 Developer Manager, Phoenix Cold Fusion User Group, AZCFUG.org