Carlos Rovira
Director de Proyectos
carlosrovira.com
Avda. Betanzos nº2, 1º-3
28029 Madrid
+34 607226005
+34 912441351
http://www.carlosrovira.com
For now, just load your beans from within the main app and keep a
private reference to those events that need to be mediated.
Cairngorm suffers from the same problem.
João Fernandes
and are you able to properly mediate Events that are exclusively within
the module and not in the main application?
João Fernandes
Any idea when using modules when you load and unload a module and then
load it again events are triggers twice? or three, four times
depending on how many times you have loaded/unloaded the module?
Thanks for your great work
I'm talking about DynamicMediator problem with Modules and cohersion errors that I've posted in the past.
I think there is also the problem of Event Classes that are exclusively within a module and not available in the main app, it will always throw an error to any mediated function that targets that class.
try to load this module from an application that has no reference to SomeEvent.
It will always to fail to create the dynamic mediator since it will lookup in the main application for the class definition and not within the available modules.
<?xml version="1.0" encoding="utf-8"?>
<mx:Module
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute" width="400" height="300"
initialize="module1_initializeHandler(event)">
<mx:Script>
<![CDATA[
import event.SomeEvent;
import org.swizframework.Swiz;
import mx.events.FlexEvent;
import mx.controls.Alert;
private var e:SomeEvent;
[Mediate(event="event.SomeEvent.DO_SOMETHING")]
public function doSomething():void{
Alert.show('mediated');
}
protected function button1_clickHandler(event:MouseEvent):void
{
Swiz.dispatchEvent(new SomeEvent(SomeEvent.DO_SOMETHING));
}
protected function module1_initializeHandler(event:FlexEvent):void
{
Swiz.setStrict(true);
}
]]>
</mx:Script>
<mx:Button x="64" y="48" label="Button" click="button1_clickHandler(event)"/>
</mx:Module>
--
João Fernandes
Adobe Certified Expert
Adobe Community Expert
http://www.onflexwithcf.org
http://www.riapt.org
Portugal Adobe User Group (http://aug.riapt.org)
Another problem is unloading modules beans, if I have a controller with
a mediated function it isn't properly 'de-mediated' and keeping a
reference that prevents garbage collection.
As a workaround for now, I've always loaded my beans in my main app,
loading them as needed and keeping a private reference to needed events
(so beans and events are always in the main app) but in my opinion
modules should be totally independent.