Last active
August 29, 2015 14:05
-
-
Save keyle/6111c91b47d83f533c49 to your computer and use it in GitHub Desktop.
Parsley 3.0 in AS3 only
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
Author
Author
UPDATE: I found a better solution, no XML so refactoring safe.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
NOTE: objects that are declared in the XML config have to be used at least once, or Parsley bootstrap will crash at runtime startup!!