Hi ,
I create this piece of code to demonstrate the problem I discovered
recently
This is an event listener from a RemoteObject call that return an
ArrayCollection with 2 entries of type Object .
private function getComplexStructResultHandler(event:ResultEvent):void
{
var result:ArrayCollection= event.result.data;
display.text="BEGIN_DEBUG-->";
for (var i:int=0 ;i<result.length; i++)
//for each (var data:Object in result)
{
var data:Object = result[i]
trace(data);
display.text = display.text + "BEGIN_ENTRY:" + data.ID + ":"+
data.Description +":"+data.Item_Category_Code +":"+ data.Unit_Cost+
":END_ENRTY";
}
display.text= display.text +"-->END_DEBUG";
}
The display is a label on screen and I got this output when I use the
js_debug version of code :
BEGIN_DEBUG-->BEGIN_ENTRY:10000011:Windows Apache and Webapi net (JSON)
:20:11.00000000:END_ENRTYBEGIN_ENTRY:10000012:Windows Apache and Webapi net
(JSON) :20 :1200.22000000:END_ENRTY-->END_DEBUG
When I use the js_release output the output is :
BEGIN_DEBUG-->BEGIN_ENTRY:undefined:undefined:10000011:undefined:END_ENRTYBE
GIN_ENTRY:undefined:undefined:10000012:undefined:END_ENRTY-->END_DEBUG
As a result
data.ID is undefined
data.Description is undefined
data.Item_Category_Code has the data.ID field Data
data.Unit_Cost is undefined
the JavaScript code generated by compiler in debug is :
/**
* @private
* @param {mx.rpc.events.ResultEvent} event
*/
CFcommunication.prototype.CFcommunication_getComplexStructResultHandler =
function(event) {
var /** @type {mx.collections.ArrayCollection} */ result =
event.result.data;
this.display.text = "BEGIN_DEBUG-->";
for (var /** @type {number} */ i = 0; i < result.length; i++) {
var /** @type {Object} */ data = result.getProperty(i);
org.apache.royale.utils.Language.trace(data);
this.display.text = this.display.text + "BEGIN_ENTRY:" + data.ID + ":" +
data.Description + ":" + data.Item_Category_Code + ":" + data.Unit_Cost +
":END_ENRTY";
}
this.display.text = this.display.text + "-->END_DEBUG";
};
In release the code is :
prototype.gr=function(a)
{
a=a.result.data;
this.display.text='BEGIN_DEBUG--\x3e';
for(var b=0;b<a.length;b++)
{
var c=a.pc(b);
this.display.text=this.display.text+'BEGIN_ENTRY:'+c.HD+':'+c.GD+':'+c.ID+':
'+c.JD+':END_ENRTY'
}this.display.text+='--\x3eEND_DEBUG'
};
When change this line of code :
display.text = display.text + "BEGIN_ENTRY:" + data.ID + ":"+
data.Description +":"+data.Item_Category_Code +":"+ data.Unit_Cost+
":END_ENRTY";
With this one
display.text = display.text + "BEGIN_ENTRY:" + data["ID"] + ":"+
data["Description"] +":"+data["Item_Category_Code"] +":"+ data["Unit_Cost"]+
":END_ENRTY";
I get the correct results
And the generated code in js-release folder for this function is
prototype.gr=function(a)
{
a=a.result.data;
this.display.text='BEGIN_DEBUG--\x3e';
for(var b=0;b<a.length;b++)
{
var c=a.pc(b);
this.display.text=this.display.text+'BEGIN_ENTRY:'+c.ID+':'+c.Description+':
'+c.Item_Category_Code+':'+c.Unit_Cost+':END_ENRTY'
}
this.display.text+='--\x3eEND_DEBUG'
}
Best regards
Spiros