Fumio Nonaka http://www.fumiononaka.com/

Technical Writer/Trainer/ActionScript Developer

Correction of a sample code in “Using the Text Layout Framework” of the CS5 help

Using the Text Layout Framework” in “ActionScript 3.0 Developer’s Guide” on the Flash CS5 help includes some example codes to show how to use the Text Layout Framework. However, the second example in the section “The Text Layout Framework View” yields errors. The following two corrections should be made.

First, insert the xmlns attribute into the Flow element of the XML data (markup).

// var markup:XML = <TextFlow><p><span>Hello, World</span></p></TextFlow>;
var markup:XML = <TextFlow xmlns=’http://ns.adobe.com/textLayout/2008′><p><span>Hello, World</span></p></TextFlow>;

Second, the method updateAllContainers() is not implemented in the IFlowComposer interface. Use the updateAllControllers() method instead.

// myFlow.flowComposer.updateAllContainers();
myFlow.flowComposer.updateAllControllers();

The corrected frame action below works and shows the text in the top left corner of the stage.

// import necessary classes
import flashx.textLayout.container.*;
import flashx.textLayout.compose.*;
import flashx.textLayout.elements.TextFlow;
import flashx.textLayout.conversion.TextConverter;

// first, create a TextFlow instance named myFlow
// var markup:XML = <TextFlow><p><span>Hello, World</span></p></TextFlow>;
var markup:XML = <TextFlow xmlns='http://ns.adobe.com/textLayout/2008'><p><span>Hello, World</span></p></TextFlow>;
var myFlow:TextFlow = TextConverter.importToFlow(markup, TextConverter.TEXT_LAYOUT_FORMAT);

// second, create a controller
// the first parameter, this, must point to a DisplayObjectContainer
// the last two parameters set the initial size of the container in pixels
var contr:ContainerController = new ContainerController(this, 600, 600);

// third, associate it with the flowComposer property
myFlow.flowComposer.addController(contr);

// fourth, update the display list ;
// myFlow.flowComposer.updateAllContainers();
myFlow.flowComposer.updateAllControllers();

Using a class in flashx.textLayout package prevents the constructor from accessing Stage

Text Layout Framework example: News layout” in the [Help] yields the run-time error #1009. Because using a class in flashx.textLayout package prevents the constructor from accessing the Stage instance.

Note: The code has already been fixed. But it is good to know how to access the Stage object when classes in flashx.textLayout package are used. (2010/06/20)

As the test script below shows, the Stage object is available after the DisplayObject.addedToStage event, which is dispatched twice.

package {
	import flash.display.Sprite;
	import flash.events.Event;
	import flashx.textLayout.elements.TextFlow;
	public class TextLayoutFormatTest extends Sprite {
		public function TextLayoutFormatTest() {
			var my_fmt:TextFlow;
			trace("constructor", stage, parent);
			addEventListener(Event.ADDED_TO_STAGE, onAdded);
		}
		private function onAdded(eventObject:Event):void {
			trace(stage, parent);
		}
	}
}

// [Output]:
constructor null null
[object Stage] [object Loader]
[object Stage] [object Stage]

As for the prior example in the [Help], TLFNewsLayout class, the statements in the constructor should be moved into a listener method of the DisplayObject.addedToStage event as follows:

