1 Reply Latest reply on Apr 13, 2012 2:18 AM by Patel Bharat

    Using dispatchEvent to communicate between swc and main app...

    Chipleh Level 3



      I'm trying to get my custom .swc to communicate with my main application via the use eventDispatchers and listeners.


      In my main app I have this:





                  public function CustomList():void {


                      this.addEventListener(Event.INIT, onInit);



                  public function onInit(e:Event):void {

                      this.addEventListener("hello", onHello);



                  public function onHello(event:Event):void {

                      trace("oh hello");





      <views:MySkinnableContainer id="mySkinnableContainer" skinClass="skins.MySkinnableContainerSkin"/>


      <s:HGroup verticalAlign="bottom" width="100%" horizontalAlign="center" paddingRight="70" paddingBottom="30" paddingTop="500">

              <s:Button id="submitBtn" buttonMode="true" click="CustomList(event)" enabled="true"/>





      Within my skinnable container, I have this code attached to a button that the user clicks:


      public function onSubFormFinishClick(event:MouseEvent):void


                  trace("dispatching event: hello");

                  dispatchEvent(new Event("hello", true, true));



      However, I'm confused on how to initiate the listening of the dispatchedEvent. I have it currently attached to a button in my main app, but this does not seem to be working. I'm a bit thrown off based on the paradigm difference between Flash and Flex. Could anyone help straighten me out and explain why things aren't wired up correctly, or make this code work efficiently?


      Thanks so much for any help, I'm struggling to get myself rooted in Flex.