Skip to main content
Known Participant
September 23, 2009
Answered

Error by textLayout.swc in Flex SDK3.4

  • September 23, 2009
  • 3 replies
  • 1506 views

Hi

     I wrote code using textLayout.swc in flex 3 Bulider (SDK3.4Ver)

     It generates error with ParaGraphFormat, CharacterFormat,DisplayObjectContainerController and UpadateAllContainers

     these all are not supported if i use single textLayout.swc,if i use three textLayout_conversion.swc,textLayout_edit.swc and textLayout_core.swc      then its working fine.

     Here is code and file is also find the attachment

package XmlParser
{
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.text.FontStyle;
    import flash.text.engine.FontWeight;
    import flash.xml.XMLNode;
   
    import flashx.textLayout.container.DisplayObjectContainerController;
    import flashx.textLayout.elements.BreakElement;
    import flashx.textLayout.elements.InlineGraphicElement;
    import flashx.textLayout.elements.LinkElement;
    import flashx.textLayout.elements.ParagraphElement;
    import flashx.textLayout.elements.SpanElement;
    import flashx.textLayout.elements.TextFlow;
    import flashx.textLayout.formats.CharacterFormat;
    import flashx.textLayout.formats.ParagraphFormat;
    import flashx.textLayout.formats.TextAlign;
    import flashx.textLayout.formats.TextDecoration;
   
    public class TextFlowInfo
    {
        private var paragraphNode:XMLNode = null;
        private var runPrntNode:XMLNode = null;
        private var paraIndex:int =0;
        private var paraLineSize:Number=0;
        private var paraMargin:Number =0;
        private var paraIndent:Number = 0;
        private var paraTextAlign:String = null;
       
        private var runIndex:int =0;
        private var runLanguage:String = null;
        private var txtLineBreak:Boolean = false;
        private var fontSize:Number =0;
        private var fontName:String = null;
        private var textDecoration:Boolean = false;
        private var fontStyle:Boolean = false;
        private var fontWeight:Boolean = false;
        private var runColorType:String = null;
        private var fontColor:int = 0;
       
        private var innerText:String = null;
       
        private var insetNode:XMLNode;
        public function set InsetNode(value:XMLNode):void{
            insetNode = value;
        }
       
        private var paragraphPrntNode:XMLNode;
        public function set ParagraphPrntNode(value:XMLNode):void{
            paragraphPrntNode = value;
        }
   
       
        private var containerWidth:Number;
        public function set ContainerWidth(value:Number):void{
            containerWidth = value;
        }
        private var titleAlign:String;
        public function set TitleAlign(value:String):void{
            titleAlign = value;
        }
       
        private var containerHeight:Number;
        public function set ContainerHeight(value:Number):void{
            containerHeight = value;
        }
        private var verAlign:String = null;
        /* public function set VerAlign(value:String):void{
            verAlign = value;
        } */
        private var textFlow:TextFlow;
        private var paraElement:ParagraphElement= null;
        private var paraFormat:ParagraphFormat = null;
        private var spanElement:SpanElement = null;
        private var charFormat:CharacterFormat = null;
        private var brkElement:BreakElement = null;
        private var bulletType:String = null;
        private var bulletFont:String= null;
        private var bulletSize:Number =0;
        private var bulletcolor:int=0;
        private var bulletTxt:String = null;
        private var bulletImgPath:String = null;
       
        private var leftInset:Number = 0;
        private var rightInset:Number = 0;
        private var topInset:Number = 0;
        private var btmInset:Number = 0;
       
        private var linkRef:String = null;
        private var linkHref:String = null;
        private var isHyperlink:Boolean = false;
       
        public function LoadParagraphNode(textContainer:Sprite):void
        {
            textFlow = new TextFlow();           
            if(titleAlign != null){
                //trace("Para Align I : "+ titleAlign);
                textFlow.textAlign = "center";
            }
            if(insetNode != null){
                if(insetNode.attributes["lIns"]!= undefined){
                    textFlow.paddingLeft = parseFloat(insetNode.attributes["lIns"]);
                }
                if(insetNode.attributes["rIns"]!= undefined){
                    textFlow.paddingRight = parseFloat(insetNode.attributes["rIns"]);
                }
                if(insetNode.attributes["tIns"]!= undefined){
                    textFlow.paddingTop = parseFloat(insetNode.attributes["tIns"]);
                }
                if(insetNode.attributes["bIns"]!= undefined){
                    textFlow.paddingBottom = parseFloat(insetNode.attributes["bIns"]);
                }
                if(insetNode.attributes["valign"]!= undefined){
                    verAlign = insetNode.attributes["valign"];
                    if(verAlign != null){
                        //trace("Align : " + verAlign);
                        textFlow.verticalAlign = "middle";   
                    }   
                }
                //trace("Inset Node : "+ insetNode.attributes["lIns"] +","+insetNode.attributes["rIns"]+","+insetNode.attributes["tIns"]+","+insetNod e.attributes["bIns"]);
            }


           
            var paraChildLength:int = paragraphPrntNode.childNodes.length;
            //trace("Graph ParaNode : "+ paraChildLength);
            //textFlow.verticalAlign = "middle";
            for(var i:int = 0 ; i<paraChildLength;i++)
            {  
                paragraphNode = paragraphPrntNode.childNodes;
               
                if(paragraphNode.attributes["index"]!= undefined)
                {
                    paraIndex = parseInt(paragraphNode.attributes["index"]);
                }
                if(paragraphNode.attributes["linesize"]!= undefined)
                {
                    paraLineSize = parseFloat(paragraphNode.attributes["linesize"]);
                }
                if(paragraphNode.attributes["marl"]!= undefined)
                {
                    paraMargin = parseFloat(paragraphNode.attributes["marl"]);
                }
                if(paragraphNode.attributes["indent"]!= undefined)
                {
                    paraIndent = parseFloat(paragraphNode.attributes["indent"]);
                }
               
                if(paragraphNode.attributes["algn"]!= undefined)
                {
                    paraTextAlign = paragraphNode.attributes["algn"];
                }
                paraElement = new ParagraphElement();
                //textFlow.addChild(paraElement);
                paraFormat = new ParagraphFormat();
                //paraFormat.textIndent = paraMargin;
                paraFormat.marginLeft = paraMargin;
               
                if(paraTextAlign == "l"){
                    paraFormat.textAlign = TextAlign.LEFT;
                }
                else if(paraTextAlign == "r"){
                    paraFormat.textAlign = TextAlign.RIGHT;
                }
                else if(paraTextAlign == "j"){
                    paraFormat.textAlign = TextAlign.JUSTIFY;
                }
                else if(paraTextAlign == "ctr"){
                    //trace("Para : textA "+ paraTextAlign);
                    paraFormat.textAlign = TextAlign.CENTER;
                }
                paraElement.paragraphFormat = paraFormat;
                //trace(" Shape Para :  "+ paraIndex+","+paraLineSize+","+paraMargin+","+paraIndent+","+ paraTextAlign);
                if(paragraphNode.childNodes.length >0 && paragraphNode.lastChild.nodeName =="runs")
                {
                    for each(var paraChildNd:XMLNode in paragraphNode.childNodes)
                    {   
                        switch(paraChildNd.nodeName.toLowerCase())
                        {                            
                            case "runs":
                                runPrntNode = paragraphNode.lastChild;
                                //trace("Graph Run : " + runPrntNode);
                                for each(var runNode:XMLNode in runPrntNode.childNodes)
                                {
                                    //trace("Run Para : "+ runNode);
                                    if(runNode.attributes["index"]!= undefined)
                                    {
                                        runIndex = parseInt(runNode.attributes["index"]);
                                    }
                                    if(runNode.attributes["linebreak"]!= undefined)
                                    {
                                        var lnBreak:String =  runNode.attributes["linebreak"];
                                        if(lnBreak == "t"){
                                            txtLineBreak = true;
                                        }
                                    }
                                    if(runNode.attributes["fontsize"]!= undefined)
                                    {
                                        fontSize = parseFloat(runNode.attributes["fontsize"]);
                                    }
                                    if(runNode.attributes["lang"]!= undefined)
                                    {
                                        runLanguage = runNode.attributes["lang"];
                                    }
                                    if(runNode.attributes["fontname"]!= undefined)
                                    {
                                        fontName = runNode.attributes["fontname"];
                                    }
                                    if(runNode.attributes["i"]!= undefined)
                                    {
                                        var tempStyle:String = runNode.attributes["i"];
                                        if(tempStyle =="1"){
                                            fontStyle = true;
                                        }
                                    }
                                    if(runNode.attributes["b"]!= undefined)
                                    {
                                        var tempwght:String = runNode.attributes["b"];
                                        if(tempwght =="1"){
                                            fontWeight = true;
                                        }
                                    }
                                    if(runNode.attributes["b"]!= undefined)
                                    {
                                        var tempDeco:String = runNode.attributes["underline"];
                                        if(tempDeco =="sng"){
                                            textDecoration = true;
                                        }
                                    }
                                    if(runNode.attributes["underline"]!= undefined)
                                    {
                                        textDecoration = runNode.attributes["underline"];
                                    }
                                    //trace("Shape Run :  "+fontSize+","+fontColor+","+fontName+","+ fontStyle+","+fontWeight);                                   
                                    /* if(runNode.lastChild.firstChild != null)
                                    {
                                        innerText = runNode.lastChild.firstChild .toString();
                                    } */
                                    for each(var runChildNd:XMLNode in runNode.childNodes){
                                        //trace("Graph Para<> : "+ runChildNd);
                                        switch(runChildNd.nodeName.toLowerCase()){                                            
                                            case "fill":
                                               
                                                if(runChildNd.attributes["type"]!= undefined)
                                                {
                                                    runColorType = runChildNd.attributes["type"];
                                                }
                                                if(runNode.firstChild.attributes["color"]!= undefined)
                                                {
                                                    fontColor = parseInt(runChildNd.attributes["color"]);
                                                }
                                                //trace("Color : "+ runColorType +","+ fontColor);
                                            break;
                                            case "text":
                                                if(runChildNd.firstChild != null)
                                                {
                                                    innerText = runChildNd.firstChild .toString();
                                                }
                                            break;
                                        }
                                        //trace("Graph InnerText "+ innerText);
                                    }                                   
                                    spanElement = new SpanElement();
                                    paraElement.addChild(spanElement);
                                                                       
                                    spanElement.text = innerText;                                       
                                    charFormat = new CharacterFormat();   
                                    charFormat.fontFamily = fontName;
                                    if(fontStyle == true)
                                    {
                                        charFormat.fontStyle = FontStyle.ITALIC;
                                        fontStyle = false;
                                    }
                                    if(fontWeight == true)
                                    {
                                        charFormat.fontWeight = FontWeight.BOLD;
                                        fontWeight = false;
                                    }
                                    if(textDecoration == true)
                                    {
                                        charFormat.textDecoration = TextDecoration.UNDERLINE;
                                        textDecoration = false;
                                    }
                                    charFormat.fontSize = Number(fontSize);
                                    //charFormat.fontSize = 18;
                                    //trace("Run Text "+spanElement.text +","+ charFormat.fontSize );   
                                    //charFormat.color = Number(fontColor);
                                    charFormat.color = 0xFFFFFF;
                                   
                                    spanElement.characterFormat = charFormat;
                                    if(txtLineBreak == true)
                                    {
                                        brkElement = new BreakElement();
                                        paraElement.addChild(brkElement);
                                        txtLineBreak = false;
                                    }
                                    //trace("Shape Text :  "+fontName +","+ fontSize);
                                }
                            break;
                            case "bullet":                               
                               
                            break;                           
                        }
                    }
                }
                else{
                    //trace("Para Break :");
                    brkElement = new BreakElement();
                    paraElement.addChild(brkElement);
                }
                textFlow.addChild(paraElement);
            }
            //this.dispatchEvent(new Event("SuccessfullyAdded"));
            textFlow.flowComposer.addController( new DisplayObjectContainerController(textContainer,containerWidth,containerHeight)) ;
            textFlow.flowComposer.updateAllContainers();
        }       
       
    }
}

Also find the Attachment!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1

Please Reply

This topic has been closed for replies.
Correct answer Camussx

If you use textLayout.swc then replace:

ParaGraphFormat, CharacterFormat for TextLayoutFormat

DisplayObjectContainerController for ContainerController

UpadateAllContainers for UpdateAllControllers()

3 replies

Camussx
Inspiring
September 23, 2009

Also, check the answer of Richard. The API has change since the initial release.

Camussx
CamussxCorrect answer
Inspiring
September 23, 2009

If you use textLayout.swc then replace:

ParaGraphFormat, CharacterFormat for TextLayoutFormat

DisplayObjectContainerController for ContainerController

UpadateAllContainers for UpdateAllControllers()

Adobe Employee
September 23, 2009

Those errors are all correct.  There have been many API changes since the initial release.  There are releasenotes posted with Flex as well as documentation on the latest TLF APIs.

This blog entry from February may help.

http://blogs.adobe.com/tlf/2009/02/tlf-api-changes-in-build-370-1.html

Richard

Known Participant
September 24, 2009

Thanks a lot for reply all answers are helpful