package {
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	import flash.geom.Rectangle;

	import flashx.textLayout.compose.StandardFlowComposer;
	import flashx.textLayout.container.ContainerController;
	import flashx.textLayout.container.ScrollPolicy;
	import flashx.textLayout.conversion.TextConverter;
	import flashx.textLayout.elements.TextFlow;
	import flashx.textLayout.formats.TextLayoutFormat;

	public class TLFNewsLayout extends Sprite {
		private var hTextFlow:TextFlow;
		private var headContainer:Sprite;
		private var headlineController:ContainerController;
		private var hContainerFormat:TextLayoutFormat;

		private var bTextFlow:TextFlow;
		private var bodyTextContainer:Sprite;
		private var bodyController:ContainerController;
		private var bodyTextContainerFormat:TextLayoutFormat;

		private const headlineMarkup:String = "TLF News Layout ExampleThis example formats text like a newspaper page with a headline, a subtitle, and multiple columns";

		private const bodyMarkup:String = "There are many such lime-kilns in that tract of country, for the purpose of burning the white marble which composes a large part of the substance of the hills. Some of them, built years ago, and long deserted, with weeds growing in the vacant round of the interior, which is open to the sky, and grass and wild-flowers rooting themselves into the chinks of the stones, look already like relics of antiquity, and may yet be overspread with the lichens of centuries to come. Others, where the lime-burner still feeds his daily and nightlong fire, afford points of interest to the wanderer among the hills, who seats himself on a log of wood or a fragment of marble, to hold a chat with the solitary man. It is a lonesome, and, when the character is inclined to thought, may be an intensely thoughtful occupation; as it proved in the case of Ethan Brand, who had mused to such strange purpose, in days gone by, while the fire in this very kiln was burning.The man who now watched the fire was of a different order, and troubled himself with no thoughts save the very few that were requisite to his business. At frequent intervals, he flung back the clashing weight of the iron door, and, turning his face from the insufferable glare, thrust in huge logs of oak, or stirred the immense brands with a long pole. Within the furnace were seen the curling and riotous flames, and the burning marble, almost molten with the intensity of heat; while without, the reflection of the fire quivered on the dark intricacy of the surrounding forest, and showed in the foreground a bright and ruddy little picture of the hut, the spring beside its door, the athletic and coal-begrimed figure of the lime-burner, and the half-frightened child, shrinking into the protection of his father's shadow. And when again the iron door was closed, then reappeared the tender light of the half-full moon, which vainly strove to trace out the indistinct shapes of the neighboring mountains; and, in the upper sky, there was a flitting congregation of clouds, still faintly tinged with the rosy sunset, though thus far down into the valley the sunshine had vanished long and long ago.";

		public function TLFNewsLayout() {
			addEventListener(Event.ADDED_TO_STAGE, initialize);
		}
		function initialize(eventObject:Event):void {
			removeEventListener(Event.ADDED_TO_STAGE, initialize);
			stage.scaleMode = StageScaleMode.NO_SCALE;
			stage.align = StageAlign.TOP_LEFT;

			// Headline text flow and flow composer
			hTextFlow = TextConverter.importToFlow(headlineMarkup,TextConverter.TEXT_LAYOUT_FORMAT);
			hTextFlow.flowComposer = new StandardFlowComposer();

			// initialize the headline container and controller objects
			headContainer = new Sprite();
			headlineController = new ContainerController(headContainer);
			headlineController.verticalScrollPolicy = ScrollPolicy.OFF;
			hContainerFormat = new TextLayoutFormat();
			hContainerFormat.paddingTop = 4;
			hContainerFormat.paddingRight = 4;
			hContainerFormat.paddingBottom = 4;
			hContainerFormat.paddingLeft = 4;

			headlineController.format = hContainerFormat;
			hTextFlow.flowComposer.addController(headlineController);
			addChild(headContainer);
			stage.addEventListener(flash.events.Event.RESIZE, resizeHandler);

			// Body text TextFlow and flow composer
			bTextFlow = TextConverter.importToFlow(bodyMarkup,TextConverter.TEXT_LAYOUT_FORMAT);
			bTextFlow.flowComposer = new StandardFlowComposer();

			// The body text container is below, and has three columns
			bodyTextContainer = new Sprite();
			bodyController = new ContainerController(bodyTextContainer);
			bodyTextContainerFormat = new TextLayoutFormat();
			bodyTextContainerFormat.columnCount = 3;
			bodyTextContainerFormat.columnGap = 30;

			bodyController.format = bodyTextContainerFormat;
			bTextFlow.flowComposer.addController(bodyController);
			addChild(bodyTextContainer);
			resizeHandler(null);
		}

		private function resizeHandler(event:Event):void {
			const verticalGap:Number = 25;
			const stagePadding:Number = 16;
			var stageWidth:Number = stage.stageWidth - stagePadding;
			var stageHeight:Number = stage.stageHeight - stagePadding;
			var headlineWidth:Number = stageWidth;
			var headlineContainerHeight:Number = stageHeight;

			// Initial compose to get height of headline after resize
			headlineController.setCompositionSize(headlineWidth, headlineContainerHeight);
			hTextFlow.flowComposer.compose();
			var rect:Rectangle = headlineController.getContentBounds();
			headlineContainerHeight = rect.height;

			// Resize and place headline text container
			// Call setCompositionSize() again with updated headline height
			headlineController.setCompositionSize(headlineWidth, headlineContainerHeight );
			headlineController.container.x = stagePadding / 2;
			headlineController.container.y = stagePadding / 2;
			hTextFlow.flowComposer.updateAllControllers();

			// Resize and place body text container ;
			var bodyContainerHeight:Number = (stageHeight - verticalGap - headlineContainerHeight);
			bodyController.format = bodyTextContainerFormat;
			bodyController.setCompositionSize(stageWidth, bodyContainerHeight );
			bodyController.container.x = (stagePadding/2);
			bodyController.container.y = (stagePadding/2) + headlineContainerHeight + verticalGap;
			bTextFlow.flowComposer.updateAllControllers();
		}
	}
}

The result of the TLFNewsLayout class

The result of the TLFNewsLayout class

Decrement versus Increment in Loop 2

Adobe’s “Optimizing Performance for the Flash Platform” recommends that “Use reverse order for while loops” in its “Miscellaneous optimizations” section. And in my last post, decrement was not explicitly faster than increment with the following code to compare them:

while (--i > -1)

while (++i < MAX_NUMBER)  // MAX_NUMBER is a constant

Difference was very little in my Mac OS environment. But in Internet Explorer 7 and Firefox 3/Flash Player 10/Windows Vista, decrement was faster up to twenty percent than increment. After several trials, speed of operation between decrement and increment seems to be almost the same. The condition of loop does not care if expression is decrement or increment.

The difference came from value to be compared with a counter variable. The new sample script for increment below does not use a constant in the condition. Then its speed seems to be almost identical to the decrement's.

while (++i < <the literal number>)

Decrement versus Increment in Loop

Adobe’s “Optimizing Performance for the Flash Platform” recommends that “Use reverse order for while loops” in its “Miscellaneous optimizations” section.

while (--i > -1)

But according to my test significant difference could not be found between decrement and increment. In other language they said that decrement and increment are identical.

The pre-increment/decrement is a little faster than post, which is included in my test, though.

Quaternion notation of Vector3D

The [Help] of the Vecror3D.w property mentions about the quaternion notation as follows:

Quaternion notation employs an angle as the fourth element in its calculation of three-dimensional rotation. The w property can be used to define the angle of rotation about the Vector3D object.

But this sounds like explanation of the axis angle (see Orientation3D .AXIS_ANGLE Constant). The axis angle uses a combination of an axis and an angle to determine the rotation. For an argument of the Matrix3D.decompose() or Matrix3D.recompose() method Orientation3D.AXIS_ANGLE can be specified as the orientation style used for the matrix transformation.

Try to rotate a Matrix3D object 180 degrees (π) around the axis (1/√2, 1/√2, 0).

The axis of rotation

var myMatrix3D:Matrix3D = new Matrix3D();
var axis:Vector3D = new Vector3D(Math.SQRT1_2, Math.SQRT1_2,0);
myMatrix3D.prependRotation(180, axis);
var axisAngle:Vector3D = myMatrix3D.decompose(Orientation3D.AXIS_ANGLE)[1];
trace(axisAngle, axisAngle.w);

The frame action above outputs as follows:

Vector3D(0.7071067094802856, 0.7071068286895752, -2.339619844353034e-24) 3.1415927410125732

[Note]: 0.707… = 1/√2 and 3.14… = π radians = 180 degrees.

The (x, y, z) coordinates represents the axis and Vector3D.w property is an angle of the rotation. This result seems to fit the explanation of the [Help] quoted above.

But the quaternion notation determine the rotation by the four value. The following expression of the quaternion Q represents the rotation of θ around the vector U.

U = (x, y, z) and |U| = 1
Q = (cos(θ/2); sin(θ/2)U)

Then try to rotate a Matrix3D object 60 degrees around the y axis (0, 1, 0).

var myMatrix3D:Matrix3D = new Matrix3D();
myMatrix3D.prependRotation(60, Vector3D.Y_AXIS);
var quaternion:Vector3D = myMatrix3D.decompose(Orientation3D.QUATERNION)[1];
trace(quaternion.w, quaternion);

The frame action above outputs as follows:

0.8660253882408142 Vector3D(0, 0.4999999701976776, 0)

These numbers represent the quaternion of 60 degrees’ rotation.

