Skip to main content
Mr. Baker the Shoe Maker
Inspiring
February 28, 2013
Answered

TypeError: Error #1006 - Removing MovieClip from the stage

  • February 28, 2013
  • 2 replies
  • 2120 views

I have a movie clip that is called to the stage and once the movieclip is finished it calls a function that removes it from the stage. The code works but I get an error message about 4 seconds after the movie clip ends.

Here’s the error message:

TypeError: Error #1006: exitWordMicroscopic is not a function.

                at ASvocabulary_microscopic/frame110()[ASvocabulary_microscopic::frame110:1]

Here’s the stage code:

//************************Removes the movieclip from the stage and enables the button.*************************

function exitWordMicroscopic():void

{

                bnt_vocab_microscopic.mouseEnabled = true;

                removeChild(word_Microscopic);

}

//******************************Stage buttons**************************************

stage.addEventListener(MouseEvent.MOUSE_DOWN, goButtonsHomeRead_1);

function goButtonsHomeRead_1(event:MouseEvent):void

{

                //Vocabulary buttons

                if (event.target == bnt_vocab_microscopic)

                {

                                bnt_vocab_microscopic.mouseEnabled = false;

                                SoundMixer.stopAll();

                                addChild(word_Microscopic);

                                word_Microscopic.x = 47;

                                word_Microscopic.y = 120;

                }

}

Here’s the code inside the movie clip. This is what the error message is referring to:

//****************** Calls function to remove itself from the stage****************************

Object(parent).exitWordMicroscopic();

What am I doing wrong?

This topic has been closed for replies.
Correct answer Ned Murphy

I added an empty movieclip to the stage and and during runtime I add the movieclip inside the empy movieclip.

mc_EmpytMovie_Micro.addChild(word_Microscopic);

In the movieclip that is added to the movieclip how do I communicate back from that movieclip to run the function to remove the movieclip (word_Microscopic)? Currently, I am using:

Object(parent).exitWordMicroscopic();

This function removes the movieclip from the stage.

function exitWordMicroscopic():void

{

    bnt_vocab_microscopic.mouseEnabled = true;

    removeChild(word_Microscopic);

}


There is a more OOP proper way to do this, but for the moment you could use...

Object(parent.parent).exitWordMicroscopic();

function exitWordMicroscopic():void

{

    bnt_vocab_microscopic.mouseEnabled = true;

    mc_EmpytMovie_Micro.removeChild(word_Microscopic);

}

2 replies

Participant
March 2, 2013

was experiencing the same problem, thanks guys for the valuable tech suport

Ned Murphy
Legend
February 28, 2013

Does the movieclip take about 4 seconds to play thru?  I am guessing that it is playing again and when it is done it once again tries to target the parent... only the second time around it has no parent with such a function.

Mr. Baker the Shoe Maker
Inspiring
February 28, 2013

Yes it does take four seconds.

Ned Murphy
Legend
February 28, 2013

You need to stop the movieclip from repeating whatever it does so that it does not execute that request to the parent again. 

When you use the removeChild method you are only removing the targeted object from the display, it still exists and still functions if left to do so.

One other thing you could do after you remove it using removeChild is to null any reference to it...

     removeChild(word_Microscopic);

     word_Microscopic =  null;