View comments | RSS feed

MovieClip class

Availability

Flash Player 3.

Description

The methods for the MovieClip class provide the same functionality as actions that target movie clips. There are also additional methods that do not have equivalent actions in the Actions toolbox in the Actions panel.

You do not need to use a constructor method to call the methods of the MovieClip class; instead, you reference movie clip instances by name, using the following syntax:

my_mc.play();
my_mc.gotoAndPlay(3);

You can extend the methods and event handlers of the MovieClip class by creating a subclass. For more information, see "Assigning a class to a movie clip symbol" in Using ActionScript in Flash.

Method summary for the MovieClip class

Method Description
MovieClip.attachAudio()

Captures and plays local audio from the microphone hardware.

MovieClip.attachMovie()

Attaches a SWF file or movie clip in the library.

MovieClip.createEmptyMovieClip()

Creates an empty movie clip.

MovieClip.createTextField()

Creates an empty text field.

MovieClip.duplicateMovieClip()

Duplicates the specified movie clip.

MovieClip.getBounds()

Returns the minimum and maximum x and y coordinates of a SWF file in a specified coordinate space.

MovieClip.getBytesLoaded()

Returns the number of bytes loaded for the specified movie clip.

MovieClip.getBytesTotal()

Returns the size of the movie clip, in bytes.

MovieClip.getDepth()

Returns the depth of a movie clip.

MovieClip.getInstanceAtDepth()

Returns the movie clip instance from a particular depth if it exists.

MovieClip.getNextHighestDepth()

Returns the next available depth that can be passed to other methods. This ensures that Flash renders the movie clip in front of all other objects in the current movie clip.

MovieClip.getSWFVersion()

Returns an integer that indicates the Flash Player version for which the movie clip was published.

MovieClip.getTextSnapshot()

Returns a TextSnapshot object that contains the text in the static text fields in the specified movie clip.

MovieClip.getURL()

Retrieves a document from a URL.

MovieClip.globalToLocal()

Converts Stage coordinates to the local coordinates of the specified movie clip.

MovieClip.gotoAndPlay()

Sends the playhead to a specific frame in the movie clip and plays the movie clip.

MovieClip.gotoAndStop()

Sends the playhead to a specific frame in the movie clip and stops the movie clip.

MovieClip.hitTest()

Returns true if bounding box of the specified movie clip intersects the bounding box of the target movie clip.

MovieClip.loadMovie()

Loads the specified SWF or JPEG file into the movie clip.

MovieClip.loadVariables()

Loads variables from a URL or other location into the movie clip.

MovieClip.localToGlobal()

Converts local coordinates of the movie clip to the global Stage.

MovieClip.nextFrame()

Sends the playhead to the next frame of the movie clip.

MovieClip.play()

Plays the specified movie clip.

MovieClip.prevFrame()

Sends the playhead to the previous frame of the movie clip.

MovieClip.removeMovieClip()

Removes the movie clip from the Timeline if it was created with duplicateMovieClip(), MovieClip.duplicateMovieClip(), or MovieClip.attachMovie().

MovieClip.setMask()

Sets a movie clip as the mask for the specified movie clip.

MovieClip.startDrag()

Specifies a movie clip as draggable and begins dragging the movie clip.

MovieClip.stop()

Stops the currently playing movie clip.

MovieClip.stopDrag()

Stops the dragging of any movie clip that is being dragged.

MovieClip.swapDepths()

Swaps the depth level of two movie clips.

MovieClip.unloadMovie()

Removes a SWF file that was loaded with MovieClip.loadMovie().

Drawing method summary for the MovieClip class

Method Description
MovieClip.beginFill()

Begins drawing a fill for the specified movie clip.

MovieClip.beginGradientFill()

Begins drawing a gradient fill for the specified movie clip.

MovieClip.clear()

Removes all the drawing commands associated with a movie clip instance.

MovieClip.curveTo()

Draws a curve using the current line style.

MovieClip.endFill()

Ends the fill specified by MovieClip.beginFill() or MovieClip.beginGradientFill().

MovieClip.lineStyle()

Defines the stroke of lines created with the MovieClip.lineTo() and MovieClip.curveTo() methods.

MovieClip.lineTo()

Draws a line using the current line style.

MovieClip.moveTo()

Moves the current drawing position to specified coordinates.

Property summary for the MovieClip class

Property Description
MovieClip._alpha

The transparency value of a movie clip instance.

MovieClip._currentframe

Read-only; the frame number in which the playhead is currently located.

MovieClip._droptarget 

Read-only; the absolute path in slash syntax notation of the movie clip instance on which a draggable movie clip was dropped.

MovieClip.enabled

A Boolean value that indicates whether a movie clip is enabled.

MovieClip.focusEnabled

A Boolean value that enables a movie clip to receive focus.

MovieClip._focusrect

A Boolean value that indicates whether a focused movie clip has a yellow rectangle around it.

MovieClip._framesloaded

Read-only; the number of frames that have been loaded from a streaming SWF file.

MovieClip._height

The height of a movie clip instance, in pixels.

MovieClip.hitArea

A reference to a movie clip that serves as the hit area for another movie clip.

MovieClip._lockroot

