One thing I did as a workaround is the following:
1. Include the bean package from the www.as2lib.org
2. Compile the class by doing something like in the root of the timeline:
public var class:AClassName;
This then gets compiled into the swf.
3. Load in the swf at runtime and once it is loaded the full class name say it was something like
net.test.MyClass would now be available in the global class path.
4. Now use as2libs bean parser:
public function loadContextXML( contextXMLPath:String, aLibraryId:String ):Void {
Logger.log("DEBUG", this + "loadContextXML() " + contextXMLPath );
this.libraryId = aLibraryId;
beanDefinitionParser = new UiBeanDefinitionParser();
applicationContext = new LoadingApplicationContext(contextXMLPath, beanDefinitionParser );
applicationContext.addListener(this);
applicationContext.start();
Logger.log("DEBUG", this + "loading batch context ["+applicationContext+"] " );
}
5. Now this runs the xml with bean definitions similar to spring and instantiates all of the classes:
6. Because the definition of the .net.test.MyClass is instantiated after the SWF that gets loaded it is now accessible through the swf that loaded in the classes.
7. This then makes it very reusable because you can compile external libraries in SWFs and then load them in at runtime and then access them using as2lib's spring factory framework.
- Code warrior
2 comments:
1 year and 3 weeks later, I'd like to tell you that this one of the most useful Actionscript tips I've seen in a while.
Are you still working with as2lib? I'd love to get a revival movement happening, this lib is just amazing, Simon Wegner should get a Nobel prize in Economics, Physics, and Medicine for this damn thing.
Er, make that Simon Wacker, not Wegner :p
Post a Comment