Reputation: 13476
So I duplicate a MovieClip
that is on the Stage and created through the IDE like so:
duplicateMovieClip(timeData, "nextTimeData", timeData._parent.getNextHighestDepth());
This works great, but when I go to delete the MovieClip
like so:
trace(timeData);
removeMovieClip(timeData);
trace(timeData);
trace(nextTimeData);
It refuses to be deleted and trace(timeData)
outputs _level0.timeData
before and after removeMovieClip(timeData)
Why would this be happening?
EDIT: According to the answers and the flash documentation MovieClips created in the IDE have a negative depth and removeMovieClip()
silently fails in removing MovieClips with a negative depth.
So I am now attaching timeData
from the library like so:
attachMovie("timeData", "timeData", this.getNextHighestDepth());
timeData._x = 530;
timeData._y = 492.5;
However it is showing the same behaviour.
Upvotes: 1
Views: 7191
Reputation: 6644
It sounds like you created your movieclip using the IDE (Flash environment).
NOTE: Movieclips created using the IDE actually have negative depths by default.
removeMovieClip will only remove clips at positive depths.
If you want to delete your movieclip that you positioned using the IDE, you'll need to first use swapDepths to bring your movieclip into "positive" depths. After that, you should be able to remove it no problem.
Upvotes: 1
Reputation: 3642
YES, there is a way:
in the IDE click on the MovieClip instance, and put this code in the AS panel:
onClipEvent(load)
{
this.swapDepths(0);
this.removeMovieClip();
}
to be able to use removeMovieClip()
on an instance it needs to have a proper depth, that's why you need to set the depth first. Bang, magic :)
Of course you can use this code and alter it, so you can control this movieClip from other instances or timelines.
Cheers, Rob
Upvotes: 3
Reputation: 1
In AS2 object created through IDE cannot be removed by removeMovieClip. That's said in official as2 help. But duplicated one can be removed with this function. You'd better take your timeData from the library using code, not manually
Upvotes: -1
Reputation: 5478
You cannot remove a MovieClip that you created by hand from the IDE using removeMovieClip()
:
Removes a movie clip instance created with duplicateMovieClip(), MovieClip.duplicateMovieClip(), MovieClip.createEmptyMovieClip(), or MovieClip.attachMovie().
From http://help.adobe.com/en_US/AS2LCR/Flash_10.0/help.html?content=00001349.html
You could remove nextTimeData
this way, but you'll never be able to remove timeData
unless you create it from AS as well.
Upvotes: 0