I don't see any public static constCONFIG_FILE_ EVENT:AString = "somtething" in 
your custom event class...
C




________________________________
From: Raymond Brown <[email protected]>
To: "[email protected]" <[email protected]>
Sent: Sat, December 12, 2009 4:40:37 PM
Subject: [flexcoders] Beginner "Event" Question

   
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.ConfigFileEv ent")]
</mx:Metadata>
<mx:Script>
<![CDATA[
import event.ConfigFileEve nt;
import events.ConfigFileEv ent;
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( myConfigFileEven t);
//now register to listen for the event
this.addEventListener( ConfigFileEvent. CONFIG_FILE_ EVENT, eventCalled) ;
}
private function eventCalled( event:ConfigFile Event): 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? 

 


      

Reply via email to