FlexBuilder sees this: [Event(name="ConfigFileEvent", type="event.ConfigFileEvent")]
And automatically creates a code complete version CONFIG_FILE_EVENT even if it doesn't exist. It's always been that way. Either create the constant yourself, or ignore the code completion and write "ConfigFileEvent". --- In flexcoders@yahoogroups.com, Raymond Brown <silenttr...@...> wrote: > > I created a custom event to pass a string with, shown here: > > package events > { > import flash.events.Event; > public class ConfigFileEvent extends Event > { > public var configFile:String; > public function ConfigFileEvent(type:String, configFile:String) > { > super(type); > this.configFile = configFile; > } > override public function clone():Event { > return new ConfigFileEvent(type, configFile); > } > } > } > > I then have in my main class an event metadata tag, a dispatch and event > listener shown here: > > <?xml version="1.0" encoding="utf-8"?> > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" > creationComplete="initApp()" > > <mx:Metadata> > [Event(name="ConfigFileEvent", type="event.ConfigFileEvent")] > </mx:Metadata> > <mx:Script> > <![CDATA[ > import event.ConfigFileEvent; > import events.ConfigFileEvent; > private function initApp(): void { > //simulate the getting of a config file from RO and once done sending out the > event; > var temp:String = "This works"; > var myConfigFileEvent:ConfigFileEvent = new > ConfigFileEvent("ConfigFileEvent", temp); > dispatchEvent(myConfigFileEvent); > //now register to listen for the event > this.addEventListener(ConfigFileEvent.CONFIG_FILE_EVENT, eventCalled); > } > private function eventCalled(event:ConfigFileEvent): void { > // > } > ]]> > </mx:Script> > </mx:Application> > > > However Flex builder won't compile because of the error: > > Access of possibly undefined property CONFIG_FILE_EVENT through a reference > with static type Class. in the addEventListener line. Can someone provide a > better insight as to this error and what it is that I am doing wrong? >