Hi,

This simple example that makes JSON call and displays the results:

<?xml version="1.0" encoding="utf-8"?>
<js:Application xmlns:fx="http://ns.adobe.com/mxml/2009";
                xmlns:js="library://ns.apache.org/royale/basic"
                applicationComplete="callSever()">

    <js:beads>
        <js:ApplicationDataBinding />
    </js:beads>

    <fx:Script><![CDATA[        
        import org.apache.royale.events.Event;
        import org.apache.royale.net.HTTPConstants;
        import org.apache.royale.net.HTTPService;

        protected var service:HTTPService;

        [Bindable] protected var description:String;
        [Bindable] protected var homepage:String;

        public function callSever():void {
            service = new HTTPService();
            service.url = "https://projects.apache.org/json/projects/flex.json";;
            service.method = HTTPConstants.POST;
            service.addEventListener(Event.COMPLETE, projectInfo);
            service.send();
        }

        public function projectInfo(event:Event):void {
            var info:Object = JSON.parse(service.data);
            var status:int = service.status;

            if (status == 200) {
                description = info.shortdesc;
                homepage = info.homepage;
            }
            service.removeEventListener(Event.COMPLETE, projectInfo);
            service = null;
        }
        ]]></fx:Script>

    <js:valuesImpl>
        <js:SimpleCSSValuesImpl/>
    </js:valuesImpl>

    <js:initialView>
        <js:View>
            <js:VContainer>
                <js:Label text="Project info" />
                <js:MultilineLabel text="{description}" width="500" />
                <js:Label text="{homepage}" />
            </js:VContainer>
        </js:View>
    </js:initialView>

</js:Application>


Works as expected in debug and displays:
Project info
Apache Flex® is a highly productive, open source application framework for 
building and maintaining expressive web applications that deploy consistently 
on all major browsers, desktops and devices (including smartphones, tablets and 
tv).
http://flex.apache.org

The release version however displays:
Project info
undefined
http://flex.apache.org

In both case the JSON is correctly asked for and returned. A 
console.log(info.shortdesc); gives undefined in the production version but 
console.log(info[“shortdesc”]) works. Is this a known issue? Is seems odd that 
homepage works while shortdesc doesn’t.

Thanks,
Justin


Reply via email to