0.866… = cos(60/2) = cos(30)
(0, 0.5, 0) = sin(60/2) (0, 1, 0)

Return value of Matrix3D.recompose() method

The [Help] of the Matrix3D.recompose() method tells about its return value as follows:

Returns false if any of the scale elements are zero.

But this is not true. Try the code below, in the 7th statement of which the third element, the z coordinate, of the scale Vector3D instance is set to zero.

var myMatrix3D:Matrix3D = new Matrix3D();
trace(myMatrix3D.decompose());
// Output: Vector3D(0, 0, 0),Vector3D(0, 0, 0),Vector3D(1, 1, 1)
var myVector:Vector.<Vector3D> = new Vector.<Vector3D>();
myVector.push(new Vector3D());  // translation
myVector.push(new Vector3D());  // rotation
myVector.push(new Vector3D(1, 1, 0));  // scale
trace(myMatrix3D.recompose(myVector));
// Output: true
trace(myMatrix3D.decompose());
// Output: Vector3D(0, -1.9986319541931152, 0),Vector3D(-1.5707963705062866, NaN, 0),Vector3D(7.667765755019554e-19, -1.998608112335205, 1.9719639421382673e-19)

The method returns true as long as the argument of Vector instance has three Vector3D elements. Therefore, the explanation in the [Help] should be rewritten as follows:

Returns false if any of the Vector3D elements of the Vector instance as the argument don’t exist or are null.

Note: The coordinates of Vector3D elements come to be invalid values if any of the scale elements are zero.

Calculation in the Utils3D.projectVectors() method

The Utils3D.projectVectors() method projects a Vector of three-dimensional space coordinates to a Vector of two-dimensional space coordinates. And the method also sets the t value of the uvt data.

Calculation in the Utils3D.projectVectors() method

Values for the calculation in the Utils3D.projectVectors() method

The Utils3D.projectVectors() method calculates t value of the uvt data by the following formula:

t value = 1 / (Distance to the origin + z coordinate value)

Also, the method calculates projected x and y values by the following formula:

Projected x or y value = Three-dimensional space x or y coordinate * Focal length * t value

The frame action below compares the results of calculation by the formulas above with the methods’. And [Output] is as follows:

0,0,0.0004 // uvt data
0.0004 // Calculated t value
20,20 // Projected x and y coordinates
20 // Calculated two-dimensional space x or y coordinate

var myPerspective:PerspectiveProjection = new PerspectiveProjection();
var myMatrix3D:Matrix3D = new Matrix3D();
var nDistance:Number = 1000;  // Distance to the origin
var nX:Number = 100;  // Three-dimensional space x or y coordinate
var nZ:Number = 1500;  // Three-dimensional z coordinate
var vertices3D:Vector.<Number> = Vector.<Number>([nX, nX, nZ]);
var vertices2D:Vector.<Number> = new Vector.<Number>();
var uvtData:Vector.<Number> = Vector.<Number>([0, 0, 0]);
var nT:Number = 1/(nDistance + nZ);  // t value
myPerspective.focalLength = 500;  // Focal length 
myMatrix3D.appendTranslation(0, 0, nDistance);
myMatrix3D.append(myPerspective.toMatrix3D());
Utils3D.projectVectors(myMatrix3D, vertices3D, vertices2D, uvtData);
trace(uvtData);  // uvt data
trace(nT);  // Calculated t value
trace(vertices2D);  // Projected x and y coordinates
trace(nX * myPerspective.focalLength * nT);  // Calculated two-dimensional space x or y coordinate

Rotating an instance with the y axis

Try to rotate a MovieClip instance named my_mc 80 degrees with the y axis. The trace() function in the code below displays information in the [Output] panel as follows:

80.00003182368921 1.3962639570236206

var nRotationY:Number = 80;
my_mc.rotationY = 0;
var myMatrix3D:Matrix3D = my_mc.transform.matrix3D;
myMatrix3D.prependRotation(nRotationY, Vector3D.Y_AXIS);
trace(my_mc.rotationY, myMatrix3D.decompose()[1].y);

Rotating an instance 80 degrees

Then change the number of degrees in the variable, nRotationY, to 100. The code seems to rotate an instance 100 degrees. However, the number of degrees shown in the [Output] panel is still 80.

