Hi,
On frame 2 of my movie clip, if I click a button called DrawLine, it draws a line. Something like this:
var lineholder4:MovieClip = new MovieClip();
lineholder4.graphics.clear();
lineholder4.graphics.lineStyle(2, 16711935, 1000);
addChild(lineholder4);
lineholder4.graphics.moveTo(…
lineholder4.graphics.lineTo(…
This part work fine. However, if I click the button to draw the line, and then go back to frame 1 via my navigation buttons, the line is stil there. And I want to clear it. I can clear it using this:
lineholder4.graphics.clear();
But obviously, if I have this on frame 1 before I get to frame 2, the MC wont exist and I’ll get a ‘object null’ error. So I’ve tried EVERYTHING to oversome this…well…everything to my knowledge…but I keep getting errors on the ‘If’ part. Please help! I’ve tried:
if (lineholder4.stage) {
lineholder4.graphics.clear();
}
if(stage.contains(lineholder4)){
lineholder4.graphics.clear();
}
if (this.getChildByName(lineholder4) == null) {
lineholder4.graphics.clear();
}
Is there another way to accomplish this?