Package | starling.display |
Class | public class MovieClip |
Inheritance | MovieClip Image Quad Mesh DisplayObject EventDispatcher Object |
Implements | IAnimatable |
Pass the frames of the movie in a vector of textures to the constructor. The movie clip
will have the width and height of the first frame. If you group your frames with the help
of a texture atlas (which is recommended), use the getTextures
-method of the
atlas to receive the textures in the correct (alphabetic) order.
You can specify the desired framerate via the constructor. You can, however, manually give each frame a custom duration. You can also play a sound whenever a certain frame appears, or execute a callback (a "frame action").
The methods play
and pause
control playback of the movie. You
will receive an event of type Event.COMPLETE
when the movie finished
playback. If the movie is looping, the event is dispatched once per loop.
As any animated object, a movie clip has to be added to a juggler (or have its
advanceTime
method called regularly) to run. The movie will dispatch
an event of type "Event.COMPLETE" whenever it has displayed its last frame.
See also
Property | Defined By | ||
---|---|---|---|
alpha : Number The opacity of the object. | DisplayObject | ||
base : DisplayObject [read-only] The topmost object in the display tree the object is part of. | DisplayObject | ||
blendMode : String The blend mode determines how the object is blended with the objects underneath. | DisplayObject | ||
bounds : Rectangle [read-only] The bounds of the object relative to the local coordinates of the parent. | DisplayObject | ||
color : uint Changes the color of all vertices to the same value. | Mesh | ||
currentFrame : int The index of the frame that is currently displayed. | MovieClip | ||
currentTime : Number The time that has passed since the clip was started (each loop starts at zero). | MovieClip | ||
defaultStyle : Class [static] The default style used for meshes if no specific style is provided. | Mesh | ||
defaultStyleFactory : Function [static] A factory method that is used to create the 'MeshStyle' for a mesh if no specific
style is provided. | Mesh | ||
filter : FragmentFilter The filter that is attached to the display object. | DisplayObject | ||
fps : Number The default number of frames per second. | MovieClip | ||
height : Number The height of the object in pixels. | DisplayObject | ||
is3D : Boolean [read-only] Indicates if this object or any of its parents is a 'Sprite3D' object. | DisplayObject | ||
isComplete : Boolean [read-only] Indicates if a (non-looping) movie has come to its end. | MovieClip | ||
isPlaying : Boolean [read-only] Indicates if the clip is still playing. | MovieClip | ||
loop : Boolean Indicates if the clip should loop. | MovieClip | ||
mask : DisplayObject The display object that acts as a mask for the current object. | DisplayObject | ||
maskInverted : Boolean Indicates if the masked region of this object is set to be inverted. | DisplayObject | ||
muted : Boolean If enabled, no new sounds will be started during playback. | MovieClip | ||
name : String The name of the display object (default: null). | DisplayObject | ||
numFrames : int [read-only] The total number of frames. | MovieClip | ||
numIndices : int [read-only] The total number of indices referencing vertices. | Mesh | ||
numTriangles : int [read-only] The total number of triangles in this mesh. | Mesh | ||
numVertices : int [read-only] The total number of vertices in the mesh. | Mesh | ||
parent : DisplayObjectContainer [read-only] The display object container that contains this display object. | DisplayObject | ||
pivotX : Number The x coordinate of the object's origin in its own coordinate space (default: 0). | DisplayObject | ||
pivotY : Number The y coordinate of the object's origin in its own coordinate space (default: 0). | DisplayObject | ||
pixelSnapping : Boolean Controls whether or not the instance snaps to the nearest pixel. | Mesh | ||
requiresRedraw : Boolean [read-only] Indicates if the object needs to be redrawn in the upcoming frame, i.e. | DisplayObject | ||
root : DisplayObject [read-only] The root object the display object is connected to (i.e. | DisplayObject | ||
rotation : Number The rotation of the object in radians. | DisplayObject | ||
scale : Number Sets both 'scaleX' and 'scaleY' to the same value. | DisplayObject | ||
scale9Grid : Rectangle The current scaling grid that is in effect. | Image | ||
scaleX : Number The horizontal scale factor. | DisplayObject | ||
scaleY : Number The vertical scale factor. | DisplayObject | ||
skewX : Number The horizontal skew angle in radians. | DisplayObject | ||
skewY : Number The vertical skew angle in radians. | DisplayObject | ||
soundTransform : SoundTransform The SoundTransform object used for playback of all frame sounds. | MovieClip | ||
stage : Stage [read-only] The stage the display object is connected to, or null if it is not connected
to the stage. | DisplayObject | ||
style : MeshStyle The style that is used to render the mesh. | Mesh | ||
texture : Texture [override] The texture that is mapped to the quad (or null, if there is none). | Quad | ||
textureRepeat : Boolean Indicates if pixels at the edges will be repeated or clamped. | Mesh | ||
textureSmoothing : String The smoothing filter that is used for the texture. | Mesh | ||
tileGrid : Rectangle The current tiling grid that is in effect. | Image | ||
totalTime : Number [read-only] The total duration of the clip in seconds. | MovieClip | ||
touchable : Boolean Indicates if this object (and its children) will receive touch events. | DisplayObject | ||
transformationMatrix : Matrix The transformation matrix of the object relative to its parent. | DisplayObject | ||
transformationMatrix3D : Matrix3D [read-only] The 3D transformation matrix of the object relative to its parent. | DisplayObject | ||
useHandCursor : Boolean Indicates if the mouse cursor should transform into a hand while it's over the sprite. | DisplayObject | ||
vertexFormat : VertexDataFormat [read-only] The format used to store the vertices. | Mesh | ||
visible : Boolean The visibility of the object. | DisplayObject | ||
width : Number The width of the object in pixels. | DisplayObject | ||
x : Number The x coordinate of the object relative to the local coordinates of the parent. | DisplayObject | ||
y : Number The y coordinate of the object relative to the local coordinates of the parent. | DisplayObject |
Method | Defined By | ||
---|---|---|---|
Creates a movie clip from the provided textures and with the specified default framerate. | MovieClip | ||
addEventListener(type:String, listener:Function):void [override] Registers an event listener at a certain object. | DisplayObject | ||
Adds an additional frame, optionally with a sound and a custom duration. | MovieClip | ||
addFrameAt(frameID:int, texture:Texture, sound:Sound = null, duration:Number = -1):void Adds a frame at a certain index, optionally with a sound and a custom duration. | MovieClip | ||
advanceTime(passedTime:Number):void Advance the time by a number of seconds. | MovieClip | ||
alignPivot(horizontalAlign:String = center, verticalAlign:String = center):void Moves the pivot point to a certain position within the local coordinate system
of the object. | DisplayObject | ||
automateSetupForTexture(texture:Texture, onAssign:Function, onRelease:Function = null):void [static] Injects code that is called by all instances whenever the given texture is assigned or replaced. | Image | ||
bindPivotPointToTexture(texture:Texture, pivotX:Number, pivotY:Number):void [static] Binds the given pivot point to the given texture so that any image which displays the texture will
automatically use the pivot point. | Image | ||
bindScale9GridToTexture(texture:Texture, scale9Grid:Rectangle):void [static] Binds the given scaling grid to the given texture so that any image which displays the texture will
automatically use the grid. | Image | ||
[static] Creates a new instance of the current default MeshStyle. | Mesh | ||
dispatchEvent(event:Event):void Dispatches an event to all objects that have registered listeners for its type. | EventDispatcher | ||
dispatchEventWith(type:String, bubbles:Boolean = false, data:Object = null):void Dispatches an event with the given parameters to all objects that have registered
listeners for the given type. | EventDispatcher | ||
dispose():void [override] Disposes all resources of the display object. | Mesh | ||
drawToBitmapData(out:BitmapData = null, color:uint = 0x0, alpha:Number = 0.0):BitmapData Draws the object into a BitmapData object. | DisplayObject | ||
[static] Creates a mesh from the specified polygon. | Mesh | ||
[static] Creates a quad from the given texture. | Quad | ||
getBounds(targetSpace:DisplayObject, out:Rectangle = null):Rectangle [override] Returns a rectangle that completely encloses the object as it appears in another
coordinate system. | Quad | ||
getFrameAction(frameID:int):Function Returns the method that is executed at a certain frame. | MovieClip | ||
getFrameDuration(frameID:int):Number Returns the duration of a certain frame (in seconds). | MovieClip | ||
getFrameSound(frameID:int):Sound Returns the sound of a certain frame. | MovieClip | ||
getFrameTexture(frameID:int):Texture Returns the texture of a certain frame. | MovieClip | ||
getTexCoords(vertexID:int, out:Point = null):Point Returns the texture coordinates of the vertex at the specified index. | Mesh | ||
getTransformationMatrix(targetSpace:DisplayObject, out:Matrix = null):Matrix Creates a matrix that represents the transformation from the local coordinate system
to another. | DisplayObject | ||
getTransformationMatrix3D(targetSpace:DisplayObject, out:Matrix3D = null):Matrix3D Creates a matrix that represents the transformation from the local coordinate system
to another. | DisplayObject | ||
getVertexAlpha(vertexID:int):Number Returns the alpha value of the vertex at the specified index. | Mesh | ||
getVertexColor(vertexID:int):uint Returns the RGB color of the vertex at the specified index. | Mesh | ||
getVertexPosition(vertexID:int, out:Point = null):Point The position of the vertex at the specified index, in the mesh's local coordinate
system. | Mesh | ||
globalToLocal(globalPoint:Point, out:Point = null):Point Transforms a point from global (stage) coordinates to the local coordinate system. | DisplayObject | ||
globalToLocal3D(globalPoint:Point, out:Vector3D = null):Vector3D Transforms a point from global (stage) coordinates to the 3D local coordinate system. | DisplayObject | ||
hasEventListener(type:String, listener:Function = null):Boolean If called with one argument, figures out if there are any listeners registered for
the given event type. | EventDispatcher | ||
hitTest(localPoint:Point):DisplayObject [override] Returns the object that is found topmost beneath a point in local coordinates, or nil
if the test fails. | Quad | ||
hitTestMask(localPoint:Point):Boolean Checks if a certain point is inside the display object's mask. | DisplayObject | ||
local3DToGlobal(localPoint:Vector3D, out:Point = null):Point Transforms a 3D point from the local coordinate system to global (stage) coordinates. | DisplayObject | ||
localToGlobal(localPoint:Point, out:Point = null):Point Transforms a point from the local coordinate system to global (stage) coordinates. | DisplayObject | ||
pause():void Pauses playback. | MovieClip | ||
play():void Starts playback. | MovieClip | ||
readjustSize(width:Number = -1, height:Number = -1):void Readjusts the dimensions of the quad. | Quad | ||
removeEventListener(type:String, listener:Function):void [override] Removes an event listener from the object. | DisplayObject | ||
removeEventListeners(type:String = null):void [override] Removes all event listeners with a certain type, or all of them if type is null. | DisplayObject | ||
removeFrameAt(frameID:int):void Removes the frame at a certain ID. | MovieClip | ||
removeFromParent(dispose:Boolean = false):void Removes the object from its parent, if it has one, and optionally disposes it. | DisplayObject | ||
removeSetupForTexture(texture:Texture, onAssign:Function, onRelease:Function = null):void [static] Removes specific setup functions for the given texture. | Image | ||
[override] Renders the display object with the help of a painter object. | Mesh | ||
resetSetupForTexture(texture:Texture):void [static] Removes all custom setup functions for the given texture, including those created via
'bindScale9GridToTexture' and 'bindPivotPointToTexture'. | Image | ||
reverseFrames():void Reverses the order of all frames, making the clip run from end to start. | MovieClip | ||
setFrameAction(frameID:int, action:Function):void Sets an action that will be executed whenever a certain frame is reached. | MovieClip | ||
setFrameDuration(frameID:int, duration:Number):void Sets the duration of a certain frame (in seconds). | MovieClip | ||
setFrameSound(frameID:int, sound:Sound):void Sets the sound of a certain frame. | MovieClip | ||
setFrameTexture(frameID:int, texture:Texture):void Sets the texture of a certain frame. | MovieClip | ||
setIndexDataChanged():void This method is called whenever the mesh's index data was changed. | Mesh | ||
setRequiresRedraw():void Forces the object to be redrawn in the next frame. | DisplayObject | ||
Sets the style that is used to render the mesh. | Mesh | ||
setTexCoords(vertexID:int, u:Number, v:Number):void Sets the texture coordinates of the vertex at the specified index to the given values. | Mesh | ||
setVertexAlpha(vertexID:int, alpha:Number):void Sets the alpha value of the vertex at the specified index to a certain value. | Mesh | ||
setVertexColor(vertexID:int, color:uint):void Sets the RGB color of the vertex at the specified index to a certain value. | Mesh | ||
setVertexDataChanged():void This method is called whenever the mesh's vertex data was changed. | Mesh | ||
setVertexPosition(vertexID:int, x:Number, y:Number):void | Mesh | ||
stop():void Stops playback, resetting "currentFrame" to zero. | MovieClip |
Event | Summary | Defined By | ||
---|---|---|---|---|
Dispatched when an object is added to a parent. | DisplayObject | |||
Dispatched when an object is connected to the stage (directly or indirectly). | DisplayObject | |||
Dispatched whenever the movie has displayed its last frame. | MovieClip | |||
Dispatched once every frame on every object that is connected to the stage. | DisplayObject | |||
Dispatched when a key on the keyboard is pressed. | DisplayObject | |||
Dispatched when a key on the keyboard is released. | DisplayObject | |||
Dispatched when an object is removed from its parent. | DisplayObject | |||
Dispatched when an object is removed from the stage and won't be rendered any longer. | DisplayObject | |||
Dispatched when an object is touched. | DisplayObject |
currentFrame | property |
currentFrame:int
The index of the frame that is currently displayed.
public function get currentFrame():int
public function set currentFrame(value:int):void
currentTime | property |
currentTime:Number
The time that has passed since the clip was started (each loop starts at zero).
public function get currentTime():Number
public function set currentTime(value:Number):void
fps | property |
fps:Number
The default number of frames per second. Individual frames can have different durations. If you change the fps, the durations of all frames will be scaled relatively to the previous value.
public function get fps():Number
public function set fps(value:Number):void
isComplete | property |
isComplete:Boolean
[read-only] Indicates if a (non-looping) movie has come to its end.
public function get isComplete():Boolean
isPlaying | property |
isPlaying:Boolean
[read-only] Indicates if the clip is still playing. Returns false
when the end
is reached.
public function get isPlaying():Boolean
loop | property |
loop:Boolean
Indicates if the clip should loop.
The default value is true
.
public function get loop():Boolean
public function set loop(value:Boolean):void
muted | property |
muted:Boolean
If enabled, no new sounds will be started during playback. Sounds that are already playing are not affected.
public function get muted():Boolean
public function set muted(value:Boolean):void
numFrames | property |
numFrames:int
[read-only] The total number of frames.
public function get numFrames():int
soundTransform | property |
soundTransform:SoundTransform
The SoundTransform object used for playback of all frame sounds.
The default value is null
.
public function get soundTransform():SoundTransform
public function set soundTransform(value:SoundTransform):void
totalTime | property |
totalTime:Number
[read-only] The total duration of the clip in seconds.
public function get totalTime():Number
MovieClip | () | Constructor |
public function MovieClip(textures:Vector.<Texture>, fps:Number = 12)
Creates a movie clip from the provided textures and with the specified default framerate. The movie will have the size of the first frame.
Parameterstextures:Vector.<Texture> | |
fps:Number (default = 12 )
|
addFrame | () | method |
public function addFrame(texture:Texture, sound:Sound = null, duration:Number = -1):void
Adds an additional frame, optionally with a sound and a custom duration. If the duration is omitted, the default framerate is used (as specified in the constructor).
Parameters
texture:Texture | |
sound:Sound (default = null )
| |
duration:Number (default = -1 )
|
addFrameAt | () | method |
public function addFrameAt(frameID:int, texture:Texture, sound:Sound = null, duration:Number = -1):void
Adds a frame at a certain index, optionally with a sound and a custom duration.
Parameters
frameID:int | |
texture:Texture | |
sound:Sound (default = null )
| |
duration:Number (default = -1 )
|
advanceTime | () | method |
public function advanceTime(passedTime:Number):void
Advance the time by a number of seconds.
Parameters
passedTime:Number — in seconds. |
getFrameAction | () | method |
public function getFrameAction(frameID:int):Function
Returns the method that is executed at a certain frame.
Parameters
frameID:int |
Function |
getFrameDuration | () | method |
public function getFrameDuration(frameID:int):Number
Returns the duration of a certain frame (in seconds).
Parameters
frameID:int |
Number |
getFrameSound | () | method |
public function getFrameSound(frameID:int):Sound
Returns the sound of a certain frame.
Parameters
frameID:int |
Sound |
getFrameTexture | () | method |
public function getFrameTexture(frameID:int):Texture
Returns the texture of a certain frame.
Parameters
frameID:int |
Texture |
pause | () | method |
public function pause():void
Pauses playback.
play | () | method |
public function play():void
Starts playback. Beware that the clip has to be added to a juggler, too!
removeFrameAt | () | method |
public function removeFrameAt(frameID:int):void
Removes the frame at a certain ID. The successors will move down.
Parameters
frameID:int |
reverseFrames | () | method |
public function reverseFrames():void
Reverses the order of all frames, making the clip run from end to start. Makes sure that the currently visible frame stays the same.
setFrameAction | () | method |
public function setFrameAction(frameID:int, action:Function):void
Sets an action that will be executed whenever a certain frame is reached.
Parameters
frameID:int | |
action:Function |
setFrameDuration | () | method |
public function setFrameDuration(frameID:int, duration:Number):void
Sets the duration of a certain frame (in seconds).
Parameters
frameID:int | |
duration:Number |
setFrameSound | () | method |
public function setFrameSound(frameID:int, sound:Sound):void
Sets the sound of a certain frame. The sound will be played whenever the frame is displayed.
Parameters
frameID:int | |
sound:Sound |
setFrameTexture | () | method |
public function setFrameTexture(frameID:int, texture:Texture):void
Sets the texture of a certain frame.
Parameters
frameID:int | |
texture:Texture |
stop | () | method |
public function stop():void
Stops playback, resetting "currentFrame" to zero.
complete | Event |
starling.events.Event
Dispatched whenever the movie has displayed its last frame.