Using TypedFactoryLocator

LowRA allows using components and libraries linked together by a XML context file.
Specifically, it is possible to create a dictionary of items and a factory to treat these items using as3 code.

Warning :
  • calling items in your plugins (from buider or at initialisation), the library/factory might not be already loaded. You should so enclose the use of your items from this library in methods you will call directly in the XML context file, with <method-call name=“myMethod” />
  • do not forget to compile the TypedFactoryLocator dll

Example : using a graphic library with TypedFactoryLocator


In the XML context file :
<dll url="assets/desktopIcons.dll"/>
<dictionary id="desktopIconsDictionary" type="Dictionary">
    <item><key value="news"/> <value type="Class" value="news"/></item>
    <item><key value="aide"/> <value type="Class" value="aide"/></item>
    <item><key value="compte"/> <value type="Class" value="compte"/></item>	
</dictionary>
 
<dll url="miscdlls/TypedFactoryLocator.dll"/>
<factory id="desktopIconsFactory" type="com.bourre.core.TypedFactoryLocator">
    <argument type="Class" value="flash.display.MovieClip"/>
    <method-call name="add">
        <argument ref="desktopIconsDictionary"/>
    </method-call>
</factory>
In the AS3 code :
var factory : TypedFactoryLocator = BeanFactory.getInstance().locate( "desktopIconsFactory" ) as TypedFactoryLocator;
var iconNews : MovieClip = factory.build( "news" ) as MovieClip;

Discussion

Enter your comment
 
 
projects/lowra/tips/using_typedfactorylocator.txt · Last modified: 2008/02/20 17:38 (external edit)
 
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki