ActionScript: Package-level introspection? Or some other pluggable loading scheme?
I'm coding up some delicious business logic and I've come to a situation like this: There are a bunch of rules ( ruleA , ruleB , etc...) which all follow a standard pattern. I've created a Rule interface, and implemented it in RuleA , RuleB , and so on. So now I just need a way to load them. Right now I'm using a map: var rules:Object = { ruleA: new RuleA(), ruleB: new RuleB(), ... }; Then calling it like this: function doStuff(whichRule:String, someData:Object):* { return rules[whichRule].applyTo(someData); } Now, the rules follow a standard naming scheme, and they are all part of one package