80.00003182368921 1.3962639570236206

var nRotationY:Number = 100;  // 80;
my_mc.rotationY = 0;
var myMatrix3D:Matrix3D = my_mc.transform.matrix3D;
myMatrix3D.prependRotation(nRotationY, Vector3D.Y_AXIS);
trace(my_mc.rotationY, myMatrix3D.decompose()[1].y);

Rotating an instance 100 degrees

The following code reveals the reason.

0 80.00003182368921 0
Vector3D(0, 1.3962639570236206, 0)
180.00000500895632 80.00003182368921 180.00000500895632
Vector3D(3.1415927410125732, 1.3962639570236206, 3.1415927410125732)

var mySprite:Sprite = new Sprite();
var axis:Vector3D = Vector3D.Y_AXIS;  // Vector3D.X_AXIS  // Try to change this
mySprite.rotationY = 0;
var myMatrix3D:Matrix3D = mySprite.transform.matrix3D;
myMatrix3D.prependRotation(80, axis);
xTrace(mySprite);
myMatrix3D.prependRotation(20, axis);
xTrace(mySprite);
function xTrace(targetSprite:Sprite):void {
	trace(targetSprite.rotationX, targetSprite.rotationY, targetSprite.rotationZ);
	trace(targetSprite.transform.matrix3D.decompose()[1]);
}

When the Matrix3D.prependRotation() method rotates an instance 100 degrees with y axis, it is only rotated 80 degrees but is flipped with x and z axes.

The appearance of the instance is all right. But the number of degrees is not good. Besides, 100 degrees can be set with x or z axis. It means that the result of y axis is not consistent. Therefore, I suspect that this is a bug.

Three types of transformation objects in the Transform class

The Transform class has several kinds of transformation objects as its properties.

The Transform class provides access to color adjustment properties and two- or three-dimensional transformation objects that can be applied to a display object.

I noticed three types of properties from the point of view of getting and seting their values.

The first example is the Transform.matrix property. It does not provide its Matrix object reference but its copy. It means that operations to the copy will not affect to the property’s Matrix object. To set a Matrix object to the Transform.matrix property, the object should be assigned to the property.

var mySprite:Sprite = new Sprite();
var myMatrix:Matrix = new Matrix();
mySprite.transform.matrix = myMatrix;
myMatrix.translate(100, 50);
trace(mySprite.transform.matrix);
// Output: (a=1, b=0, c=0, d=1, tx=0, ty=0)
mySprite.transform.matrix = myMatrix;
trace(mySprite.transform.matrix);
// Output: (a=1, b=0, c=0, d=1, tx=100, ty=50)
myMatrix = mySprite.transform.matrix;
myMatrix.scale(2, 1.5);
trace(mySprite.transform.matrix);
// Output: (a=1, b=0, c=0, d=1, tx=100, ty=50)
trace(mySprite.transform.matrix == myMatrix);  // Output: false

The second example is the Transform.matrix3D property. Unlike to the Transform.matrix property, a Matrix3D object’s reference is obtained from the property. Therefore, once its reference is gotten, operations to the reference affects to the Transform.matrix3D property.

var mySprite:Sprite = new Sprite();
var myMatrix3D:Matrix3D = new Matrix3D();
mySprite.transform.matrix3D = myMatrix3D;
myMatrix3D.prependTranslation(100, 50, 0);
trace(mySprite.transform.matrix3D.position);
// Output: Vector3D(100, 50, 0)
trace(mySprite.transform.matrix3D == myMatrix3D);  // Output: true

The third one is the Transform.perspectiveProjection property. When a new PerspectiveProjection instance is assigned to the property, operations to the instance do not affect to the property as well as the Transform.matrix property. Then, try to get the object from the property and set it to a variable again. You can operate the variable as if it was the object reference of the property. However the variable’s object is not evaluated to be equal to the property’s value. It is a mysterious property, isn’t it.

var mySprite:Sprite = new Sprite();
var myPerspective:PerspectiveProjection = new PerspectiveProjection();
mySprite.transform.perspectiveProjection = myPerspective;
myPerspective.fieldOfView = 20;
trace(mySprite.transform.perspectiveProjection.fieldOfView);  // Output: 55
myPerspective = mySprite.transform.perspectiveProjection;
myPerspective.fieldOfView = 100;
trace(mySprite.transform.perspectiveProjection.fieldOfView);  // Output: 100
trace(mySprite.transform.perspectiveProjection == myPerspective);
// Output: false

