0

我正在尝试使用字符串更新多个<mx:text>对象。htmlText我遇到的问题是只有最后一个<mx:text>对象在数据更改时变得可见。

我错过了<mx:text>标签上的一些基本内容吗?

使用弹性 4.6

谢谢艺术

test1.html

<rtnA><![CDATA[ <font color="#0000ff" face="helvetica" size="15" >This is rtnA</font> ]]></rtnA>  
<rtnB>this is rtnB</rtnB>
<rtnC>this is rtnC</rtnC>
<rtnD><![CDATA[ <font color="#aa00aa" face="Arial" size="15" >This is </font><font color="#0000ff" face="helvetica" size="15" >rtnD</font> ]]></rtnD>

测试1.mxml

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
           xmlns:s="library://ns.adobe.com/flex/spark" 
           xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
<s:layout>
    <s:BasicLayout/>
</s:layout>
<fx:Declarations>
    <s:HTTPService id="sendMe" url="http://myUrl.com/test1.html"
                   useProxy="false" method="POST"  resultFormat="object"  >
    </s:HTTPService>
</fx:Declarations>
<fx:Script>
    <![CDATA[


        import mx.core.FlexGlobals;
        import mx.geom.RoundedRectangle;
        import mx.rpc.events.ResultEvent;

        import spark.events.TextOperationEvent; 

        [Bindable]
        public var meta:Object;

        public function send_data(event:MouseEvent, funRtn):void {
            var params:Object = new Object();
            if(funRtn == "A"){
                sendMe.send();
                sendMe.addEventListener("result",getResA);
            }
            if(funRtn == "B"){
                sendMe.send();
                sendMe.addEventListener("result",getResB);
            }
        }

        public function getResA(event:ResultEvent) : void{
            sendMe.removeEventListener("result",getResA);
            status.text="getResA";
            meta = event.result;
            if(meta.hasOwnProperty("rtnA")){
                if(meta.rtnA != null){
                    rtnAtxt.htmlText = meta.rtnA; 
                }   
            }
            if(meta.hasOwnProperty("rtnD")){
                if(meta.rtnD != null){
                    rtnDtxt.htmlText=  meta.rtnD;
                }
            }       
        }

        public function getResB(event:ResultEvent) : void{
            sendMe.removeEventListener("result",getResB);
            status.text="getResB";
            meta = event.result;
            if(meta.hasOwnProperty("rtnB")){
                if(meta.rtnB != null){
                    rtnAtxt.htmlText = meta.rtnB; 
                }   
            }
            if(meta.hasOwnProperty("rtnC")){
                if(meta.rtnC != null){
                    rtnDtxt.htmlText=  meta.rtnC;
                }
            }       
        }


    ]]>
</fx:Script>

<s:SkinnableContainer id="lisc" width="100%" height="100%"  >
    <s:Label id="status">
    </s:Label>

    <mx:Text id="rtnAtxt"  x="20" width="150"  y="20" height="50" >
    </mx:Text>  

    <mx:Text id="rtnDtxt" x="20" width="150" y="20" height="50" >
    </mx:Text>  

    <s:Form id="myForm" x="20"  width="150" y="90"  height="100"> 
        <s:FormItem>
            <s:Button id="myButtonA" width="50" height="20"
                      label="go A" click="send_data(event, 'A')" />
            <s:Button id="myButtonB" width="50" height="20"
                      label="go B" click="send_data(event,'B')" />
        </s:FormItem>
        <s:FormItem>

        </s:FormItem>
    </s:Form>
</s:SkinnableContainer>

4

1 回答 1

0

我看不出你的标签有什么问题。尝试在为每个侦听器指定的字段中打印出 meta.hasOwnProperty 值,这样您就可以查看结果是否确实是您认为的那样。

于 2012-09-07T18:10:31.900 回答