Flex 3 and using name / value pairs

Does anyone have any guidelines for working with name and value pairs in Flex?

Context: I want to create a Flex UI to update a database table. I want the UI to contain the field name (read-only) and the current value of the field (which will be editable). I am using a WebService component to get the value of a field and then assign it to an object named hardcoded for example.

private function resultHandler(event:ResultEvent):Object
{
var resultsObj:Object;
resultsObj = {
name:event.result.name as String,

      

However, this approach adds the dependency that the table / field names will not change. Using an object type also requires me to write my own algorithm for sorting the output.

0


a source to share


2 answers


I'm not sure I understand this problem.

If you want to avoid dependency on the properties returned from the event at this point, simply use the event.result object, which is already an associative array .



As far as sorting goes, we need more context for what you are trying to sort.

0


a source


It's pretty straightforward. Do not use for every cycle. Use the For-In Loop Demo shown below.

var dicEntry:Object = new Object();

dicEntry["Name"] = "Raj";
dicEntry["sal"] = 10000;
dicEntry["age"] = 33;

for(var key:Object in dicEntry)
{
    trace("Object Key: "+key+" Object Value:  +dicEntry[key]);
}   

      



What is it.

0


a source







All Articles