Issue with Flex 3 error "class is not an IEventDispatcher"

I just started playing around with Flex 3 for a project at work. Part of the project requires pulling customer site information and displaying on a Google Map. I figured out how to do that, but when I would display grid data I would get the warning.

warning: unable to bind to property ‘xxx’ on class ‘xxx’ (class is not an IEventDispatcher)

After a few Google searches, I found an easy solution and a “d’uh moment”.

I had set up my data structures as ActionScript Class files.


package
{
public class Site
{
public var site_id:int;
public var name:String;
public var street_address:String;
public var city:String;
public var state:String;
public var zip:String;
public var latitude:Number;
public var longitude:Number;

public function Site(obj:Object = null)
{
if (obj != null)
{
this.site_id = obj.site_id;
this.name = obj.name;
this.street_address = obj.street_address;
this.city = obj.city;
this.state = obj.state;
this.zip = obj.zip;
this.latitude = obj.latitude;
this.longitude = obj.longitude;
}
}

}
}

When ever I made a web service request to retrieve the site data, I would get the warning message. A simple fix to not get the warning was to simply bind each of the variables.

package
{
public class Site
{
[Bindable]
public var site_id:int;
[Bindable]
public var name:String;
[Bindable]
public var street_address:String;
[Bindable]
public var city:String;
[Bindable]
public var state:String;
[Bindable]
public var zip:String;
[Bindable]
public var latitude:Number;
[Bindable]
public var longitude:Number;

public function Site(obj:Object = null)
{
if (obj != null)
{
this.site_id = obj.site_id;
this.name = obj.name;
this.street_address = obj.street_address;
this.city = obj.city;
this.state = obj.state;
this.zip = obj.zip;
this.latitude = obj.latitude;
this.longitude = obj.longitude;
}
}

}
}

That was simple enough. Took me an hour or so of search to figure it out.

About DeanLogic
Dean has been playing around with programming ever since his family got an IBM PC back in the early 80's. Things have changed since BASICA and Dean has dabbled in HTML, JavaScript, Action Script, Flex, Flash, PHP, C#, C++, J2ME and SQL. On this site Dean likes to share his adventures in coding. And since programming isn't enough of a time killer, Dean has also picked up the hobby of short film creation.

About DeanLogic

Dean has been playing around with programming ever since his family got an IBM PC back in the early 80's. Things have changed since BASICA and Dean has dabbled in HTML, JavaScript, Action Script, Flex, Flash, PHP, C#, C++, J2ME and SQL. On this site Dean likes to share his adventures in coding. And since programming isn't enough of a time killer, Dean has also picked up the hobby of short film creation.

Leave a Reply

Your email address will not be published. Required fields are marked *

*