Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/flash/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flash AS3 htmlText正在自行重新排列字体标记_Flash_Actionscript 3 - Fatal编程技术网

Flash AS3 htmlText正在自行重新排列字体标记

Flash AS3 htmlText正在自行重新排列字体标记,flash,actionscript-3,Flash,Actionscript 3,我在AS3中有以下代码: var str:String = '<TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="Arial" SIZE="12" COLOR="#000000" LETTERSPACING="0" KERNING="0">Lo<FONT COLOR="#0000FF">re<FONT FACE="GG Superscript">m</FONT></F

我在AS3中有以下代码:

var str:String = '<TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="Arial" SIZE="12" COLOR="#000000" LETTERSPACING="0" KERNING="0">Lo<FONT COLOR="#0000FF">re<FONT FACE="GG Superscript">m</FONT></FONT><FONT FACE="GG Superscript"> Ip</FONT><FONT COLOR="#990000"><FONT FACE="GG Superscript">su</FONT>m i</FONT>s simply dummy text </FONT></P></TEXTFORMAT>';

trace('BEFORE: '+str);

txt.htmlText = str;

trace('AFTER: '+txt.htmlText);
var-str:String='

Lorem-Ipsum只是一个伪文本; 跟踪('BEFORE:'+str); txt.htmlText=str; 跟踪('AFTER:'+txt.htmlText);

我面临的问题是,跟踪前后的文本非常不同。详情如下:

跟踪前

<TEXTFORMAT LEADING="2">
    <P ALIGN="LEFT">
        <FONT FACE="Arial" SIZE="12" COLOR="#000000" LETTERSPACING="0" KERNING="0">Lo
            <FONT COLOR="#0000FF">re
                <FONT FACE="GG Superscript">m</FONT>
            </FONT>
            <FONT FACE="GG Superscript"> Ip</FONT>
            <FONT COLOR="#990000">
                <FONT FACE="GG Superscript">su</FONT>
                m i
            </FONT>
            s simply dummy text 
        </FONT>
    </P>
</TEXTFORMAT>
<TEXTFORMAT LEADING="2">
    <P ALIGN="LEFT">
        <FONT FACE="Arial" SIZE="12" COLOR="#000000" LETTERSPACING="0" KERNING="0">Lo
            <FONT COLOR="#0000FF">re
                <FONT FACE="GG Superscript">m
                    <FONT COLOR="#000000"> Ip
                        <FONT COLOR="#990000">su
                            <FONT FACE="Arial">m i</FONT>
                        </FONT>
                    </FONT>
                </FONT>
            </FONT>s simply dummy text 
        </FONT>
    </P>
</TEXTFORMAT>

瞧 重新 M 知识产权 苏 我 它只是虚拟文本

跟踪后

<TEXTFORMAT LEADING="2">
    <P ALIGN="LEFT">
        <FONT FACE="Arial" SIZE="12" COLOR="#000000" LETTERSPACING="0" KERNING="0">Lo
            <FONT COLOR="#0000FF">re
                <FONT FACE="GG Superscript">m</FONT>
            </FONT>
            <FONT FACE="GG Superscript"> Ip</FONT>
            <FONT COLOR="#990000">
                <FONT FACE="GG Superscript">su</FONT>
                m i
            </FONT>
            s simply dummy text 
        </FONT>
    </P>
</TEXTFORMAT>
<TEXTFORMAT LEADING="2">
    <P ALIGN="LEFT">
        <FONT FACE="Arial" SIZE="12" COLOR="#000000" LETTERSPACING="0" KERNING="0">Lo
            <FONT COLOR="#0000FF">re
                <FONT FACE="GG Superscript">m
                    <FONT COLOR="#000000"> Ip
                        <FONT COLOR="#990000">su
                            <FONT FACE="Arial">m i</FONT>
                        </FONT>
                    </FONT>
                </FONT>
            </FONT>s simply dummy text 
        </FONT>
    </P>
</TEXTFORMAT>

瞧 重新 M 知识产权 苏 我 它只是虚拟文本

htmlText似乎正在重新排列html标记。尽管输出是相同的,但我需要返回原始html,因为我正在制作一个文本编辑器,而后面的htmlText会扰乱我的标记计算。你知道这里能做什么吗


提前感谢。

项目是否要求使用
标签进行样式设置?对基本HTML标记样式的支持非常有限,并且在Flash文本字段中存在缺陷。我强烈建议使用CSS使用
flash.text.Stylesheet
类格式化文本。你会发现它更可靠,你的代码也更干净


查看文本字段中CSS的干净实现。

如果您决定使用CSS和flash,这也是一个非常好的库: