# Moving a Shape made by graphic class drawing

**URL:** <https://forum.kirupa.com/t/moving-a-shape-made-by-graphic-class-drawing/325295>\
**Category:** flash\
**Created:** [October 7, 2011, 2:48pm UTC](https://forum.kirupa.com/t/moving-a-shape-made-by-graphic-class-drawing/325295 "2011-10-07T14:48:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![DSlish](https://avatars.discourse-cdn.com/v4/letter/d/ac91a4/32.png) [@DSlish](https://forum.kirupa.com/u/DSlish)\
**Post date:** [October 7, 2011, 2:48pm UTC](https://forum.kirupa.com/t/moving-a-shape-made-by-graphic-class-drawing/325295/1 "2011-10-07T14:48:50Z")

</div>

I drew a line (stepVoltage) in a fla using the graphics class. Once drawn, I want to move it to the right in an update function, but am having trouble. I tride just moving the line with statements like “stepVoltage.x = newX; stepVoltage.y = newY;” but this didn’t work. Then I tried to delete the previous line and draw a new one with a clear () function (see below) but this blocked the next drawn line from showing up.

Any ideas?

The code:

var stepVoltage:Shape = new Shape ();  
stepVoltage.graphics.lineStyle(2,0x000000);  
addChild (stepVoltage);

later:

function startExp(event:MouseEvent):void  
{ newXone = 543;  
newYone = 75;  
stepVoltage.graphics.moveTo(541, 125);  
stepVoltage.graphics.lineTo(newXone, newYone);  
addEventListener(Event.ENTER\_FRAME, updateTwo);  
}

function updateTwo (e:Event):void  
{ if (newXone \> 337)  
{  
newXone = newXone-4;  
stepVoltage.graphics.clear();  
stepVoltageLine.graphics.lineStyle(2,0x000000);  
stepVoltage.graphics.moveTo(newXone, 125);  
stepVoltage.graphics.lineTo(newXone, newYone);  
}  
}
