0

so I have array like ParamsArray

{a,b,a,a,...b} (so i have 2 kinds of parameters in this array - a and b) (here I have N strings)

and another array - DataArray

{data1,data2,...dataN} (different strings) (here I have N strings)

Now I created 2 new arrays ArrayA and ArrayB and I wanta want to feel arra ArrayA with all data (strings) from DataArray which correspond (by index in array) to a param in ParamsArray. and so strings that correspond to param B should appear in ArrayB.

How to do such thing in actionscript? (Please - I need a code example)

1
  • Hey man I'd love to help but I'm so confused. Could you clarify your need? Commented Apr 29, 2010 at 23:31

1 Answer 1

1

I think this is what you want to do. Check http://livedocs.adobe.com/flex/3/langref/ and look at the array function. You can do a similar thing with Array.filter, and so on.

function foo(params:Array, data:Array):Object {
  var a:Array = [], b:Array = []
  data.forEach(function(item:*, index:int, array:Array):void {
    if(params[index] == "a") {
      a.push(item)
    } else if(params[index] == "b") {
      b.push(item)
    }
  })
  return {alist:a, blist:b}
} 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.