about_ Flex TextBinding
<?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" creationComplete="creationCompleteHandler(event)"> <fx:Script> <![CDATA[ import flashx.textLayout.container.ContainerController; import flashx.textLayout.conversion.TextConverter; import flashx.textLayout.edit.EditManager; import flashx.textLayout.elements.TextFlow; import mx.core.UIComponent; import mx.events.FlexEvent; static private const simpleText:* = <TextFlow xmlns='http://ns.adobe.com/textLayout/2008' fontSize='14' textIndent='15' marginBottom='15' paddingTop='4' paddingLeft='4'></TextFlow>; protected function creationCompleteHandler(event:FlexEvent):void { var _container:Sprite = new Sprite(); var ui:UIComponent=new UIComponent(); ui.addChild(_container); editor.addElement(ui); editor.tabFocusEnabled = false; var textFlow:TextFlow = TextConverter.importToFlow(simpleText, TextConverter.TEXT_LAYOUT_FORMAT); textFlow.flowComposer.addController(new ContainerController(_container,editor.width,editor.height)); textFlow.interactionManager = new EditManager(); textFlow.interactionManager.selectRange(0,0); textFlow.interactionManager.setFocus(); } ]]> </fx:Script> <s:BorderContainer backgroundColor="0x999999" horizontalCenter="0" verticalCenter="0" id="editor" /> </s:Application>
posted on 2012-04-27 12:51 破阵子 . 如是我闻 阅读(221) 评论(0) 编辑 收藏 举报