Class: MovieClip

MovieClip

Provide timeline playback of movieclip

new MovieClip (options)

Name Type Attributes Description
options MovieClipOptions | number <optional>

The options object

Extends

Members

MovieClip.DEFAULT_FRAMERATE number staticreadonly

The default framerate if none is specified or there's not parent clip with a framerate.

Default Value:
  • 24

MovieClip.INDEPENDENT number staticreadonly

The MovieClip will advance independently of its parent, even if its parent is paused. This is the default mode.

Default Value:
  • 0

MovieClip.SINGLE_FRAME number staticreadonly

The MovieClip will only display a single frame (as determined by the startPosition property).

Default Value:
  • 1

MovieClip.SYNCHED number staticreadonly

The MovieClip will be advanced only when its parent advances and will be synched to the position of the parent MovieClip.

Default Value:
  • 2

aa

Short cut for addAction

actionsEnabled boolean

If true, actions in this MovieClip's tweens will be run when the playhead advances.

am

Shortcut alias for addTimedMask

at

Alias for method addTimedChild

autoReset boolean

If true, the MovieClip will automatically be reset to its first frame whenever the timeline adds it back onto the display list. This only applies to MovieClip instances with mode=INDEPENDENT.

For example, if you had a character animation with a 'body' child MovieClip instance with different costumes on each frame, you could set body.autoReset = false, so that you can manually change the frame it is on, without worrying that it will be reset automatically.

currentFrame number readonly

The current frame of the movieclip.

currentLabel string | null

Returns the name of the label on or immediately before the current frame.

elapsedTime number

When the MovieClip is framerate independent, this is the time elapsed from frame 0 in seconds.

framerate number

By default MovieClip instances advance one frame per tick. Specifying a framerate for the MovieClip will cause it to advance based on elapsed time between ticks as appropriate to maintain the target framerate.

For example, if a MovieClip with a framerate of 10 is placed on a Stage being updated at 40fps, then the MovieClip advance roughly one frame every 4 ticks. This will not be exact, because the time between each tick vary slightly between frames.

