MovieClip

Description

A MovieClip is a container for shapes and other MovieClip instances. Each MovieClip plays back the animation in its timeline. You can use SceneGraphFactory to create MovieClip instances.

Extends

  • flwebgl.event.EventDispatcher

Methods

addChild(child)

Description

 This method adds the passed child object as the top-most child of this MovieClip. The child can be a shape or a MovieClip.

Parameters

Name

Type

Description

child

Shape or MovieClip

The object to add as  child .

Returns

  • Whether the operation was successful
  • Type - boolean

addChildAt(child, index)

Description

This method adds the passed child object at the specified index for this movie clip. The child can be a shape or a movie clip.

Parameters

Name

Type

Description

child

Shape or MovieClip

The child to add to the index.

index

number

The index to which to add the child.

Returns

  • Whether the operation was successful
  • Type - boolean

getBounds(targetCoordinateSpace, bFastBounds)

Description

  This method returns the bounding rectangle.

Parameters

Name

Type

Description

targetCoordinateSpace

Shape or MovieClip

(Optional, default = undefined) The display object that defines the coordinate system to use. If not specified, returns the local bounds.

bFastBounds

boolean

(Optional, default = true) Specifies whether to return the original or default bounds (fast computation) or the transformed local bounds (more accurate but comparatively slower).

Returns

  • Bounds of the display object
  • Type - flwebgl.geom.Rect

getChildAt(index)

Description

This method returns the child at the specified index of this movie clip. It returns 'undefined' if there is no child at the specified index

Parameters

Name

Type

Description

index

number

The index at which the child is requested.

Returns

  • Type - Shape or MovieClip

Example

In this example, a node is moved from one MovieClip to another.

        var stage = player.getStage();
        var mc1 = stage.getChildAt(0);
        var mc2 = stage.getChildAt(1);
        
        var child = mc1.getChildAt(0);
        mc2.addChildAt(child, 0);

getChildByName(name)

Description

This method returns the child display object that exists with the specified name. If more than one child display object has the same specified name, the method returns the first object in the child list.

Parameters

Name

Type

Description

name

string

Name of the child to search for

Returns

  • Child with the given name
  • Type - number

getChildIndex(child)

Description

The method returns the index of the child in the children list. It returns '1' if the child is not found.

Parameters

Name

Type

Description

child

Shape or MovieClip

The child to search for.

Returns

  • Type - number

getChildren()

Description

    This method returns the children of the movie clip.

Returns

  • Type - An array containing Shapes or MovieClips

getCurrentFrame()

Description

    This method returns the current frame number. Frame numbers are 1-based.

Returns

  • Type - number

getCurrentFrameLabel()

Description

    This method returns the label at the current frame in the timeline of the MovieClip instance. If the current frame has no label, it returns currentLabel as 'undefined.'

Returns

  • Type - String

Example

This example stops animating a MovieClip when it crosses a frame with label "stop_anim."

 
function exitHandler(e) {
 var m = e.getTarget();
 var curLabel = m.getCurrentFrameLabel();
 
 if (curLabel == "stop_anim")
  m.stop();
}

var stage = player.getStage();
stage.addEventListener(flwebgl.events.Event.EXIT_FRAME, exitHandler);

getCurrentLabel()

Description

    This method returns the current label in which the playhead is located in the timeline of the MovieClip instance. If the current frame has no label, getCurrentLabel() returns the name of the previous frame that includes a label. If the current frame and previous frames do not include a label, getCurrentLabel() returns the value 'undefined.'

Returns

  • Type - String

getFrameLabels()

Description

    This method returns a list of all the labels in the movie clip or scene. You can access each label by its 'name' and 'frameNum' properties.

Returns

  • Array of {frameNum: number, name: string}

getGlobalColorTransform()

Description

    This method returns the global color transform of the display object.

Returns

  • Type - flwebgl.geom.ColorTransform

getGlobalTransform()

