attachMovie/createEmptyMoiveClip & moving between frames

Why is it when I attach a movie to the stage using the attachMovie function or create a movie clip dynamically using createEmptyMovieClip and the drawing API the movie clips stays visible when I change between frames.

Example Code – Frame 1

_root.attachMovie(“mc”,“mc”,2)
_root.createEmptyMovieClip(“square”,1)

stop();

square.moveTo(0,0)
square.lineStyle(1,0,100);
square.lineTo(100,0)
square.lineTo(100,100)
square.lineTo(0,100)
square.lineTo(0,0)

onMouseDown = function()
{
gotoAndStop(2); // Still visible?
}

So why do they stay visible when I change frames?

  1. You cannot move thru frames in the mcs which are created dynamically. They have only first frame. So using gotoAndStop or play etc. things won’t work for the mcs created dynamically (i mean using createEmptyMovieClip).

2.If you are using this code in MX or MX 2004 you need to specify which object fires the event (her mousedown)
so it should be something like


this.onMouseDown=function()
{
square.gotoAndStop(2);//which won't work logically coz it's dynamically 
//created
mc.gotoAndStop(2);//this will work provided you have frame 2 in mc
}