, , , simply impossible... ... , ...
:
ActionScript ... , , swf... ...
, , , script, , - - ... , Array,
[Rule1, Rule2,...RuleN]
, ... , ( ), getDefinitionByName, ...
, , , , ... ...
- , ... , , , , ... ...
:
class NameIsRule implements IRule {
private var _name:String;
public function NameIsRule(name:String) {
this._name = name;
}
public function applyTo(target:Object):* {
return target.hasOwnProperty("name") && (target.name == this._name)
}
}
rules = {
isCalledJim : new NameIsRule("Jim"),
isCalledJohn : new NameIsRule("John")
}
( , , )
, ...
package {
public class RuleMap {
private var _rules:Object = {}
public function RuleMap(init:Object = null) {
for (var name:String in init)
this.addRule(name, init[name]);
}
public function addRule(id:String, rule:IRule):IRule {
if (this.ruleExists(id))
throw new Error("duplicate rule for id " + id);
if (rule == nul)
throw new ArgumentError("invalid value null for parameter rule");
this._rules[id] = rule;
return rule;
}
public function applyRule(id:String, target:Object):* {
return this.getRule(id).applyTo(target);
}
public function getRule(id:String):IRule {
if (this.ruleExists(id))
return this._rules[id];
else
throw new Error("no rule for id " + id);
}
public function ruleExists(id:String):Boolean {
return this._rules.hasOwnProperty(id);
}
}
}
verbous (, ), , , AVM2 ( , ... , )...
, , , ... .....
AS3, , , ... AS3 ... , ...
(, ), IMHO, , ... , - ... ...;)
Greetz
back2dos