2 Replies Latest reply on Mar 10, 2011 11:39 AM by Rahul7777

    dispatching events between components/main application problem


      Hi ,

           i am new to flex, i am working hard to learn event dispatching, i got some knowledge but still not clear. Firstly i started dispatching events between components, later between main application and components, first one works, but later one didn't.

      Can you go through it and help me out.






              [Event(name="RebatesChangedEvent", type="flash.events.Event")]



                import events.ChangeEvent;

         protected function one_clickHandler(event:MouseEvent):void


            dispatchEvent(new RebatesChangeEvent("ChangedEvent"));




      <mx:checkBox id="one"  click="one_clickhandler(event)"/>


      <comps:Rectangle id="rect"    x="10" y="50" />






      <s:Group intialize="init()">


      import event.ChangeEvent;

      public function init():void



      public function eventListener(event:Event):void


          alert.show("event Dispatched");


      <s:rect> <s:fill> <s:SolidColor color="blue" alpha="0.3"/>

      </s:fill> </s:Rect>






      public class ChangeEvent extends Event
              public  static const rebates:String = "ChangedEvent";
              public function ChangeEvent(type:String)
           public override function  clone():Event
               var event:ChangeEvent =  new ChangeEvent(type);
               return event;



      Here while adding the listener i used parent.addeventListener(...)  i am not sure when to use parent, while dispatching b/w components this works but not b/w application and component.


      Can any one help me out.



      for reading.