Hi Roland,
i did include all classes, but the next line was missing in the main app.
Code:
import org.springextensions.actionscript.module.ISASModule; ISASModule;
cannot understand why it's working at your place then, cause in the svn this line is missing too... Im using flash builder 4 beta 2. Maybe it has something to do with that?
Anyway nice that you put an example project together but actually you are not testing the use of a custom class in a module. Ok you define it in the context, but it's never retrieved from that context! If i Try that it fails.
i modufied module 1 like this:
Code:
<?xml version="1.0" encoding="utf-8"?>
<BasicSASModule
xmlns="org.springextensions.actionscript.module.*"
xmlns:mx="http://www.adobe.com/2006/mxml"
creationComplete="initModule()"
layout="vertical"
horizontalAlign="left" xmlns:view="view.*">
<mx:Script>
<![CDATA[
import classes.ModuleClass;
import classes.ModuleClassImpl;
[Bindable]
[Autowired(mode="byType")]
//[Autowired]
public var moduleClass:ModuleClass;
private var forceInClusdeClasses:Array = [ModuleClassImpl];
private function initModule():void {
moduleApplicationContext.addConfigLocation("module1-context.xml");
moduleApplicationContext.addEventListener(Event.COMPLETE,complete_handler);
moduleApplicationContext.load();
}
private function complete_handler(event:Event):void {
moduleApplicationContext.removeEventListener(Event.COMPLETE,complete_handler);
}
]]>
</mx:Script>
<mx:Label fontSize="20" text="MODULE #1"/>
<mx:Label fontSize="20" text="moduleclass: {moduleClass.title}, now: {moduleClass.now}"/>
<mx:HBox>
<view:InjectedTextLabel/>
</mx:HBox>
</BasicSASModule>
and modified custom class like this (interface and implementation):
Code:
package classes {
[Bindable]
public interface ModuleClass
{
function get title():String;
function set title(value:String):void;
function get now():Date;
function set now(value:Date):void;
}
}
Code:
package classes
{
[Bindable]
public class ModuleClassImpl implements ModuleClass
{
public var title:String = "ModuleClass";
public var now:Date = new Date();
public function ModuleClassImpl() {
super();
}
}
}
and context for module 1 like this:
Code:
<?xml version="1.0" encoding="utf-8"?>
<objects
xsi:schemaLocation="http://www.springactionscript.org/schema/objects http://www.springactionscript.org/schema/objects/spring-actionscript-objects-1.0.xsd"
xmlns="http://www.springactionscript.org/schema/objects"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<object id="injectedText" class="String">
<constructor-arg value="This was injected by the module 1 context"/>
</object>
<object id="customClass" class="classes.ModuleClassImpl"/>
</objects>
if i run this i get the next error:
Code:
...
Sun Oct 25 12:14:28 GMT+0100 2009 DEBUG - org.springextensions.actionscript.stage.FlexStageProcessorRegistry - Process UIComponent '_poc_multi_module_sas0.module2.SASDemoModule2_13.HBox16.InjectedTextLabel17.VBox18.lblTitle2'
Sun Oct 25 12:14:28 GMT+0100 2009 DEBUG - org.springextensions.actionscript.stage.FlexStageProcessorRegistry - Stage processing completed
Sun Oct 25 12:14:28 GMT+0100 2009 DEBUG - org.springextensions.actionscript.context.support.XMLApplicationContext - No external properties file reference found.
Sun Oct 25 12:14:28 GMT+0100 2009 INFO - org.springextensions.actionscript.ioc.factory.support.DefaultListableObjectFactory - Pre-instantiating singletons in [object FlexXMLApplicationContext]
Sun Oct 25 12:14:28 GMT+0100 2009 WARN - org.as3commons.reflect.Type - Type.forName error: Error #1065: Variable ModuleClassImpl is not defined. The class 'classes.ModuleClassImpl' is probably an internal class or it may not have been compiled.
ReferenceError: Error #1065: Variable ModuleClass is not defined.
at global/flash.utils::getDefinitionByName()
at org.as3commons.lang::ClassUtils$/getImplementedInterfaces()[/home/christophe/IdeaProjects/as3commons/as3-commons-lang/src/main/actionscript/org/as3commons/lang/ClassUtils.as:282]
at org.as3commons.reflect::Type$/forClass()[/home/christophe/IdeaProjects/as3commons/as3-commons-reflect/src/main/actionscript/org/as3commons/reflect/Type.as:156]
at org.springextensions.actionscript.ioc.autowire::DefaultAutowireProcessor/getUnclaimedSimpleObjectProperties()[/Users/arnoudbos/Desktop/development/flex frameworks svn/spring-actionscript/trunk/spring-actionscript-core/src/main/actionscript/org/springextensions/actionscript/ioc/autowire/DefaultAutowireProcessor.as:412]
at
...
so the module has trouble looking up the custom class in the context, but it is force included in the module as can be seen in the module 1 mxml
You can also see that reflect cannot find ModuleClassImpl ....
i'll experiment some more and let you know how it goes.... I have a feeling that if i include those classes in the main context everything will work...
Arnoud