3 Replies Latest reply on Sep 13, 2007 5:45 PM by Peter Flynn (Adobe)

    Two Modules Issues: Debug & Events

    Justin Girard

      I have one issue and one question in reference to Modules:

      1) I'm using the Mac version of the Beta, and for some reason when I either build a Module project or select the "Run Application" option for the Module MXML file, the debug version of the SWF is not being compiled. As far as I can tell, the settings I currently have are not preventing this from happening. Anyone have an idea why? I'm stumped.

      2) If events are dispatched via a loaded module, can the Application that loaded it register listeners for those events? I can't find a clear answer to this anywhere in the documentation. One would think that this would be referenced somewhere, regardless of whether it's possible or not. I sure hope it's possible.


        • 1. Re: Two Modules Issues: Debug & Events
          Hi Justin,

          Ansering your query(2), I dont think you can directly add event listener to a component in the module in the main app... instead, you can register the event on the module itself if it is a bubbling event and then handle it in the main app, using event.target. For example:

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Module xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" width="400" height="300">
          import mx.controls.Alert;
          private function onClick():void{
          mx.controls.Alert.show("click from Module");
          <mx:Button id="btn" label="myBtn" click="onClick()"/>

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" xmlns="*" creationComplete="initApp()">
          import mx.controls.Alert;
          private function initApp():void{
          private function clickHandler(event:MouseEvent):void{
          if(event.target.id=="btn"){mx.controls.Alert.show("Click detected in main");}
          <mx:ModuleLoader url="myModule.swf" id="mod"/>
          • 2. Re: Two Modules Issues: Debug &amp; Events
            Justin Girard Level 1
            Hi raghunathrao,

            Thanks for your reply!

            What I was looking to confirm was that events dispatched from a Module will propagate through the Application that loaded it. I've confirmed this works, at least when the Module is implemented in MXML. I tried the same using an ActionScript-based module and had the opposite result, however that was before I determined why the debug version of my module SWF file was not bein compiled, which was...

            Apparently the debug version of the SWF is only compiled if your Module is set as the default Application for a project. There may or may not also be a problem with having that Module set to compile in the Flex Modules dialog of the Application's properties. Once I set my Module as the default app, and removed it from the Flex Modules dialog, I got the debug SWF I needed. Now I need to test this with an ActionScript-based Module, but based on the documentation for events, unless my ActionScript Module is on the DisplayList, the event will be dispatched directly to the target and the Application will remain unaware of the event.

            Your example will be great for cases where I need to make an Application aware of user interaction with components in the Module. Thanks!

            - justin
            • 3. Re: Two Modules Issues: Debug &amp; Events
              Peter Flynn (Adobe) Adobe Employee
              Hi Justin,

              The way Flex Builder handles debug vs. release SWFs has been streamlined for our next beta. I think it should resolve problem #1 on your list. Give it a try when it comes out (in October) and let us know what you think!

              - Peter