<mx:Canvasxmlns:mx="http://www.adobe.com/2006/mxml" width="1000" height="800"> <mx:Script> <![CDATA[ import mx.core.UIComponent; import mx.controls.TextArea; import mx.containers.utilityClasses.ConstraintColumn; [Bindable] publicvar txt:String = "Cort¨¢zar is highly regarded as a master of short stories of a fantastic bent, with the collections Bestiario (1951)" + " and Final de Juego (1956) containing many of his best examples in the genre, including the remarkable /"Continuidad de los Parques/"" + " and /"Axolotl./""; privatefunction addText(event:Event):void { var text:TextArea = new TextArea(); addChild(text); text.text = txt; var constraintColumn:ConstraintColumn = new ConstraintColumn(); constraintColumn.id = "column"+numChildren.toString(); constraintColumns.push(constraintColumn); if(constraintColumns.length > 1) { for each(var col:ConstraintColumn in constraintColumns){ col.width = (width / (numChildren-2)); } }c onstraintColumn.width = (width / (numChildren-2)); text.setStyle("top", "row:30"); text.setStyle("bottom", "row:30"); text.setStyle("left", constraintColumn.id+":10"); text.setStyle("right", constraintColumn.id+":10"); } privatefunction addRow(event:Event):void { var constraintRow:ConstraintRow = new ConstraintRow(); constraintRows.push(constraintRow); constraintRow.id = "row"+constraintRows.length; for each(var row:ConstraintRow in constraintRows){ row.height = (height / (constraintRows.length-1)); } var i:int = Math.round(numChildren - (numChildren- 2)/constraintRows.length); while(i < numChildren){ var child:UIComponent = (getChildAt(i) as UIComponent); child.setStyle("top", "row"+constraintRows.length+":30"); child.setStyle("bottom", "row"+constraintRows.length+":30"); child.setStyle("left", (constraintColumns[i- (constraintColumns.length/2)-2] as ConstraintColumn).id+":10"); child.setStyle("right", (constraintColumns[i- (constraintColumns.length/2)-2] as ConstraintColumn).id+":10"); i++; }c onstraintColumns.length = constraintColumns.length / constraintRows.length; }