# Unlimited movieclip object stack and drag

**URL:** <https://forum.kirupa.com/t/unlimited-movieclip-object-stack-and-drag/308283>\
**Category:** Uncategorized\
**Created:** [April 20, 2010, 3:28pm UTC](https://forum.kirupa.com/t/unlimited-movieclip-object-stack-and-drag/308283 "2010-04-20T15:28:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![robinhoodisback](https://avatars.discourse-cdn.com/v4/letter/r/a8b319/32.png) [@robinhoodisback](https://forum.kirupa.com/u/robinhoodisback)\
**Post date:** [April 20, 2010, 3:28pm UTC](https://forum.kirupa.com/t/unlimited-movieclip-object-stack-and-drag/308283/1 "2010-04-20T15:28:27Z")

</div>

Hello Everyone,  
I’m new to actionscript and im currently building a webpage. inside the page im going to run a simple flash application but im struggling some with a certain part of the code. basically i want a unlimited deck of cards. and i want to be able to drag the cards all over the screen. i have the dragging code down, but i can figure out how to make an unlimited amount of movieclip objects in a stack. this is what i have now

> reset\_btn.addEventListener(MouseEvent.CLICK, resetbuttonClicked);

function resetbuttonClicked(event:MouseEvent):void  
{  
trace(“Reset Button Clicked!”);  
gotoAndStop(1);  
}

/_Alignment_/

card\_mc.x = 50;

card\_mc.y = stage.stageHeight - 200;

/_Dragging – START_/  
card\_mc.addEventListener(MouseEvent.MOUSE\_DOWN,dragObject);

function dragObject(event:MouseEvent):void  
{  
trace(“Dragging Card”);  
event.target.startDrag();  
event.target.removeEventListener(MouseEvent.MOUSE\_DOWN,dragObject);  
event.target.addEventListener(MouseEvent.MOUSE\_UP,dropObject);  
}

function dropObject(event:MouseEvent):void  
{  
trace(“Dropping Card”);  
event.target.stopDrag();  
event.target.removeEventListener(MouseEvent.MOUSE\_UP,dropObject);  
event.target.addEventListener(MouseEvent.MOUSE\_DOWN,dragObject);

}  
/_Dragging – END_/

card\_mc.buttonMode = true;  
stop();
