API Documentation | All Packages | All Classes | Index | Frames No Frames |
Class ContentDisplay

Package | com.greensock.loading.display
Class | public class ContentDisplay
Inheritance | ContentDisplay flash.display.Sprite

A container for visual content that is loaded by any of the following: ImageLoaders, SWFLoaders, or VideoLoaders. It is essentially a Sprite that has a `loader` property for easily referencing the original loader, as well as several other useful properties for controling the placement of `rawContent` and the way it is scaled to fit (if at all). You can add a ContentDisplay to the display list or populate an array with as many as you want and then if you ever need to unload() the content or reload it or figure out its url, etc., you can reference your ContentDisplay's `loader` property like `myContent.loader.url` or `(myContent.loader as SWFLoader).getClass("com.greensock.TweenLite");`
Flex users can utilize the `FlexContentDisplay` class instead which extends `UIComponent` (a Flex requirement). All you need to do is set the `LoaderMax.contentDisplayClass` property to FlexContentDisplay once like:

Example
Example AS3 code:

     import com.greensock.loading.*;
     import com.greensock.loading.display.*;

    LoaderMax.contentDisplayClass = FlexContentDisplay;

After that, all ImageLoaders, SWFLoaders, and VideoLoaders will return FlexContentDisplay objects as their `content` instead of regular ContentDisplay objects.
Copyright 2011, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership.

Public Properties

| Property | Defined by
--- | --- | ---
|  | bgAlpha : Number Controls the alpha of the rectangle that is drawn when the ContentDisplay's `fitWidth` and `fitHeight` properties are defined (or `width` and `height` in the loader's `vars` property/parameter). | ContentDisplay
|  | bgColor : uint When the ContentDisplay's `fitWidth` and `fitHeight` properties are defined (or `width` and `height` in the loader's `vars` property/parameter), a rectangle will be drawn inside the ContentDisplay object immediately in order to ease the development process (for example, you can add `ROLL_OVER/ROLL_OUT` event listeners immediately). | ContentDisplay
|  | centerRegistration : Boolean If `true`, the ContentDisplay's registration point will be placed in the center of the `rawContent` which can be useful if, for example, you want to animate its scale and have it grow/shrink from its center. | ContentDisplay
|  | crop : Boolean When the ContentDisplay's `fitWidth` and `fitHeight` properties are defined (or `width` and `height` in the loader's `vars` property/parameter), setting `crop` to `true` will cause the `rawContent` to be cropped within that area (by applying a `scrollRect` for maximum performance). | ContentDisplay
|  | data : * Arbitrary data that you can associate with the ContentDisplay instance. | ContentDisplay
|  | fitHeight : Number The height to which the `rawContent` should be fit according to the ContentDisplay's `scaleMode` (this height is figured before rotation, scaleX, and scaleY). | ContentDisplay
|  | fitWidth : Number The width to which the `rawContent` should be fit according to the ContentDisplay's `scaleMode` (this width is figured before rotation, scaleX, and scaleY). | ContentDisplay
|  | hAlign : String When the ContentDisplay's `fitWidth` and `fitHeight` properties are defined (or `width` and `height` in the loader's `vars` property/parameter), the `hAlign` determines how the `rawContent` is horizontally aligned within that area. | ContentDisplay
|  | loader : LoaderItem The loader whose rawContent populates this ContentDisplay. | ContentDisplay
|  | rawContent : * The raw content which can be a Bitmap, a MovieClip, a Loader, or a Video depending on the type of loader associated with the ContentDisplay. | ContentDisplay
|  | scaleMode : String When the ContentDisplay's `fitWidth` and `fitHeight` properties are defined (or `width` and `height` in the loader's `vars` property/parameter), the `scaleMode` controls how the `rawContent` will be scaled to fit the area. | ContentDisplay
|  | vAlign : String When the ContentDisplay's `fitWidth` and `fitHeight` properties are defined (or `width` and `height` in the loader's `vars` property/parameter), the `vAlign` determines how the `rawContent` is vertically aligned within that area. | ContentDisplay

