PDA

View Full Version : Adding/Removing components...



iloveitaly
November 18th, 2004, 08:46 AM
I am working with components for the first time....
Now, currently, i am creating components with the attachMovie(), it works, but is it the right way to do it? The reason i ask is because i cant remove the components with removeMovieClip(), how do you remove them?
Thanks! :thumb:

moonless_planet
November 18th, 2004, 10:10 AM
should work actually. Are you addressing the MC right with the name you gave it when you attached it?

If you can't figure it out attach your fla (MX format, please).

iloveitaly
November 18th, 2004, 01:17 PM
should work actually. Are you addressing the MC right with the name you gave it when you attached it?

If you can't figure it out attach your fla (MX format, please).
Hmm, i would attatch in MX for u but i am using AS2 classes...

Anyways, i figured out the problem...
if you attach the moveclip at the depth specified by MC.getNextHighestDepth() it DOESN'T REMOVE, but if i use 0 as the depth it removes fine.
for example i am using this code:


test = _root.createObject('ProgressBar', 'testload', _root.getNextHighestDepth(), {_x:50, _y:50})
removeMovieClip(test)

but this does not work! If i simple add a test.swapDepths(1) then it works!?
The _root.getNextHighestDepth() returns a 1048576 with ABSOLUTLY NOTHING on the stage. I guess i am not the only one with this problem (http://www.kirupaforum.com/forums/showthread.php?t=61986&highlight=components+remove). In addition if i create a holder movieClip and then attach the component to that it works fine, as long as i dont specifie the movieClips depth with _root.getNextHighestDepth(). So basicilly that function doesn't work correctly for the root!!!!!
<rant>
Ok, now i am no genius, i'm 15 and havent even finished algebra II, but comon macromedia you cant make that function work correctly?!
This simple prototype i made works for the root and solves the whole problem i was having:


MovieClip.prototype.getHighestDepth = function() {
var counter = 0;
while(this.getInstanceAtDepth(counter)!=undefined) {
counter++;
}
return counter;
}

Why doesn't macromedias function work? This one works fine....
</rant>
Hopefully someone with the same problem can find this post and doesn't waste 2 hours trying to figure why the heck it doesn't work.