Ted Patrick > { Events & Community } > Adobe Systems


Using removeMovieClip with timeline placed asset

When I was exploring MovieClip depth management, I ran into a quirk in the Flash player. It seems that depths are negative for timeline content and positive for assets added dynamically (attachMovie,createChild,etc).&

So how do you remove content added on the timeline?

First you need to move it to a positive depth and then delete it. removeMovieClip only works with positive depth up to a high range.

myTimelineContent.swapDepths(10000) //yes you can pass a # depth ;)
myTimelineContent.removeMovieClip()


What is interesting with Timeline content is that you begin to see how keyframes are actually implemented. A Keyframe at runtime is a unique asset at a negative depth, the stacking order correlates to the layers in the Timeline view in Flash but depths are assigned dynamically from -16383 and higher. When the player overwrites a depth, the content is replaced making what seems to be a seamless transition to the next frame..

What gets really interesting is that you can pop keyframes to a higher depth and the frames are not overwritten by new keyframes. This was very enlightening for me when I first discovered this quirk. Actually in looking at duplicateMovieClip, it makes sense to see that this copies content of one depth to another where attachMovie adds a library asset directly to a depth.

Ahhh low level flash, nothing like understanding what the player is actually doing at runtime.

Cheers and happy 4th!

Ted ;)

5 Responses to “ Using removeMovieClip with timeline placed asset ”

  1. # Blogger BIT-101

    the use of swapDepths to remove is kind of old news to a lot of us, but that's pretty fascinating about the keyframe stuff.  

  2. # Anonymous erikbianchi

    If you're publishing to 7 you can also use:

    some_mc.swapDepths(this.getNextHighestDepth());
    some_mc.removeMovieClip();

    -erik  

  3. # Anonymous JesterXL

    That won't work on _root Erik because of researved being in the highest possible removeable depth.  

  4. # Anonymous Robert Penner

    I don't understand what you're saying about keyframes. What do they have to do with the depth? The two are independent dimensions as far as I understand.  

  5. # Blogger Ted Patrick

    Robert,

    My point is that keyframes are implemented using depth. You can actually move Keyframe content without a container to a higher depth. Here is an example that attempts to isolate the behavior. In the example, a movieClip displaces a keyframe in depth. Movieclips are isolated to even negative depths where keyframe content is isolated on odd depths. If you switch the swap depth value to an odd value, it will actually break the keyframe logic of the player at runtime.

    http://www.powersdk.com/sample/swapKeyframe.fla

    It is a very odd quirk in the player but is probably part of the SWF legacy. I know that in F3-F4 Textfields were required to sit on odd depths as this allowed them functionality that regualr depths did not have.

    I guess I just like to know how things work.

    Cheers,

    ted ;)  

Post a Comment



© 2008 Ted On Flash