“Private” classes might cause a compile error

BeInteractive! (blog written by Yoshihiro Shindo) reported a bug of “private” classes (defined outside of the package block). Two or more “private” classes might cause a compile error, which tells that a local variable declared in a main class (inside the package) is undefined in Flash CS4 Professional.

1120: Access of undefined property s.

Compile error #1120

Compile error #1120

I found another condition of the error. If a “private” class inherits a class other than Object the compile error will be prevented.

package {
	import flash.display.Sprite;
	public class PrivateClassIssue extends Sprite {
		public function PrivateClassIssue() {
			var s:String = 'hello';
			trace(s);
		}
	}
}
class Foo {}
class Bar extends Array {}  // inherits Array class

Calculation of focalLength

[Help] of PerspectiveProjection.focalLength property says:

During the perspective transformation, the focalLength is calculated dynamically using the angle of the field of view and the stage’s aspect ratio (stage width divided by stage height).

However as far as I tested it, the stage height does not affect the result of focalLength property’s value. It is calculated from only the stage width by the following formula:

tan(fieldOfView/2) = (stageWidth/2)/focalLength
focalLength = stageWidth/2 tan(fieldOfView/2)

From [Help] of PerspectiveProjection
*From [Help] of PerspectiveProjection

focal length and field of view

focal length and field of view

Therefore the function below returns focal length by passing field of view.

// Frame action
function getFocalLength(nFieldOfView:Number):Number {
	var falf_tan:Number = Math.tan(nFieldOfView / 2 * Math.PI / 180);
	return stage.stageWidth/2/falf_tan;
}


[Note]: With Stage.scaleMode property set to StageScaleMode.NO_SCALE, the value of Stage.stageWidth property can be changed when the browser window is resized. However the PerspectiveProjection.focalLength would be calculated by the original width of the stage set with the [Property] inspector.

The revised function below can return the right result in the case:

// Frame action
var originalMode:String = stage.scaleMode;
stage.scaleMode = StageScaleMode.EXACT_FIT;
var myStageWidth:int = stage.stageWidth;
stage.scaleMode = originalMode;
function getFocalLength(nFieldOfView:Number):Number {
	var falf_tan:Number = Math.tan(nFieldOfView / 2 * Math.PI / 180);
	// return stage.stageWidth/2/falf_tan;
	return myStageWidth/2/falf_tan;
}

Setting String to DataGridColumn.cellRenderer property

Reference of a class to render the items in a column can be set to DataGridColumn.cellRenderer property as the following frame action:

// Frame action
import fl.controls.DataGrid;
import fl.controls.dataGridClasses.DataGridColumn;
var myColmn:DataGridColumn = new DataGridColumn("data");
var myDataGrid:DataGrid = new DataGrid();
myDataGrid.addColumn(myColmn);
// myColmn.cellRenderer = "CustomCellRenderer";  // Error #2007
myColmn.cellRenderer = CustomCellRenderer;  // OK
myDataGrid.addItem({data: "test"});
addChild(myDataGrid);

[Help] also tells that the type of the property’s value can be String. However setting a String class name causes Error #2007 like the below. The error would be shown if the comment-outed statement was validated instead in the sample above.

TypeError:Error #2007:Parameter child must be non-null.

I happened to see DataGridColumn.cellRenderer property in ActionScript 2.0 Components Language Reference. It says that the property is “a linkage identifier for a symbol”.

Therefore, I tried to create an empty MovieClip symbol and to set the class to [Class] of [Linkage]. Then the String class name set to the property in the code above worked properly without an error. As my conclusion, a String class name might only be used for the class set to [Class] of [Linkage].

Symbol Properties

Resizing the drop down list of ComboBox when removeItem() is called

When items in a CombBox compnent instance are removed with ComboBox.removeItem() method, its size of drop down list will not be adjusted. I suspect that this behavior might be a bug because ComboBox.removeItemAt() method properly reset its size.

Combobox.removeItem() -> Combobox.removeitem()

In order to set size of the drop down list properly call UIComponent.validateNow() method after an item is removed with the method like the following code:

