03.05.2013 Views

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

var triangle:MovieClip = this.createEmptyMovieClip("triangle",<br />

this.getNextHighestDepth());<br />

triangle._x = triangle._y = 50;<br />

triangle.lineStyle(3, 0xFFCC00);<br />

triangle.lineTo(0, 30);<br />

triangle.lineTo(50, 0);<br />

triangle.lineTo(0, 0);<br />

triangle.endFill();<br />

triangle.opaqueBackground = 0xCCCCCC;<br />

If your SWF file includes a version 2 component, use the version 2 components'<br />

DepthManager class instead of the MovieClip.getNextHighestDepth() method, which is<br />

used in this example.<br />

See also<br />

cacheAsBitmap (MovieClip.cacheAsBitmap property), hitTest (MovieClip.hitTest<br />

method)<br />

_parent (MovieClip._parent property)<br />

public _parent : MovieClip<br />

A reference to the movie clip or object that contains the current movie clip or object. The<br />

current object is the object that references the _parent property. Use the _parent property to<br />

specify a relative path to movie clips or objects that are above the current movie clip or object.<br />

You can use _parent to move up multiple levels in the display list, as in the following code:<br />

this._parent._parent._alpha = 20;<br />

Availability: <strong>ActionScript</strong> 1.0; Flash Player 5<br />

Example<br />

The following example traces the reference to a movie clip <strong>and</strong> its parent timeline. Create a<br />

movie clip with the instance name my_mc, <strong>and</strong> add it to the main timeline. Add the following<br />

<strong>ActionScript</strong> to your FLA or AS file:<br />

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

trace("You clicked the movie clip: "+this);<br />

trace("The parent of "+this._name+" is: "+this._parent);<br />

}<br />

When you click the movie clip, the following information appears in the Output panel:<br />

You clicked the movie clip: _level0.my_mc<br />

The parent of my_mc is: _level0<br />

924 <strong>ActionScript</strong> classes

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

Saved successfully!

Ooh no, something went wrong!