Public Methods

| Method | Defined by
--- | --- | ---
|  | ContentDisplay(loader:LoaderItem) Constructor | ContentDisplay
|  | dispose(unloadLoader:Boolean = true, disposeLoader:Boolean = true):void Removes the ContentDisplay from the display list (if necessary), dumps the `rawContent`, and calls `unload()` and `dispose()` on the loader (unless you define otherwise with the optional parameters). | ContentDisplay

Property detail

bgAlpha | property

`bgAlpha:Number` [read-write]

Controls the alpha of the rectangle that is drawn when the ContentDisplay's `fitWidth` and `fitHeight` properties are defined (or `width` and `height` in the loader's `vars` property/parameter).

Implementation
`public function get bgAlpha():Number`
`public function set bgAlpha(value:Number):void`

See also

bgColor
fitWidth
fitHeight

bgColor | property |

`bgColor:uint` [read-write]

When the ContentDisplay's `fitWidth` and `fitHeight` properties are defined (or `width` and `height` in the loader's `vars` property/parameter), a rectangle will be drawn inside the ContentDisplay object immediately in order to ease the development process (for example, you can add `ROLL_OVER/ROLL_OUT` event listeners immediately). It is transparent by default, but you may define a `bgAlpha` if you prefer.

Implementation
`public function get bgColor():uint`
`public function set bgColor(value:uint):void`

See also

bgAlpha
fitWidth
fitHeight

centerRegistration | property |

`centerRegistration:Boolean` [read-write]

If `true`, the ContentDisplay's registration point will be placed in the center of the `rawContent` which can be useful if, for example, you want to animate its scale and have it grow/shrink from its center.

Implementation
`public function get centerRegistration():Boolean`
`public function set centerRegistration(value:Boolean):void`

See also

scaleMode

crop | property |

`crop:Boolean` [read-write]

When the ContentDisplay's `fitWidth` and `fitHeight` properties are defined (or `width` and `height` in the loader's `vars` property/parameter), setting `crop` to `true` will cause the `rawContent` to be cropped within that area (by applying a `scrollRect` for maximum performance). This is typically useful when the `scaleMode` is `"proportionalOutside"` or `"none"` so that any parts of the `rawContent` that exceed the dimensions defined by `fitWidth` and `fitHeight` are visually chopped off. Use the `hAlign` and `vAlign` properties to control the vertical and horizontal alignment within the cropped area.

Implementation
`public function get crop():Boolean`
`public function set crop(value:Boolean):void`

See also

scaleMode

data | property |

`public var data:*`

Arbitrary data that you can associate with the ContentDisplay instance. For example, you could set `data` to be an object containing various other properties or set it to an index number related to an array in your application. It is completely optional and arbitrary.

fitHeight | property |

`fitHeight:Number` [read-write]