This feature is dependent on the tick event object (or an object with an appropriate 'delta' property) being passed into {{#crossLink 'Stage/update'}}{{/crossLink}}.

isMovieClip boolean

Fast way of checking if a movie clip is actually a movie clip. Prevents circular references and is faster than instanceof.

Default Value:
  • true

labels FrameLabel[]

Returns an array of objects with label and position (aka frame) properties, sorted by position.

labelsMap LabelMap

Returns a dictionary of labels where key is the label and value is the frame.

loop boolean

Indicates whether this MovieClip should loop when it reaches the end of its timeline.

mode number

Controls how this MovieClip advances its time. Must be one of 0 (INDEPENDENT), 1 (SINGLE_FRAME), or 2 (SYNCHED). See each constant for a description of the behaviour.

parentFramerate number

Get the close parent with a valid framerate. If no parent, returns the default framerate.

paused boolean

If true, the MovieClip's position will not advance when ticked.

ps

Short cut for playSound

selfAdvance boolean

If true, this movieclip will animate automatically whenever it is on the stage.

startPosition number

Specifies what the first frame to play in this movieclip, or the only frame to display if mode is SINGLE_FRAME.

totalFrames number

Get the total number of frames (duration) of this MovieClip

tw

Shortcut alias for addTween

_actions FrameAction[][] protected

Array of frame scripts, indexed by frame.

_depthSorted AnimateDisplayObject[] protected

Array to depth sort timed children

_framerate number protected

By default MovieClip instances advance one frame per tick. Specifying a framerate for the MovieClip will cause it to advance based on elapsed time between ticks as appropriate to maintain the target framerate.

_timelines Timeline[] protected

Standard tween timelines for all objects. Each element in the _timelines array is a Timeline object - an array of tweens for one target, in order of occurrence.

Methods

addAction (callback, startFrame) this

Handle frame actions, callback is bound to the instance of the MovieClip.

Name Type Description
callback FrameAction

The clip call on a certain frame

startFrame number | string

The starting frame index or label

Returns:
Type Description
this

addKeyframe (instance, properties, startFrame) this

Add a tween to the clip

Name Type Description
instance AnimateDisplayObject

The clip to tween

properties KeyframeData

The property or property to tween

startFrame number

The frame to start tweening

Returns:
Type Description
this

addTimedChild (instance, startFrame, duration, keyframes) this

Add a child to show for a certain number of frames before automatic removal.

Name Type Attributes Description
instance AnimateDisplayObject

The clip to show

startFrame number

The starting frame

duration number <optional>

The number of frames to display the child before removing it.

keyframes string | { [frame: number]: KeyframeData } <optional>

The collection of static keyframes to add

Returns:
Type Description
this

addTimedMask (instance, keyframes) this

Add mask or masks

Name Type Description
instance AnimateDisplayObject
keyframes { [frame: number]: Graphics | Sprite }
Returns:
Type Description
this

addTween (instance, properties, startFrame, duration, ease) this

Add a tween to the clip

Name Type Attributes Description
instance AnimateDisplayObject

The clip to tween

properties TweenProps

The property or property to tween

startFrame number

The frame to start tweening

duration number <optional>

Number of frames to tween. If 0, then the properties are set with no tweening.

ease EaseMethod <optional>

An optional easing function that takes the tween time from 0-1.

Returns:
Type Description
this

advance (time) void

Advances the playhead. This occurs automatically each tick by default.

Name Type Attributes Description
time number <optional>

The amount of time in seconds to advance by. Only applicable if framerate is set.

gotoAndPlay (positionOrLabel) void

Advances this movie clip to the specified position or label and sets paused to false.

Name Type Description
positionOrLabel string | number

The animation name or frame number to go to.

gotoAndStop (positionOrLabel) void

Advances this movie clip to the specified position or label and sets paused to true.

Name Type Description
positionOrLabel string | number

The animation or frame name to go to.

play () void

Sets paused to false.

playSound (alias, loop) this

Handle sounds.

Name Type Attributes Description
alias string

The name of the Sound

loop boolean <optional>

The loop property of the sound

Returns:
Type Description
this

stop () void

Sets paused to true.

_goto (positionOrLabel) void protected

Name Type Description
positionOrLabel string | number

The animation name or frame number to go to.

_setTimelinePosition (startFrame, currentFrame, doActions) void protected

Set the timeline position

Name Type Description
startFrame number
currentFrame number
doActions boolean

Inherited Properties

From class AnimateContainer

Shortcut for setAlpha.

Shortcut for addChild.

Shortcut for setColor.

colorTransformFilter ColorMatrixFilter inherited

The current default color transforming filters

Shortcut for setTint.

Shortcut for setMask.

Shortcut for setRenderable.

Shortcut for setTransform.

Inherited Methods

From class AnimateContainer

setAlpha (alpha) this inherited

Chainable setter for alpha

Name Type Description
alpha number

The alpha amount to use, from 0 to 1

Returns:
Type Description
this Instance for chaining

setColorTransform (r, rA, g, gA, b, bA) this inherited

Set additive and multiply color, tinting

Name Type Description
r number

The multiply red value

rA number

The additive red value

g number

The multiply green value

gA number

The additive green value

b number

The multiply blue value

bA number

The additive blue value

Returns:
Type Description
this Object for chaining

setMask (mask) this inherited

Setter for mask to be able to chain.

Name Type Description
mask Graphics | Sprite

The mask shape to use

Returns:
Type Description
this Instance for chaining

setRenderable (renderable) this inherited

Function to set if this is renderable or not. Useful for setting masks.

Name Type Attributes Description
renderable boolean <optional>

Make renderable. Defaults to false.

Returns:
Type Description
this This instance, for chaining.

setTint (tint) this inherited

Set the tint values by color.

Name Type Description
tint string | number

The color value to tint

Returns:
Type Description
this Object for chaining