# Help clone object from library as3

**URL:** <https://forum.kirupa.com/t/help-clone-object-from-library-as3/326409>\
**Category:** flash\
**Created:** [December 12, 2011, 4:26pm UTC](https://forum.kirupa.com/t/help-clone-object-from-library-as3/326409 "2011-12-12T16:26:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![duchman](https://avatars.discourse-cdn.com/v4/letter/d/91b2a8/32.png) [@duchman](https://forum.kirupa.com/u/duchman)\
**Post date:** [December 12, 2011, 4:26pm UTC](https://forum.kirupa.com/t/help-clone-object-from-library-as3/326409/1 "2011-12-12T16:26:08Z")

</div>

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:

```auto
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:

```auto
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?
