2 Replies Latest reply on Apr 24, 2008 9:49 AM by RanchingOnMyMind

    Event communication between Dynamically loaded modules

    sk_acura Level 1
      Hi All,

      I am loading the Modules dynamically in a separate popup windows and
      once ther are loaded they need to communicate with each other (for
      when i click some link in one window i need to refresh the contents of
      the Other window and switch focus to it..)

      And when i try to send a custom event i am getting the following Error:

      I am not sure why it is having trouble in converting FocusViewEvent
      Object to FocusViewEvent Type !!!


      TypeError: Error #1034: Type Coercion failed: cannot convert
      com.dpa.ui.desktop.event::FocusViewEvent@-4ff225ff to
      at flash.events::EventDispatcher/dispatchEvent()
      at MyGraph/::notifyParent()
      at MyGraph/___Button4_click()

      The code i have is :


      private function notifyParent():void{
      var focusEvent:FocusViewEvent = null;
      var viewVO:ViewVO = new ViewVO();
      focusEvent = new FocusViewEvent(viewVO);
      trace("Here in notifyParent() and focusEvent ="+focusEvent);
      trace("After sending the Notification Event");


      public function init():void{
      trace("Here in init()");
      trace("After adding the Event Listener 1");
      public function onFocusWindow(event:FocusViewEvent):void{
      trace("Here in onFocusEvent focusEvent ="+event);

      The FocusViewEvent is declared as
      public class FocusViewEvent extends CairngormEvent
      public static var EVENT_FOCUS_WINDOW : String = "focusViewEvent";
      public var viewVO:ViewVO;
      public function FocusViewEvent(viewVO : ViewVO)
      this.viewVO = viewVO;

        • 1. Re: Event communication between Dynamically loaded modules
          Gaurav J Adobe Employee
          You may be having class loading conflicts in your app. The definition of FocusViewEvent may be different between the two modules.

          As a workaround you should try to declare the FocusViewEvent in the main app, so that the class gets loaded as part of the main app and the same definition is shared by both modules.

          You should add the following to your main app.

          import com.dpa.ui.desktop.event::FocusViewEvent;
          var dummyFocusEvent:FocusViewEvent = null;

          Gaurav Jain
          Flex SDK Team
          • 2. Re: Event communication between Dynamically loaded modules
            RanchingOnMyMind Level 1

            I encountered a similar problem--TypeError: Error #1034: Type Coercion failed: cannot convert mx.controls::ToggleButtonBar@431b0a1 to mx.controls:ButtonBar.

            I followed Gaurav's advice and placed a variable in the main app, as follows:

            private var dummyToggleButtonBar:ToggleButtonBar = null;

            This resolved the TypeError: Error #1034.

            My only question is why, I assume this resets the ToggleButtonBar, but how does the above variable get associated with the ToggleButtonBar I'm using in several modules?