How to define bullets in Flash TLFTextField?

163 views Asked by At

I'm using Flash's TLFTextField in a flex project. We can add bullets in TLFTextField using HTMLText(li), but how can I add bullets to TLFTextField without using HTMLText?

I can do bullets in Flash's classic TextField using the bullet property of TextFormat.

2

There are 2 answers

0
Rasekaran On BEST ANSWER

This is not a solid fix but this solved my problem. I share my code so that it may help anyone who come across this issue.

// Imagine you have to apply bullet to the text index between beginIndex, endIndex
var index : int = beginIndex; 
var le : FlowLeafElement = this.textFlow.findLeaf( index + 1 );

var listEle : ListElement = new ListElement();
while( le && index < endIndex ) {

    if( le ){

        var p : ParagraphElement = le.getParagraph();

        if( p ) {

            index += p.getText().length + 1;

            if ( p.getText().length > 0 && ( !( p.parent is ListItemElement ) ) ) {

                var childIndex : int = this.textFlow.getChildIndex( p );
                this.textFlow.removeChild( p );

                listEle = new ListElement();
                var listItem : ListItemElement = new ListItemElement();
                listItem.addChild( p );
                listEle.addChild( listItem );

                if( childIndex >= 0 ){
                    this.textFlow.addChildAt( childIndex, listEle );
                } else {
                    this.textFlow.addChild( listEle );
                }
            }
        }
    }
    le = le.getNextLeaf();
}
1
krishnaja mavatoor On

Try this

var pText:String =       "<list listStylePosition='inside' listStyleType='disc' afterFormat = '\t' paddingLeft = '30' tabStops='e100 s700'>" +  
                         "<li><p>Mango</p></li>" +  
                         "<li><p>Apple</p></li>" +  
                         "</list>";                       


                    var t:TLFTypographicCase;  
                    textLayoutFormat = new TextLayoutFormat();  
                    //textLayoutFormat.color = "#ffffff";  
                    textLayoutFormat.fontFamily = "Myriad Pro";  
                    textLayoutFormat.fontSize = 36;  

                    textLayoutFormat.paragraphSpaceBefore = 12;  



                    linkNormal = new TextLayoutFormat();  
                    linkNormal.color = 0x26e1fd;  
                    linkNormal.fontFamily = textLayoutFormat.fontFamily;  
                    linkNormal.fontSize = textLayoutFormat.fontSize;  


                    richTextArea.textFlow = TextFlowUtil.importFromString(pText);  
                    richTextArea.textFlow.format = textLayoutFormat;  
                    richTextArea.textFlow.linkNormalFormat = linkNormal;

Please check this link for further help.. https://forums.adobe.com/thread/787203?tstart=0

Hope this helps