Apache Flex 4.16.0 API Reference | All Packages | All Classes | Index | Frames No Frames |
MovieClipAsset

Package | mx.core
Class | public class MovieClipAsset
Inheritance | MovieClipAsset FlexMovieClip flash.display.MovieClip
Implements | IFlexAsset, IFlexDisplayObject, IBorder
Subclasses | MovieClipLoaderAsset

Language Version : | ActionScript 3.0

Product Version : | Flex 3

Runtime Versions : | Flash Player 9, AIR 1.1

MovieClipAsset is a subclass of the flash.display.MovieClip class which represents movieclip symbols that you embed in a Flex application from a SWF file produced by Flash. It implements the IFlexDisplayObject interface, which makes it possible for the MovieClip to be displayed in an Image control, or to be used as a container background or a component skin.

The MovieClip that you're embedding must be a movieclip symbol that is in a SWF file. A common reason for using an embedded movieclip is that you have created a frame-based animation in Flash and want to use it in a Flex application. The MXML compiler autogenerates a class that extends MovieClipAsset to represent the embedded animation.

You don't generally have to use the MovieClipAsset class directly when you write a Flex application. For example, you can use a movieclip animation as an application's background image by writing the following:

      <mx:Application backgroundImage="@Embed(source='Assets.swf', symbol='BackgroundAnimation')"/>

or

      <fx:Style>
          @namespace mx "library://ns.adobe.com/flex/mx"
          mx|Application {
              backgroundImage: Embed(source="Assets.swf", symbol="BackgroundAnimation")
          }
      <fx:Style/>

without having to understand that the MXML compiler has created a subclass of MovieClipAsset for you.

However, it may be useful to understand what is happening at the ActionScript level. To embed a movieclip in ActionScript, you declare a variable of type Class, and put `[Embed]` metadata on it. For example:

      [Bindable]
      [Embed(source="Assets.swf", symbol="BackgroundAnimation")]
      private var backgroundAnimationClass:Class;

The MXML compiler notices that the BackgroundAnimation symbol in Assets.swf is a movie clip, autogenerates a subclass of the MovieClipAsset class to represent it, and sets your variable to be a reference to this autogenerated class. You can then use this class reference to create instances of the MovieClipAsset using the `new` operator, and you can use APIs of the MovieClip class on them:

      var backgroundAnimation:MovieClipAsset =
          MovieClipAsset(new backgroundAnimationClass());
      var n:int = backgroundAnimation.totalFrames;

However, you rarely need to create MovieClipAsset instances yourself because image-related properties and styles can be set to an image-producing class, and components will create instances as necessary. For example, to set the application background to this animation, you can simply write the following:

      <mx:Application backgroundImage="{backgroundAnimationClass}"/>

Public Properties

| Property | Defined By
--- | --- | ---
|  | borderMetrics : EdgeMetrics [read-only] Returns an EdgeMetrics object for the border that has four properties: left, top, right, and bottom. | MovieClipAsset
|  | measuredHeight : Number [read-only] The measured height of this object. | MovieClipAsset
|  | measuredWidth : Number [read-only] The measured width of this object. | MovieClipAsset

Public Methods
Hide Inherited Public Methods
Show Inherited Public Methods

| Method | Defined By
--- | --- | ---
|  | MovieClipAsset() Constructor. | MovieClipAsset
|  | move(x:Number, y:Number):void Moves this object to the specified x and y coordinates. | MovieClipAsset
|  | setActualSize(newWidth:Number, newHeight:Number):void Sets the actual size of this object. | MovieClipAsset
|  | toString():String [override] Returns a string indicating the location of this object within the hierarchy of DisplayObjects in the Application. | FlexMovieClip

Property Detail

borderMetrics | property

`borderMetrics:EdgeMetrics` [read-only]

Language Version : | ActionScript 3.0

Product Version : | Flex 3

Runtime Versions : | Flash Player 9, AIR 1.1

Returns an EdgeMetrics object for the border that has four properties: `left`, `top`, `right`, and `bottom`. The value of each property is equal to the thickness of one side of the border, in pixels.

Implementation
`public function get borderMetrics():EdgeMetrics`

measuredHeight | property |

`measuredHeight:Number` [read-only]

Language Version : | ActionScript 3.0

Product Version : | Flex 3

Runtime Versions : | Flash Player 9, AIR 1.1

The measured height of this object.

This is typically hard-coded for graphical skins because this number is simply the number of pixels in the graphic. For code skins, it can also be hard-coded if you expect to be drawn at a certain size. If your size can change based on properties, you may want to also be an ILayoutManagerClient so a `measure()` method will be called at an appropriate time, giving you an opportunity to compute a `measuredHeight`.

Implementation
`public function get measuredHeight():Number`

measuredWidth | property |

`measuredWidth:Number` [read-only]

Language Version : | ActionScript 3.0

Product Version : | Flex 3

Runtime Versions : | Flash Player 9, AIR 1.1

The measured width of this object.

This is typically hard-coded for graphical skins because this number is simply the number of pixels in the graphic. For code skins, it can also be hard-coded if you expect to be drawn at a certain size. If your size can change based on properties, you may want to also be an ILayoutManagerClient so a `measure()` method will be called at an appropriate time, giving you an opportunity to compute a `measuredHeight`.

Implementation
`public function get measuredWidth():Number`
Constructor Detail

MovieClipAsset | () | Constructor

`public function MovieClipAsset()`

Language Version : | ActionScript 3.0

Product Version : | Flex 3

Runtime Versions : | Flash Player 9, AIR 1.1

Constructor.

Method Detail

move | () | method

`public function move(x:Number, y:Number):void`

Language Version : | ActionScript 3.0

Product Version : | Flex 3

Runtime Versions : | Flash Player 9, AIR 1.1

Moves this object to the specified x and y coordinates.

Parameters

| `x:Number` — The new x-position for this object.
| `y:Number` — The new y-position for this object.

setActualSize | () | method |

`public function setActualSize(newWidth:Number, newHeight:Number):void`

Language Version : | ActionScript 3.0

Product Version : | Flex 3

Runtime Versions : | Flash Player 9, AIR 1.1

Sets the actual size of this object.

This method is mainly for use in implementing the `updateDisplayList()` method, which is where you compute this object's actual size based on its explicit size, parent-relative (percent) size, and measured size. You then apply this actual size to the object by calling `setActualSize()`.

In other situations, you should be setting properties such as `width`, `height`, `percentWidth`, or `percentHeight` rather than calling this method.

Parameters

| `newWidth:Number` — The new width for this object.
| `newHeight:Number` — The new height for this object.

Sun Mar 5 2017, 03:42 PM +11:00