Hello,
I have this “left half of a door” image in my library, and I did cloned
the same image to the stage, making it “right half of a door”… but really would like to know what would be the right way of doing such things…
Simply do:
var doorLeft = new Door();
doorLeft.x = 316;
doorLeft.y = 194;
addChild(doorLeft);
var doorRight = new Door();
doorRight.x = 502;
doorRight.y = 194;
doorRight.scaleX *= -1;
addChild(doorRight)
or more like:
var doorLeft = new Door();
doorLeft.x = 316;
doorLeft.y = 194;
addChild(doorLeft);
function cloneDoor(source:DisplayObject,sourceX:Number,sourceY:Number):void{
var objectClass:Class = Object(source).constructor;
var doorRight:Sprite = new objectClass() as Sprite;
source.parent.addChild(doorRight);
doorRight.x = sourceX;
doorRight.y = sourceY;
doorRight.scaleX *= -1;
}
cloneDoor(doorLeft,502,194);
Should I just make new instance, or do it through function? Is there a memory issues in one of those, what hurts Flash more?