Flex不会在运行时设置标签文本

时间:2014-01-09 19:35:29

标签: flex text label

以下是弹性代码。它在启动时加载一个url并获取XML。 XML加载正常,我可以在trace中看到returnData [0] .name的值!但是当我尝试将值分配给标签时,标签只显示空文本...因为它删除了我的默认文本并替换为空,而不是returnData [0] .name ??如果我使用trace(),那个变量的值是“John”

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
                       xmlns:s="library://ns.adobe.com/flex/spark" 
                       xmlns:mx="library://ns.adobe.com/flex/mx" width="800" height="523" maxWidth="800" maxHeight="523" initialize="httpService.send()" showStatusBar="false" backgroundColor="white" backgroundAlpha="0">
    <fx:Script>
        <![CDATA[
            import mx.collections.ArrayCollection;
            import mx.rpc.events.ResultEvent;

            public var returnData:ArrayCollection;

            protected function httpService_handler(event:ResultEvent):void{
                returnData = event.result.people.person;

                testlabel.text = returnData[0].name;
            }
        ]]>
    </fx:Script>
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
        <s:HTTPService id="httpService" url="MYURL TO LOAD XML HERE" result="httpService_handler(event)" />
    </fx:Declarations>
    <s:BorderContainer borderVisible="false" mouseDown="nativeWindow.startMove();" skinClass="MainStyle" width="800" height="600" id="container" >
        <s:Label text="Original Text" id="testlabel"/>
    </s:BorderContainer>
</s:WindowedApplication>

这是皮肤:

<?xml version="1.0" encoding="utf-8"?>
<s:Skin xmlns:fx="http://ns.adobe.com/mxml/2009" 
        xmlns:s="library://ns.adobe.com/flex/spark" 
        xmlns:mx="library://ns.adobe.com/flex/mx">
    <!-- host component -->
    <fx:Metadata>
        [HostComponent("spark.components.BorderContainer")]
    </fx:Metadata>

    <!-- states -->
    <s:states>
        <s:State name="disabled" />
        <s:State name="normal" />
    </s:states>

    <!-- SkinParts
    name=contentGroup, type=spark.components.Group, required=false
    -->
    <s:Group id="container">
        <s:BitmapImage source="@Embed('/School Catchup/libs/images/App-BG8.png')" left="0" top="0" right="0" bottom="0" width="800" height="523" />
    </s:Group>
</s:Skin>

如果我取下skinClass它可以看到文字,但它几乎就像图像最终位于标签顶部..

0 个答案:

没有答案
相关问题