Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" encoding="utf-8"?>
- <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
- xmlns:s="library://ns.adobe.com/flex/spark"
- xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" creationComplete="onComplete()">
- <fx:Script>
- <![CDATA[
- import flashx.textLayout.container.ContainerController;
- import flashx.textLayout.edit.EditManager;
- import flashx.textLayout.edit.SelectionManager;
- import flashx.textLayout.elements.ParagraphElement;
- import flashx.textLayout.elements.SpanElement;
- import flashx.textLayout.elements.TableBodyElement;
- import flashx.textLayout.elements.TableCellElement;
- import flashx.textLayout.elements.TableColElement;
- import flashx.textLayout.elements.TableColGroupElement;
- import flashx.textLayout.elements.TableElement;
- import flashx.textLayout.elements.TableRowElement;
- import flashx.textLayout.elements.TextFlow;
- import flashx.textLayout.formats.TableFrame;
- import flashx.textLayout.formats.TableRules;
- import flashx.undo.UndoManager;
- import mx.events.FlexEvent;
- [Bindable]private var textFlow:TextFlow;
- private var table:TableElement;
- private var controller:ContainerController;
- private var undoManager:UndoManager;
- private function onComplete():void{
- textFlow = new TextFlow();
- undoManager = new UndoManager();
- textFlow.interactionManager = new EditManager(undoManager);
- table = new TableElement();
- //table.tableWidth = 600;
- table.columnCount = 4;
- //var body:TableBodyElement = new TableBodyElement();
- //table.addChild(body);
- for(var i:int=0;i<4;i++){
- addTableRow(4);
- //table.addChild(row);
- }
- var para:ParagraphElement = new ParagraphElement();
- var span:SpanElement = new SpanElement();
- span.text = "Let's try a table...";
- para.addChild(span);
- textFlow.addChild(para);
- /* para = new ParagraphElement();
- para.paragraphStartIndent = 3;
- span = new SpanElement();
- span.text = "before the table";
- para.addChild(span);
- para.addChild(table);
- span = new SpanElement();
- span.text = "after the table";
- para.addChild(span); */
- /*
- table = new TableElement();
- table.numColumns = 3;
- table.insertRow(); // or insertColumn()
- */
- /*
- para = new ParagraphElement();
- span = new SpanElement();
- span.text = "after the table...";
- para.addChild(span);
- */
- /* textFlow.addChild(para);
- para = new ParagraphElement();
- span = new SpanElement();
- span.text = "another para";
- para.addChild(span);
- textFlow.addChild(para); */
- controller = new ContainerController(holder,NaN,NaN);
- textFlow.flowComposer.addController(controller);
- textFlow.flowComposer.updateAllControllers();
- }
- private function addTableRow(numCells:int):void{
- var rowIdx:int = table.numRows;
- table.addRow();
- // var row:TableRowElement = new TableRowElement();
- // table.addChild(row);
- for(var i:int=0;i<numCells;i++){
- var cell:TableCellElement = new TableCellElement();
- cell.backgroundAlpha = 1;
- cell.backgroundColor = "#FF0000";//Math.random();
- cell.borderBottomColor = "#00FF00";
- cell.borderBottomWidth = 1;
- cell.borderRightColor = "#FF00FF";
- cell.borderRightWidth = 1;
- cell.paddingBottom = 7;
- cell.paddingTop = 7;
- cell.colIndex = i;
- cell.rowIndex = rowIdx;
- var para:ParagraphElement = new ParagraphElement();
- para.paragraphStartIndent = 3;
- var span:SpanElement = new SpanElement();
- span.text = "This is cell #" + i;
- para.addChild(span);
- var cellFlow:TextFlow = new TextFlow();
- cellFlow.addChild(para);
- cellFlow.interactionManager = new EditManager(undoManager);
- cell.textFlow = cellFlow;
- //cell.addChild(para);
- table.addChild(cell);
- }
- }
- ]]>
- </fx:Script>
- <s:SpriteVisualElement id="holder" width="100%" height="100%"/>
- <!-- <s:RichEditableText textFlow="{textFlow}" width="100%" height="100%"/> -->
- </s:Application>
Advertisement
Add Comment
Please, Sign In to add comment