Ok dear i chanaged MyEvent Class with this
        public class MyEvent extends Event
        { 
                public static  var MY_EVENT:String = "MY_EVENT" ;       
        
                public function MyEvent()
                {
                        super ( MY_EVENT  , true  ); 
                }
        }

but what about " dispatchEvent( new MyEvent(), true ); "
dispatchEvent does not accept second argument , it only accepts one argument of 
Type Event

----- Original Message -----
From: "Daniel Gold" <[EMAIL PROTECTED]>
To: flexcoders@yahoogroups.com
Sent: Sat, 28 Jun 2008 10:16:29 -0500
Subject: Re: [flexcoders] Custom Event Not Dispatched

> If you're not listening for the event directly on the component that will be
> dispatching it, you need to toggle the 'bubbles' property so that the event
> will will trigger handlers up the display list from where it was dispatched.
> 
> So in your case change your dispatch line to:
> dispatchEvent( new MyEvent(), true );
> 
> On Sat, Jun 28, 2008 at 10:11 AM, <[EMAIL PROTECTED]> wrote:
> 
> >   HI can any one tell me what is wrong with this code.
> >
> > I wrote a custom event and dispatched this event from my entity class and
> > am listening for this event on main application but the listener is not
> > listening for event. Please help me.
> >
> > here is my Event class
> > public class MyEvent extends Event
> > {
> > public static var MY_EVENT:String = "MY_EVENT" ;
> >
> > public function MyEvent()
> > {
> > super ( MY_EVENT );
> > }
> > }
> >
> > This class dispatches an event of type MyEvent from setter method
> > public class MyObject extends EventDispatcher
> > {
> > [Bindable(event="MyEvent")]
> > private var _name:String;
> >
> > public function set name( _pname:String ):void
> > {
> > _name = _pname ;
> > trace( "Dispatching Event" );
> > dispatchEvent( new MyEvent() );
> >
> > }
> > }
> >
> > and here is code for my main application .
> > <?xml version="1.0" encoding="utf-8"?>
> > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
> > layout="vertical" creationComplete="{init()}" >
> >
> > <mx:Script>
> > <![CDATA[
> > import com.MyEvent;
> > import com.MyObject;
> >
> > private var obj:MyObject ;
> >
> > public function init():void
> > {
> > obj = new MyObject();
> > this.addEventListener(MyEvent.MY_EVENT , propertyChangeListener ) ;
> >
> > }
> >
> > public function propertyChangeListener( evt:MyEvent ):void
> > {
> > // This Function never gets called
> > trace( 'Listining for MyEvent......' );
> > }
> > public function btnClickHandler():void
> > {
> > obj.name = 'Changing Value' ;
> > trace( obj.name );
> > }
> >
> > ]]>
> > </mx:Script>
> > <mx:Button click="{btnClickHandler()}"/>
> > </mx:Application>
> >
> >  
> >

Reply via email to