The height to which the `rawContent` should be fit according to the ContentDisplay's `scaleMode` (this height is figured before rotation, scaleX, and scaleY). When a "height" property is defined in the loader's `vars` property/parameter, it is automatically applied to this `fitHeight` property. For example, the following code will set the loader's ContentDisplay `fitHeight` to 80:`
var loader:ImageLoader = new ImageLoader("photo.jpg", {width:100, height:80, container:this});`

Implementation
`public function get fitHeight():Number`
`public function set fitHeight(value:Number):void`

See also

fitWidth
scaleMode

fitWidth | property |

`fitWidth:Number` [read-write]

The width to which the `rawContent` should be fit according to the ContentDisplay's `scaleMode` (this width is figured before rotation, scaleX, and scaleY). When a "width" property is defined in the loader's `vars` property/parameter, it is automatically applied to this `fitWidth` property. For example, the following code will set the loader's ContentDisplay `fitWidth` to 100:`
var loader:ImageLoader = new ImageLoader("photo.jpg", {width:100, height:80, container:this});`

Implementation
`public function get fitWidth():Number`
`public function set fitWidth(value:Number):void`

See also

fitHeight
scaleMode

hAlign | property |

`hAlign:String` [read-write]

When the ContentDisplay's `fitWidth` and `fitHeight` properties are defined (or `width` and `height` in the loader's `vars` property/parameter), the `hAlign` determines how the `rawContent` is horizontally aligned within that area. The following values are recognized (you may use the `com.greensock.layout.AlignMode` constants if you prefer):

- `"center"` (the default) - The `rawContent` will be centered horizontally in the ContentDisplay
- `"left"` - The `rawContent` will be aligned with the left side of the ContentDisplay
- `"right"` - The `rawContent` will be aligned with the right side of the ContentDisplay

Implementation
`public function get hAlign():String`
`public function set hAlign(value:String):void`

See also

scaleMode
vAlign

loader | property |

`loader:LoaderItem` [read-write]

The loader whose rawContent populates this ContentDisplay. If you get the loader's `content`, it will return this ContentDisplay object.

Implementation
`public function get loader():LoaderItem`
`public function set loader(value:LoaderItem):void`

rawContent | property |

`rawContent:*` [read-write]

The raw content which can be a Bitmap, a MovieClip, a Loader, or a Video depending on the type of loader associated with the ContentDisplay.

Implementation
`public function get rawContent():*`
`public function set rawContent(value:*):void`

scaleMode | property |

`scaleMode:String` [read-write]

When the ContentDisplay's `fitWidth` and `fitHeight` properties are defined (or `width` and `height` in the loader's `vars` property/parameter), the `scaleMode` controls how the `rawContent` will be scaled to fit the area. The following values are recognized (you may use the `com.greensock.layout.ScaleMode` constants if you prefer):

- `"stretch"` (the default) - The `rawContent` will fill the width/height exactly.
- `"proportionalInside"` - The `rawContent` will be scaled proportionally to fit inside the area defined by the width/height
- `"proportionalOutside"` - The `rawContent` will be scaled proportionally to completely fill the area, allowing portions of it to exceed the bounds defined by the width/height.
- `"widthOnly"` - Only the width of the `rawContent` will be adjusted to fit.
- `"heightOnly"` - Only the height of the `rawContent` will be adjusted to fit.
- `"none"` - No scaling of the `rawContent` will occur.

Implementation
`public function get scaleMode():String`
`public function set scaleMode(value:String):void`

vAlign | property |

`vAlign:String` [read-write]

When the ContentDisplay's `fitWidth` and `fitHeight` properties are defined (or `width` and `height` in the loader's `vars` property/parameter), the `vAlign` determines how the `rawContent` is vertically aligned within that area. The following values are recognized (you may use the `com.greensock.layout.AlignMode` constants if you prefer):

- `"center"` (the default) - The `rawContent` will be centered vertically in the ContentDisplay
- `"top"` - The `rawContent` will be aligned with the top of the ContentDisplay
- `"bottom"` - The `rawContent` will be aligned with the bottom of the ContentDisplay

Implementation
`public function get vAlign():String`
`public function set vAlign(value:String):void`

See also

scaleMode
hAlign
Constructor detail

ContentDisplay | () | constructor

`public function ContentDisplay(loader:LoaderItem)`

Constructor

Parameters

| `loader:LoaderItem` — The Loader object that will populate the ContentDisplay's `rawContent`.

Method detail

dispose | () | method

`public function dispose(unloadLoader:Boolean = true, disposeLoader:Boolean = true):void`

Removes the ContentDisplay from the display list (if necessary), dumps the `rawContent`, and calls `unload()` and `dispose()` on the loader (unless you define otherwise with the optional parameters). This essentially destroys the ContentDisplay and makes it eligible for garbage collection internally, although if you added any listeners manually, you should remove them as well.

Parameters

| `unloadLoader:Boolean` (default = `true`)`` — If `true`, `unload()` will be called on the loader. It is `true` by default.
| `disposeLoader:Boolean` (default = `true`)`` — If `true`, `dispose()` will be called on the loader. It is `true` by default.