开发者

How to Place XML Node Value as Label Component's Text Value (in Flash/AS3)?

I'm querying an XML web service and am parsing 3 nodes per the code below. I want to send the resulting value to a label component. When I place the Label component on stage, and name it lowtemp_label, remove the default text value of Label and play the SWF, nothing shows up. How do I ensure that the lowtemp_label gets the returned low temp value?

private function onXmlLoaded(event:Event):void
    {
        XML.ignoreWhitespace = true;
        var urlLoader:URLLoader = event.currentTarget as URLLoader;
        var resultXML:XML = XML(url开发者_Python百科Loader.data);
        trace(resultXML.cc.tmp);
        trace(resultXML.cc.flik);
        trace(resultXML.cc.icon);

        var lowtemp_label :TextField = new TextField();
        addChild(lowtemp_label)
        var hitemp_label :TextField=new TextField();
        addChild(hitemp_label)
        var condicon_label :TextField=new TextField();
        addChild(condicon_label)

        lowtemp_label.text=resultXML.cc.tmp;
        hitemp_label.text=resultXML.cc.flik;
        condicon_label.text=resultXML.cc.icon;
        }

Thanks much:)


If this is your Document class (using the Flash IDE) and you have a label component on the stage, just remove the chunk of code where you're creating a new TextField.

var lowtemp_label :TextField = new TextField();
addChild(lowtemp_label)

In your code, "lowtemp_label" is a TextField instance in the scope of the function...you probably want to reference the label component that is on the stage and outside of the function scope.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