`
hanyiduo
  • 浏览: 77412 次
  • 性别: Icon_minigender_1
  • 来自: 沈阳
社区版块
存档分类
最新评论

(flex4)循环随机改变FxTextArea内的字体颜色

    博客分类:
  • Flex
阅读更多
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/12/06/looping-over-paragraphs-in-the-fxtextarea-control-in-flex-gumbo/ -->
<Application name="FxTextArea_export_test"
        xmlns="http://ns.adobe.com/mxml/2009"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white">

    <Script>
        private function getParagraphs():void {
            var textFlowNS:Namespace = new Namespace("http://ns.adobe.com/textLayout/2008");

            var xml:XML = textArea.export();
            var xmlList:XMLList = xml.textFlowNS::p;
            var para:XML;
            for each (para in xmlList) {
                para.@color = getRandomColor();
            }
            textArea.content = xml;
        }

        private function getRandomColor():String {
            return "0x" + Math.round(Math.random() * 0xFFFFFF).toString(16);
        }
    </Script>

    <ApplicationControlBar dock="true">
        <FxButton label="Randomize paragraph colors"
                click="getParagraphs();" />
    </ApplicationControlBar>

    <FxTextArea id="textArea" width="240" height="160">
        <content>
            <p>The quick brown fox jumped over the lazy dog.</p>
            <p>The quick brown fox jumped over the lazy dog.</p>
            <p>The quick brown fox jumped over the lazy dog.</p>
            <p>The quick brown fox jumped over the lazy dog.</p>
            <p>The quick brown fox jumped over the lazy dog.</p>
            <p>The quick brown fox jumped over the lazy dog.</p>
            <p>The quick brown fox jumped over the lazy dog.</p>
            <p>The quick brown fox jumped over the lazy dog.</p>
            <p>The quick brown fox jumped over the lazy dog.</p>
            <p>The quick brown fox jumped over the lazy dog.</p>
            <p>The quick brown fox jumped over the lazy dog.</p>
            <p>The quick brown fox jumped over the lazy dog.</p>
            <p>The quick brown fox jumped over the lazy dog.</p>
            <p>The quick brown fox jumped over the lazy dog.</p>
            <p>The quick brown fox jumped over the lazy dog.</p>
        </content>
    </FxTextArea>

</Application>

分享到:
评论
1 楼 荷尔萌 2013-10-13  
只能说。。。这是超级烂的代码

相关推荐

Global site tag (gtag.js) - Google Analytics