要把一个字符串传到Flex前台~ 已经写好,结果又需要传多一个,不想改太多~
正好闲来无事,就想用用Json~
其实也很简单,就改一点点~(仅示改动地方)
一般情况下会没有包含com.adobe.serialization这个包的包,我给附上了~
就这么简单,然后在后台里修改相应返回值为Json格式就行了~
正好闲来无事,就想用用Json~
其实也很简单,就改一点点~(仅示改动地方)
...
import com.adobe.serialization.json.JSON;
...
private function someHandle():void {
//get the raw JSON data and cast to String
var rawData:String = String(event.result);
//decode the data to ActionScript using the JSON API
//in this case, the JSON data is a serialize Array of Objects.
var arr:Array = (JSON.decode(rawData) as Array);
//create a new ArrayCollection passing the de-serialized Array
//ArrayCollections work better as DataProviders, as they can
//be watched for changes.
var dp:ArrayCollection = new ArrayCollection(arr);
//pass the ArrayCollection to the DataGrid as its dataProvider.
grid.dataProvider = dp;
}
一般情况下会没有包含com.adobe.serialization这个包的包,我给附上了~
就这么简单,然后在后台里修改相应返回值为Json格式就行了~