Skip to content

Instantly share code, notes, and snippets.

@keyle
Last active August 29, 2015 14:05
Show Gist options
  • Select an option

  • Save keyle/6111c91b47d83f533c49 to your computer and use it in GitHub Desktop.

Select an option

Save keyle/6111c91b47d83f533c49 to your computer and use it in GitHub Desktop.
Parsley 3.0 in AS3 only
package
{
public class Model
{
public var test:Array = ["hello", "world"];
}
public class Player
{
[Inject]
public var model:Model;
[Init]
public function Init():void
{
trace(model.test);
}
}
}
private function addedToStage(Event:*):void
{
XmlContextBuilder.build("parsleyconfig.xml");
var p = new Player();
}
parsleyconfig.xml:
<objects xmlns="http://www.spicefactory.org/parsley"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.spicefactory.org/parsley/schema/2.3/parsley-core.xsd">
<object type="Model" />
<object type="Player" />
</objects>
runtime:
[trace] hello,world
@keyle

keyle commented Aug 26, 2014

Copy link
Copy Markdown
Author

NOTE: objects that are declared in the XML config have to be used at least once, or Parsley bootstrap will crash at runtime startup!!

@keyle

keyle commented Aug 26, 2014

Copy link
Copy Markdown
Author

UPDATE: I found a better solution, no XML so refactoring safe.

https://gist.github.com/keyle/b1d5254b3c43d2dbf79c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment