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);
}
}