# Incrementing values to a variable

**URL:** <https://forum.kirupa.com/t/incrementing-values-to-a-variable/323125>\
**Category:** Uncategorized\
**Created:** [June 17, 2011, 8:25pm UTC](https://forum.kirupa.com/t/incrementing-values-to-a-variable/323125 "2011-06-17T20:25:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![joselalupa](https://avatars.discourse-cdn.com/v4/letter/j/5fc32e/32.png) [@joselalupa](https://forum.kirupa.com/u/joselalupa)\
**Post date:** [June 17, 2011, 8:25pm UTC](https://forum.kirupa.com/t/incrementing-values-to-a-variable/323125/1 "2011-06-17T20:25:43Z")

</div>

i’m trying to add values to a variable…  
i have this:

```auto

var myMC:MovieClip = new MovieClip();
myMC.graphics.beginFill(0x00ff00);
myMC.graphics.drawRect(0, 0, 400, 300);
myMC.graphics.endFill();
myMC.x = myMC.y = 00;
addChild(myMC);

myMC.addEventListener(MouseEvent.MOUSE_DOWN, startMotionHandler);

function startMotionHandler($evt:MouseEvent):void {
    
}

myMC.addEventListener(MouseEvent.MOUSE_DOWN, drag);
function drag(e:MouseEvent){
myMC.startDrag();

}
myMC.addEventListener(MouseEvent.MOUSE_UP, drop);
function drop(e:MouseEvent){
myMC.stopDrag();
myMC.x = myMC.y = 00;

}

```

a simple drag and drop on a MC.  
i would like to store the X displacement when i drag. let say i have 30 in a variable wich store x position of myMC, if i drag the MC 200 units the variable should read 230 and so on. i hope my explanation is clear.  
any help?? don’t have a clue on this.

\*it should be done at runtime.
