Flash: Final solution -KillerBeacon
May 13th, 2005 by LuisFinally I have find a clean solution in order to remove from the stage TextFields that were not created with createTextField() or movie clip instances that were not created with duplicateMovieClip(), MovieClip.duplicateMovieClip(), or MovieClip.attachMovie().
KILLER BEACON:
Actionscript:
- /**
- * KillerBeacon, version 1
- * @class: KillerBeacon
- * @author: luis@lessrain.com
- * @version: 1.0
- */
- import lessrain.lib.utils.DepthManager;
- class KillerBeacon
- {
- private static var _oInstance:KillerBeacon = null;
- function KillerBeacon (){}
- public static function getInstance ():KillerBeacon
- {
- if (_oInstance == null) {
- KillerBeacon._oInstance = new KillerBeacon ();
- }
- return KillerBeacon._oInstance;
- }
- public function destroy (o:Object):Void
- {
- var dm:DepthManager = DepthManager.getInstance ();
- var target:MovieClip = o._parent;
- var nextDepth:Number=dm.getNextDepth (target)
- var tempKiller:MovieClip = target.createEmptyMovieClip ('killer', nextDepth);
- tempKiller.swapDepths (o);
- (typeof (o) == 'movieclip') ? o.removeMovieClip () : o.removeTextField ();
- // remove killer mc
- tempKiller.swapDepths (nextDepth);
- tempKiller.removeMovieClip ();
- }
- }
USAGE:
Actionscript:
- var killer=KillerBeacon.getInstance ().destroy(myTextField);
NOTE:
If you export the movie as flash 7 there is not need of the DepthManager utility , you can simply use the built in movieclip method getNextHighestDepth()
Actionscript:
- var tempKiller:MovieClip = target.createEmptyMovieClip ('killer',target.getNextHighestDepth());


August 16th, 2005 at 9:58 am
[…] ith duplicateMovieClip(), MovieClip.duplicateMovieClip(), or MovieClip.attachMovie() using swapDepths(). Small DepthManager Utility to use when you export as Flash 6: ActionScript: /** ************ […]
October 13th, 2005 at 10:36 pm
Hi there, I was taking a look at your code when I realize that it is impossible to use the build-in depthmanager class, because it doesnt have a “getNextDepth()” method.
I guess it might be a method of you class.
Is there any link to get your depthmanager approuch?
thanks in advance. Diego.
October 14th, 2005 at 11:31 am
The build in method uses getNextHighestDepth() instead of getNextDepth(), and you can see the depthManager class here:
http://www.blog.lessrain.com/?p=33