PDA

View Full Version : removeMovieClip not working


GooMoo
01-26-2009, 11:45 PM
Forgive me I'm tired and embaressed that I can't figure this out...

So the first time this code is executed (ie the Next button is pressed), it works just fine. The second time this function is executed though, the question_mc does not get removed.

function nextQuestion(){
delete visQuestion;
_level0.question_mc.swapDepths(999);
_level0.question_mc.removeMovieClip();
if(_level0.question_mc){
trace('still here');
for(a in _level0.question_mc){
trace("question number:"+currentQuestion+" value:"+_level0.question_mc[a]+" type of:"+typeof _level0.question_mc[a]+" with name:"+_level0.question_mc[a]._name);
}
trace('end objects');
} else {
trace('removed');
}...

visQuestion is the object created by a class that creates the question_mc on the stage. So the first time around the trace is just "removed". The second time around the trace returns:

still here
question number:1 value:8429 type of:number with name:undefined
question number:1 value:_level0.question_mc.next_mc type of:movieclip with name:next_mc
question number:1 value:_level0.question_mc.option_mc0 type of:movieclip with name:option_mc0
question number:1 value:_level0.question_mc.option_mc1 type of:movieclip with name:option_mc1
question number:1 value:_level0.question_mc.option_mc2 type of:movieclip with name:option_mc2
question number:1 value:_level0.question_mc.option_mc3 type of:movieclip with name:option_mc3
end objects

The option_mc# clips are from the previous question_mc that should have been removed. The number returned, without a name, I have no idea where it's coming from. The question_mc is being created on the stage by a class, like this:

class QuestionLayout{

public function QuestionLayout(myQuestion,currentQuestion){
var question_mc:MovieClip = _level0.createEmptyMovieClip("question_mc", _level0.getNextHighestDepth());

I'm hoping maybe someone has an idea what might typically cause something like this to happen? I'd give you the whole code, but I wouldn't expect anyone to surf through 600 lines.

GooMoo
01-27-2009, 03:18 AM
Perhaps this doesn't belong in the newbie section after all. I've altered my class and next button function so that the name of the question_mc is dynamically generated.

function nextQuestion(){
delete visQuestion;
oldQuestion = eval('question_mc'+currentQuestion);
oldQuestion.swapDepths(999);
oldQuestion.removeMovieClip();
trace(oldQuestion);
if(oldQuestion){
trace('still here');
for(a in oldQuestion){
trace("question number:"+currentQuestion+" value:"+oldQuestion[a]+" type of:"+typeof oldQuestion[a]+" with name:"+oldQuestion[a]._name);
}
trace('end objects');
} else {
trace('removed');
}...

I understand that "oldQuestion" is a variable and will still exist even though the MC it represents is gone. Tracing oldQuestion the first time shows nothing, but the second time shows "_level0.question_mc1", the name of the clip that should have been removed.

At least now I am able to go onto the third question in the series, but the 4th question (which is the same type as the second) also stays behind even though the MC should have been removed. Both of these question MC's contain ComboBox ui components, is it possible that these components are stopping the containing MC from being removed?