Hello all,
I have a diagram with three buttons that when clicked, draws a line from that button to the corresponding movieclip on the stage. All this works fine but I’d like to build in a toggle button so I can turn each line off in any order. I’m having trouble understanding how to reference each shape that’s been draw on the stage so I can remove it. Here is my code, any help would be greatly appreciated.
Thanks.
var btnArray:Array = new Array(btn1, btn2, btn3);
var spotArray:Array = new Array(hotspot1, hotspot2, hotspot3);
var togArray:Array = new Array(tog1, tog2, tog3);
for (var i:Number = 0; i<3; i++) {
btnArray*.addEventListener(MouseEvent.MOUSE_DOWN, buttonDown);
togArray*.addEventListener(MouseEvent.MOUSE_DOWN, toggleDown);
}
function buttonDown(e:MouseEvent):void {
for (var i:Number = 0; i<btnArray.length; i++) {
if (e.target == btnArray*) {
var line:Shape = new Shape();
line.graphics.lineStyle(2, 0xCC0000, 1, false, LineScaleMode.HORIZONTAL, CapsStyle.ROUND, JointStyle.ROUND, 1);
line.graphics.moveTo(btnArray*.x, btnArray*.y);
line.graphics.lineTo(spotArray*.x, spotArray*.y);
addChild(line);
}
}
}
function toggleDown(e:MouseEvent):void {
trace("hit");
}