I have the code below, which essentially is the beginning of a personal physical computing project that will use an offline hardware to control the flash app like the an etch a sketch.
The code below, when the user hits the left, right, up down the cursor draws a line to that location. I want a reset button that essentially clears the line, and moves the cursor back to the middle of the screen. I have the ResetSketch() function that is suppose to clear the lines, but it doesn’t work.
_root.createEmptyMovieClip ("SketchMC", 1);
SketchMC.lineStyle (1, 0x000000, 100);
MoveSpce = 2;
Xpos = Stage.width/2;
Ypos = Stage.height/2;
SketchMC.moveTo (Xpos, Ypos);
MoveLine = false;
keyListener = new Object();
keyListener.onKeyDown = function() {
//x = String.fromCharCode(Key.getAscii())
if(Key.getCode() == Key.RIGHT){
Xpos = Xpos + MoveSpce;
MoveLine = true;
}
else if(Key.getCode() == Key.LEFT){
Xpos = Xpos - MoveSpce;
MoveLine = true;
}
else if(Key.getCode() == Key.UP){
Ypos = Ypos - MoveSpce;
MoveLine = true;
}
else if(Key.getCode() == Key.DOWN){
Ypos = Ypos + MoveSpce;
MoveLine = true;
}
if(MoveLine){
SketchMC.lineTo (Xpos,Ypos);
MoveLine = false;
}
};
Key.addListener(keyListener);
function ResetSketch(){
_root.SketchMC.removeMovieClip();
_root.createEmptyMovieClip ("SketchMC", 1);
}