0

im trying to read arrayCollection without using loops.actually my intention is to read range of values from arrayCollection and put in to another Array collection and delete that data from original array. is it possible ? any ideas guys ?

2 Answers 2

1

I hope I have misunderstood what you needed, tell me.

.....chargeArray(1,4)


private function chargeArray(indexA:int,indexB:int):void
    {
        var myArray:Array = new Array();
        var expenses:ArrayCollection = new ArrayCollection([ {Label:"Taxes", Value:2000}, 
        {Label:"Rent", Value:1000},
        {Label:"Bills", Value:100},
        {Label:"Car", Value:450},
        {Label:"Gas", Value:100},
        {Label:"Food", Value:200},
        {Label:"Taxes1", Value:2000} ]); 

        myArray = expenses.source.slice(indexA, indexB);     
        expenses.source.splice(indexA,(indexB-indexA));
        expenses.refresh();
    }
Sign up to request clarification or add additional context in comments.

Comments

1

You can work with items using methods from Array class:

var myArray:Array = myCollection.source.slice(0, 5);
myAnotherCollection.addAll(new ArrayCollection(myArray));

Looks a bit tricky but there is no loops.

3 Comments

thanks for your reply.But this is my arrayCollection.Above method is not working for my case private var expenses:ArrayCollection = new ArrayCollection([ {Label:"Taxes", Value:2000}, {Label:"Rent", Value:1000}, {Label:"Bills", Value:100}, {Label:"Car", Value:450}, {Label:"Gas", Value:100}, {Label:"Food", Value:200}, {Label:"Taxes1", Value:2000} ]);
What items you want to have in your second collection?
Both Label and Value fields i need. if i select 0 to 2 i must get {Label:"Taxes", Value:2000}, {Label:"Rent", Value:1000}, {Label:"Bills", Value:100} fields . is this possible ?

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.