PDA

View Full Version : removeMovieClip issues; works but affects local var in function


vee
12-29-2006, 07:18 PM
:eek:I never am able to get removeMovieClip to work just as I would like it to. I have a menu which is built by a function. The menu pops up inside a scrollPane (br_sp). What I wanted to do is have each of my buttons in the _root swf be able to break down the menu that exists then, rebuild using my common function (after they have been broken down). I tried targeting a unique substring to pick only the last menu created to break down. This works but .....my function (that creates each menu and is common to all buttons) has a local var which is affected by the removing of the clips.

my removing code:
ActionScript Code:
for (o in _root.br_sp.content) { if (typeof (_root.br_sp.content[o]) == "movieclip" and _root.br_sp.content[o]._name.substring(5, 6) == itemMCID) { _root.br_sp.content.removeMovieClip(o); //trace(o); } }


now within my function the var that gets affected by the code above:
ActionScript Code:
var tmp_mc = _root.br_sp.content.attachMovie("item_mc", "item_" + itemMCID + "_" + +i + "_mc", i, {_y:0});


I'm thinking that i am going about this all wrong. Maybe it would be best to reuse (if theres clips there already) the clips and add or subtract as necessary... but im not quite sure how to do that, so I thought i was taking the easy way.:confused: