03.05.2013 Views

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Removes a movie clip instance created with duplicateMovieClip(),<br />

MovieClip.duplicateMovieClip(), MovieClip.createEmptyMovieClip(), or<br />

MovieClip.attachMovie().<br />

This method does not remove a movie clip assigned to a negative depth value. Movie clips<br />

created in the authoring tool are assigned negative depth values by default. To remove a movie<br />

clip that is assigned to a negative depth value, first use MovieClip.swapDepths() to move<br />

the movie clip to a positive depth value.<br />

Note: If you are using V2 components, <strong>and</strong> use MovieClip.getNextHighestDepth()<br />

instead of the DepthManager class to assign depth values, you may find that<br />

removeMovieClip() fails silently. When any V2 component is used, the DepthManager class<br />

automatically reserves the highest (1048575) <strong>and</strong> lowest (-16383) available depths for cursors<br />

<strong>and</strong> tooltips. A subsequent call to getNextHighestDepth() returns 1048576, which is<br />

outside the valid range. The removeMovieClip() method fails silently if it encounters a<br />

depth value outside the valid range. If you must use getNextHighestDepth() with V2<br />

components, then you can use swapDepths() to assign a valid depth value or use<br />

MovieClip.unloadMovie() to remove the contents of the movie clip. Alternatively, you can<br />

use the DepthManager class to assign depth values within the valid range.<br />

You can extend the methods <strong>and</strong> event h<strong>and</strong>lers of the MovieClip class by creating a subclass.<br />

Example<br />

Each time you click a button in the following example, you attach a movie clip instance to the<br />

Stage in a r<strong>and</strong>om position. When you click a movie clip instance, you remove that instance<br />

from the SWF file.<br />

function r<strong>and</strong>Range(min:Number, max:Number):Number {<br />

var r<strong>and</strong>Num:Number = Math.round(Math.r<strong>and</strong>om()*(max-min))+min;<br />

return r<strong>and</strong>Num;<br />

}<br />

var bugNum:Number = 0;<br />

addBug_btn.onRelease = addBug;<br />

function addBug() {<br />

var thisBug:MovieClip = this._parent.attachMovie("bug_id",<br />

"bug"+bugNum+"_mc", bugNum,<br />

{_x:r<strong>and</strong>Range(50, 500), _y:r<strong>and</strong>Range(50, 350)});<br />

thisBug.onRelease = function() {<br />

this.removeMovieClip();<br />

};<br />

bugNum++;<br />

}<br />

464 ActionScript classes

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!