Link to home
Start Free TrialLog in
Avatar of myBlueSky
myBlueSky

asked on

Split Sting in ArrayCollection

I have arraycollection items contains list of items;

I need to get the id and the description out of this list to be used in Flex app.

The input is:
                  private var input:ArrayCollection=new ArrayCollection
                  ([
                  { item: "5 Computers HP 125"},
                  { item: "125 Monitors LG 54 "},
                  { item: "00425 Keyboard AA 58 "},
                  { item: "0525 others "}
                  ]);


The output should be
                  private var output:ArrayCollection=new ArrayCollection
                  ([
                  { id: "5", Desc: "Computers HP 125"},
                  { id: "125", Desc: "Monitors LG 54"},
                  { id: "00425", Desc: " Keyboard AA 58"},
                  { id: "0525", Desc: “others"}
                  ]);
SOLUTION
Avatar of Meir Rivkin
Meir Rivkin
Flag of Israel image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Cool @sedgwick has answered it already.
But I think mine will be better in performance as it uses the same ArrayCollection :)

Warm Regards
Deepanjan Das
Avatar of myBlueSky
myBlueSky

ASKER


Deepanjan
I’m getting error on this statement:  value = input.getItemAt(i);

Implicit coercion of a value with static type Object to a possibly unrelated type String
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Set the value to an Object;

var value:Object;

Also @ute_arbeit 's suggestion is good.

Warm Regards
Deepanjan Das