register

Availability

Flash Player 7.

Usage

myAligner.register(target, alignParams)

Parameters

target Movie clip to align.

alignParams Object containing align parameters.

Returns

Nothing.

Description

Method; registers the target movie clip to be aligned. Align behavior is defined using the alignParams object. These are the properties of alignParams object:

hAlign, vAlign, hStretch, vStretch Boolean properties that enable aligning and/or stretching. All aligning and stretching is disabled by default.

hPosition, vPosition, hPositionMargin, vPositionMargin, hPositionOffset, vPositionOffset Numeric properties defining the aligning. Default value for all four properties is 0. (targetX = (host.width - hPositionMargin) * hPosition + hPositionOffset)

hSize, vSize, hSizeMargin, vSizeMargin Numeric properties defining the stretching. By default margin values are set to 0 and size values to 1. (targetWIdth = host.width * hSize - hSizeMargin)

hPositionRounding, vPositionRounding, hSizeRounding, vSizeRounding Define the rounding functions used for aligining and stretching. By default aligner.noRounding, a static method of aligner class, is used. Typically you can also use Math.round, Math.floor and Math.ceil.

hCenterPointCalculated, hCenterPointCalculated By default the actual movie clip registration point is used for aligning ("none"). Set these properties to "center"/"right" or "center"/"bottom" and the calculated registration point will be used for aligning. (This requires the actual registration point to be top-left.)

Should a movie clip with a calculated registration point broadcast the resize event, the calculated registration point will be recalculated and the movie clip realigned.

proportionalStretch, boundingRectagleWidth, boundingRectagleHeight Instead of the horizontal and/or vertical stretching, you can use the proportional stretching, which will preserve the proportions of the movie clip. It is the virtual rectangle around the movie clip, of the specified size, that will be stretched. Note that the movie clip's proportion to the rectangle will be based on its size at 100% (therefore, you should resize the content inside of the movie clip and not the movie clip itself; or you could increase the dimension of the rectangle, and hence decrease the relative size of the movie clip). "in" stretching will fit the entire rectangle inside of the resizable clip area, while "out" stretching will always keep all of the resizable clip area occupied by stretching the movie clip as much as necessary.

Additionally, proportional stretching takes account of hSizeMargin, vSizeMargin, hSizeRounding and vSizeRounding properties.

Example

import xm.corpus.aligner;

myAligner = new aligner(Stage);

// Centers the movie clip (at full pixels)
myAligner.register(myCenteredClip, {hAlign: true, hPosition: 0.5, vAlign: true, vPosition: 0.5, hPositionRounding: Math.round, vPositionRounding: Math.round });

// Fills out the entire stage
myAligner.register(myBackground {hSize: true, vSize: true});

// 100 pixels to the left side of the right scene's edge
myAligner.register(myLogo, {hAlign: true, hPosition: 1, hPositionOffset: -100});