Actionscript:
-
// set multiple properties of an Object
-
function setProps(o:*, props:Object):void{
-
for (var key:String in props){
-
o[key] = props[key];
-
}
-
}
-
-
// example:
-
-
var s:Sprite = new Sprite();
-
s.graphics.beginFill(0);
-
s.graphics.drawRect(0,0,10,10);
-
addChild(s);
-
-
// set some properties
-
setProps(s, {x:100, y:100, scaleX:2, scaleY:2, rotation:45});
This was inspired by tweening engines like TweenLite.
Basically the same thing using a with statement:
Actionscript:
-
with(s) x = 100, y = 100, scaleX = 2, scaleY = 2, rotation = 45;