Description

    This method returns the global transform of the display object.

Returns

  •     Type - flwebgl.geom.Matrix

getLocalColorTransform()

Description

    This method returns the local color transform of the display object.

Returns

  • Type - flwebgl.geom.ColorTransform

getLocalTransform()

Description

    This method returns the local transform of the display object.

Returns

  • Type - flwebgl.geom.Matrix

getName()

Description

    This method returns the name for this display object.

Returns

  • Type - String

getNumChildren()

Description

    This method returns the number of children.

Returns

  • Type - number

getTotalFrames()

Description

    This method returns the total number of frames in the corresponding timeline.

Returns

  • Type - number

gotoAndPlay(frame)

Description

This method starts playing the movie clip at the specified frame.

Parameters

Name

Type

Description

frame

number or string

The requested frame number or frame label

Example

This example adds a handler to a MovieClip that makes it jump directly to frame 15 after it crosses frame 5.

function exitHandler(e) {
    var m = e.getTarget();
    var curFrame = m.getCurrentFrame();

    if (curFrame == 5)
        m.gotoAndPlay(15);
}

var stage = player.getStage();
stage.addEventListener(flwebgl.events.Event.EXIT_FRAME, exitHandler);

gotoAndStop(frame)

Description

This method brings the playhead to the specified frame of the movie clip and stops it there.

Parameters

Name

Type

Description

frame

number or string

The requested frame number or frame label

isVisible()

Description

    This method returns the visibility flag for the display object.

Returns

  • Type - boolean

play()

Description

    This method moves the playhead in the timeline of the movie clip.

removeChild(child)

Description

 This method removes the supplied child object from the movie clip. The child can be a shape or a movie clip.

Parameters

Name

Type

Description

child

Shape or MovieClip

The child to remove

Returns

  • Whether the operation was successful
  • Type - boolean

removeChildAt(index)

Description

 This method removes the child at the specified index from the movie clip. The child can be a shape or a movie clip.

Parameters

Name

Type

Description

index

number

Index of the child to remove.

Returns

  • Whether the operation was successful
  • Type - boolean

setChildIndex(child, newIndex)

Description

This method can be used to rearrange the ordering children of a MovieClip. When you use the setChildIndex() method and specify an index position that is already occupied, the only positions that change are those in between the display object's former and new position. All others will stay the same.

Parameters

Name

Type

Description

child

Shape or movieclip

The child to move

newIndex

Number

The new index of the child display object

Example

This example takes the lowest child of the stage and places it on top of all other children.

var stage = player.getStage();
var n = stage.getNumChildren();
var child = stage.getChildAt(n - 1);
stage.setChildIndex(child, 0);

setLocalColorTransform(colorTransform)

Description

This method sets the local color transform of the display object.

Parameters

Name

Type

Description

colorTransform

flwebgl.geom.ColorTransform

The color transform that you want to set

setLocalTransform(transform)

Description

 This method sets the local transform of the display object.

Parameters

Name

Type

Description

transform

flwebgl.geom.Matrix

The transform that you want to set

Example

This example modifies the local transform of a MovieClip instance on stage by transforming it by 20 pixels both horizontally and vertically.

var stage = player.getStage();
var mc = stage.getChildAt(0);
var mat = mc.getLocalTransform();
mat.translate(20, 20);
mc.setLocalTransform(mat);

setName(name)

Description

This method sets the name for this display object.

Parameters

Name

Type

Description

name

string

The name of the display object

setVisible(flag)

Description

This method sets the visibility flag for this display object.

Parameters

Name

Type

Description

flag

boolean

The visibility flag

Example

This example toggles the visibility flag of the topmost child of the stage.

var stage = player.getStage();
var mc = stage.getChildAt(0);
var visibiliity = mc.isVisible();
mc.setVisible(!visibiliity);

stop()

Description

    This method stops the playhead in the movie clip.

Adobe logo

Sign in to your account