// Frame action
import fl.controls.ComboBox;
var myComboBox:ComboBox = new ComboBox();
addChild(myComboBox);
myComboBox.addEventListener(Event.CHANGE, xSelected);
myComboBox.addItem({label:"Dreamweaver CS4", data:"html"});
myComboBox.addItem({label:"Fireworks CS4", data:"png"});
myComboBox.addItem({label:"Flash CS4 Professional", data:"fla"});
function xSelected(eventObject:Event):void {
	var myItem:Object = myComboBox.getItemAt(0);
	myComboBox.removeItem(myItem);
	myComboBox.validateNow();  // Insert this statement.
}

In the ComboBox class ComboBox.removeItemAt() method calls UIComponent.invalidate() method after deleting an item with List.removeItemAt() method.

public function removeItemAt(index:uint):void {
	list.removeItemAt(index);
	invalidate(InvalidationType.DATA);
}

However, ComboBox.removeItem() method does not call the method.

public function removeItem(item:Object):Object {
	return list.removeItem(item);
}

Therefore, UIComponent.invalidate() method could be used instead of UIComponent.validateNow() method.

// Frame action
import fl.core.InvalidationType;
import fl.controls.ComboBox;
var myComboBox:ComboBox = new ComboBox();
addChild(myComboBox);
myComboBox.addEventListener(Event.CHANGE, xSelected);
myComboBox.addItem({label:"Dreamweaver CS4", data:"html"});
myComboBox.addItem({label:"Fireworks CS4", data:"png"});
myComboBox.addItem({label:"Flash CS4 Professional", data:"fla"});
function xSelected(eventObject:Event):void {
	var myItem:Object = myComboBox.getItemAt(0);
	myComboBox.removeItem(myItem);
	myComboBox.invalidate(InvalidationType.DATA);  // Insert this statement.
}

Vector3D.w property for multiplication

Vector3D.project() method in [Help] of Flash CS4 Professional says:

If the current Vector3D object is the result of multiplying a Vector3D object by a projection Matrix3D object, the w property can hold the transform value.

However a Vector3D.w property does not hold its original value. I suppose that the method for multiplication is the Matrix3D.transformVector(). Then see the result of the following script:

var myMatrix3D:Matrix3D = new Matrix3D();
var myVector3D:Vector3D = new Vector3D();
trace(myVector3D, myVector3D.w);  // Output: Vector3D(0, 0, 0) 0
myVector3D = myMatrix3D.transformVector(myVector3D);
trace(myVector3D, myVector3D.w);  // Output: Vector3D(0, 0, 0) 1

The default value of the Vector3D.w property is 0. But it is changed into 1 as the result of multiplication. The property does not hold the original value. No number multiplied by 0 can result to 1.

On the other hand, the Vector3D.add() and the Vector3D.subtract() methods reset Vector3D.w property to 0. The property is ignored by these methods.

While the Matrix3D.transformVector() method set the Vector3D.w property's value of the multiplying Vector3D instance to 1, the method does not ignore the property but multiplies it by the Matrix3D instance.

The code below creates a Matrix3D instance, of which the fourth row is set to [4, 3, 2, 5]. The result value of the Vector3D.w property after multiplication is 34. The value is the dot product of the multiplying Vector3D instance (whose Vector3D.w property is 1) and the fourth row of Matrix3D instance.

(4, 3, 2, 5)•(4, 3, 2, 1) = 4x4 + 3x3 + 2x2 + 5x1 = 34

Multiplying a Vector3D by a Matrix3D

var myMatrix3D:Matrix3D = new Matrix3D();
var myRawData:Vector.<Number> = myMatrix3D.rawData;
var myVector3D:Vector3D = new Vector3D(4,3,2);
trace(myVector3D, myVector3D.w);  // Output: Vector3D(4, 3, 2) 0
myRawData[3] = 4;
myRawData[7] = 3;
myRawData[11] = 2;
myRawData[15] = 5;
myMatrix3D.rawData = myRawData;
myVector3D = myMatrix3D.transformVector(myVector3D);
trace(myVector3D, myVector3D.w);  // Output: Vector3D(4, 3, 2) 34

I assume that the sentence in the [Help] quoted in this article implies this process. But it is hard to understand from the expression especially for non-english speaking people. At least it should be mentioned that the Vector3D.w property's value of the multiplying Vector3D instance is set to 1.