Link to home
Start Free TrialLog in
Avatar of hockeyragazzo
hockeyragazzo

asked on

ModuleLoader Issues

Hello everyone. I suspect this is a relatively simple problem, but I can't figure out what is going on. Here's the scenario:

- I have a simple TabNavigator with three tabs: Home, Transactions, Positions
- Home is empty, Transactions and Positions each have a ModuleLoader that call separate modules. Each module is relatively complex and contains multiple components, custom components, and functions, both public and private.
- When a tab is clicked, the attached code is run:


Now here's the problem:

When I load the transactions module, it works fine. However, if I load the positions module after the transactions module is already loaded, many of the functions simply do not work. If I load the positions module first, all functions work perfectly, but then if I load the transactions module after that, many of the functions in the transactions module don't work.

For example, I have a pie chart in the positions module. If I load the positions module first, you can hover over individual slices and it pops up the DataTips. If I open the transactions module first and the positions module second, you can only see the DataTips if you click the slices of the pie.

Another example: if I load the positions module first and then the transactions module, a function I have that calls an HTTPService object doesn't fire.

Other examples that may help you in your quest to help me:

- ComboBoxes don't drop down when clicked in the second-loaded module.
- DateChoosers don't pop up with the calendar when selected in a DateField.
- Individual rows in DataGrids are selectable, but selecting the column headers does nothing (normally sorts by that column)
- Mouse hover events seem not to be firing, though click events seem to be firing at times.
- States aren't changing properly.

For reference, all of these things function perfectly when the module is loaded first in the application, but fail when it is loaded second.

Can somebody please help?

private function loadTranModule():void {
    if (mainnavigator.selectedIndex == 1) {
        if (tranloader.url != "modules/MainTransactionsModule.swf") {
            tranloader.url = "modules/MainTransactionsModule.swf";
            tranloader.loadModule();
            return;
        } else {
            return;
        }
    } else if (mainnavigator.selectedIndex == 2) {
        if (posloader.url != "modules/MainPositionsModule.swf") {
            posloader.url = "modules/MainPositionsModule.swf";
            posloader.loadModule();
            return;
        } else {
            return;
        }
    }
}

Open in new window

SOLUTION
Avatar of Dgleich
Dgleich

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of hockeyragazzo
hockeyragazzo

ASKER

Thanks for the reply, Dgleich. I have restructured the code as seen below and the problem still persists. I've done another test where the following is the only thing in the Application:

<mx:ModuleLoader url="modules/stuffmodule1.swf" x="212" y="176"/>
<mx:ModuleLoader url="modules/stuffmodule2.swf" x="540" y="176"/>

The two modules each have this code:

<mx:DateField x="39" y="42"/>

So there are two date fields sitting next to each other. The first one I interact with pops up the datechooser, but the second one I interact with does not. Thanks again for taking the time to help.
public function loadTranModule():void {
				if (mainnavigator.selectedIndex == 1) {
					if (tranloader.url != "modules/MainTransactionsModule.swf") {
						tranloader.url = "modules/MainTransactionsModule.swf";
						tranloader.loadModule();
						return;
					} else {
						tranloader.url = "";
						tranloader.unloadModule();
						return;
					}
				} else if (mainnavigator.selectedIndex == 2) {
					if (posloader.url != "modules/MainPositionsModule.swf") {
						posloader.url = "modules/MainPositionsModule.swf";
						posloader.loadModule();
						return;
					} else {
						posloader.url = "";
						posloader.unloadModule();
						return;
					}
				}
			}

Open in new window

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hey lexxwern,

The application creationPolicy is whatever the default setting is. I tried screwing around with the creationPolicy for the ModuleLoader's container and the ModuleLoader (using both "auto" and "all" and every combination thereof), but it didn't change the result. I'm currently at work, so I don't yet have the opportunity to try changing the creationPolicy for my application, but do you think this is what's affecting the loading of my modules?

Thanks
Hi lexxwern,

I just got home and I started playing around with the creationPolicy for the Application. When I set it to queued or none, the tab navigator doesn't load. When I set it to auto or all, it loads, but the problem persists. For the meantime, I've managed to get the ModuleManager to work well, but this loads up the main application swf in terms of size, and I'd like to be able to use the ModuleLoader so I can keep the main swf size small.

I'm getting more and more perplexed by this problem, especially after seeing sites like these:

http://www.huyler.net/flexblog/2007/09/01/modules-part-1-using-moduleloader/#more-5

What is he doing that I'm not?? In the interest of solving the problem, I've posted a very simple version of this code that produces the same problem. The first snippet is what's in each module (very simple...one DateField), and the second is the main application. Run it and try to select the calendar in each DateField.



<?xml version="1.0" encoding="utf-8"?>
<mx:Module xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="168" height="112" backgroundColor="#419F3F">
	<mx:DateField x="39" y="42"/>
</mx:Module>
 
============
 
<?xml version="1.0" encoding="utf-8"?> 
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationPolicy="auto"
layout="absolute" xmlns:components="components.*"> 
    <mx:Script> 
        <![CDATA[
	    	import mx.managers.PopUpManager;
        ]]> 
    </mx:Script> 
	<mx:ModuleLoader id="loader1" x="207" y="197" url="modules/stuffmodule1.swf"/>
	<mx:ModuleLoader id="loader2" x="509" y="197" url="modules/stuffmodule2.swf"/>
</mx:Application>

Open in new window

ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial