How to adjust a div position?
well, here attempt adjust div container discovered can't apply styles declared. can please take look.
is ok me convert 'data' text_layout_format?
why aren't css styles being applied?
and orginal question, how can adjust/justify/move div element?
<?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="500" minheight="500" creationcomplete="application1_creationcompletehandler(event)"> <fx:style> @namespace s "library://ns.adobe.com/flex/spark"; @namespace mx "library://ns.adobe.com/flex/mx"; .body { font-size: 18; } .divright { padding-left: 100; padding-right: 100; } </fx:style> <fx:script> <![cdata[ 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 mx.events.flexevent; import spark.core.spritevisualelement; private var textflow:textflow; private var xml:xml = <flow> <div> <p id='body'>lorem ipsum dolor sit amet, consectetur adipisicing elit, sed eiusmod tempor incididunt ut labore et dolore magna aliqua.</p> </div> <div id='divright'> <p>hello.</p> </div> </flow> protected function application1_creationcompletehandler(event:flexevent):void { convertxmltotextflow(xml); } private function convertxmltotextflow(xml:xml):void { var sprite:spritevisualelement = new spritevisualelement(); var container:containercontroller = new containercontroller(sprite, 500, 500); var data:string = "<textflow xmlns='http://ns.adobe.com/textlayout/2008'>"+xml.children()+"</textflow>"; textflow = textconverter.importtoflow(data, textconverter.text_layout_format); textflow.flowcomposer = new standardflowcomposer(); textflow.formatresolver = new cssformatresolvertlf(); textflow.flowcomposer.addcontroller(container); group.addelement(sprite); textflow.flowcomposer.updateallcontrollers(); } ]]> </fx:script> <s:group id="group"/> </s:application>
i able "move" div left or right assigning 2 columns. unable answer first 2 questions:
is ok me convert 'data' text_layout_format?
why aren't css styles being applied?
below updated sample showing how "move" div. works inlinegraphicelement too.
<?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="500" minheight="500" creationcomplete="application1_creationcompletehandler(event)"> <fx:style> @namespace s "library://ns.adobe.com/flex/spark"; @namespace mx "library://ns.adobe.com/flex/mx"; .body { font-size: 18; } </fx:style> <fx:script> <![cdata[ import flashx.textlayout.compose.standardflowcomposer; import flashx.textlayout.container.containercontroller; import flashx.textlayout.container.scrollpolicy; import flashx.textlayout.conversion.textconverter; import flashx.textlayout.elements.flowgroupelement; import flashx.textlayout.elements.textflow; import flashx.textlayout.formats.direction; import flashx.textlayout.formats.textlayoutformat; import mx.events.flexevent; import spark.core.spritevisualelement; private var textflow:textflow; private var xml:xml = <flow> <div> <p id='body'>lorem ipsum dolor sit amet, consectetur adipisicing elit, sed eiusmod tempor incididunt ut labore et dolore magna aliqua.</p> </div> <div stylename='divright'> <p>hello.</p> </div> </flow> protected function application1_creationcompletehandler(event:flexevent):void { convertxmltotextflow(xml); } private function convertxmltotextflow(xml:xml):void { var sprite:spritevisualelement = new spritevisualelement(); var container:containercontroller = new containercontroller(sprite, 500, 500); var data:string = "<textflow xmlns='http://ns.adobe.com/textlayout/2008'>"+xml.children()+"</textflow>"; textflow = textconverter.importtoflow(data, textconverter.text_layout_format); textflow.flowcomposer = new standardflowcomposer(); textflow.formatresolver = new cssformatresolvertlf(); textflow.flowcomposer.addcontroller(container); splitdivelements(); group.addelement(sprite); textflow.flowcomposer.updateallcontrollers(); } private function splitdivelements():void { var divrighttags:array = textflow.getelementsbystylename("divright"); for each(var divelement:flowgroupelement in divrighttags) { divelement.columncount = 2; divelement.columnwidth = 250; divelement.direction = direction.rtl; } } ]]> </fx:script> <s:group id="group"/> </s:application>
More discussions in Text Layout Framework
adobe
Comments
Post a Comment