The specification of what _root refers to when a SWF file is loaded into a movie clip.

MovieClip.menu

An object that associates a ContextMenu object with a movie clip.

MovieClip._name

The instance name of a movie clip instance.

MovieClip._parent

A reference to the movie clip that encloses the movie clip.

MovieClip._quality

A string that sets the rendering quality of a SWF file.

MovieClip._rotation

The degree of rotation of a movie clip instance.

MovieClip._soundbuftime

The number of seconds before a sound starts to stream.

MovieClip.tabChildren

A Boolean value that indicates whether the children of a movie clip are included in automatic tab ordering.

MovieClip.tabEnabled

A Boolean value that indicates whether a movie clip is included in tab ordering.

MovieClip.tabIndex

A number that indicates the tab order of an object.

MovieClip._target

Read-only; the target path of a movie clip instance.

MovieClip._totalframes

Read-only; the total number of frames in a movie clip instance.

MovieClip.trackAsMenu

A Boolean value that indicates whether other movie clips can receive mouse release events.

MovieClip._url

Read-only; the URL of the SWF file from which a movie clip was downloaded.

MovieClip.useHandCursor

A Boolean value that determines whether the hand is displayed when the mouse rolls over a movie clip.

MovieClip._visible

A Boolean value that determines whether a movie clip instance is hidden or visible.

MovieClip._width

The width of a movie clip instance, in pixels.

MovieClip._x

The x coordinate of a movie clip instance

MovieClip._xmouse

Read-only; the x coordinate of the mouse pointer within a movie clip instance.

MovieClip._xscale

The value specifying the percentage that the movie clip is scaled horizontally.

MovieClip._y

The y coordinate of a movie clip instance.

MovieClip._ymouse

Read-only; the y coordinate of the mouse pointer within a movie clip instance.

MovieClip._yscale

The value specifying the percentage for vertically scaling a movie clip.

Event handler summary for the MovieClip class

Event handler Description
MovieClip.onData

Invoked when all the data is loaded into a movie clip.

MovieClip.onDragOut

Invoked when the mouse button is pressed inside the movie clip area and then rolled outside the movie clip area.

MovieClip.onDragOver

Invoked when the mouse pointer is dragged over the movie clip.

MovieClip.onEnterFrame

Invoked continually at the frame rate of the SWF file. The actions associated with the enterFrame event are processed before any frame actions that are attached to the affected frames.

MovieClip.onKeyDown

Invoked when a key is pressed. Use the Key.getCode() and Key.getAscii() methods to retrieve information about the last key pressed.

MovieClip.onKeyUp

Invoked when a key is released.

MovieClip.onKillFocus

Invoked when focus is removed from a movie clip.

MovieClip.onLoad

Invoked when the movie clip is instantiated and appears in the Timeline.

MovieClip.onMouseDown

Invoked when the left mouse button is pressed.

MovieClip.onMouseMove

Invoked every time the mouse is moved.

MovieClip.onMouseUp

Invoked when the left mouse button is released.

MovieClip.onPress

Invoked when the mouse is pressed while the pointer is over a movie clip.

MovieClip.onRelease

Invoked when the mouse is released while the pointer is over a movie clip.

MovieClip.onReleaseOutside

Invoked when the mouse is clicked over a movie clip and released while the pointer is outside the movie clip's area.

MovieClip.onRollOut

Invoked when the pointer rolls outside of a movie clip area.

MovieClip.onRollOver

Invoked when the mouse pointer rolls over a movie clip.

MovieClip.onSetFocus

Invoked when a movie clip has input focus and a key is released.

MovieClip.onUnload

Invoked in the first frame after the movie clip is removed from the Timeline. The actions associated with the Unload movie clip event are processed before any actions are attached to the affected frame.


Comments


Ayin _ said on Feb 3, 2005 at 2:49 PM :
Two usefully additions to the current events would be ‘onFirstFrame’ and ‘onLastFrame’.
Especially the later of the two would have come in usefully on many occasions.
Yo-NuTZ said on Mar 6, 2005 at 3:41 AM :
you can just use the onLoad (if you rewrite the MovieClipClass with externat as file) or the classical _onenterframe=x where x is first or last frame!
caskater said on May 7, 2005 at 5:23 PM :
Please consider the following changes:

A new method for MovieClip class:
isChildOf(parent:MovieClip):Boolean;
This function returns true if movieclip is a child of parameter 'parent' movieclip. It is not the same as the _parent reference since the child may be several levels deep inside of the 'parent'.

Please allow event passthrough of some sort so that when creating a movieclip with an event handler (i.e. onRollOver) and creating another movieclip inside of this one with its own (onRollOver) event handler, the parent movieclip does not break all child event actions.
chrisworth said on Sep 29, 2005 at 4:09 PM :
I have a movieclip question. Can a movieclip be made up of textinputs and buttons that responds to events on the buttons? I can quicky make a fla file with these components, but when I press F8 and make it into a movie clip, all events from the components in the clip are lost. Also, what is the best way to make a generic "popup" form for, say user input for a database insert, movieclip, as class with graphics, of just bring up a different layer?

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/mx2004/main_7_2/00001484.html