How to update ArrayCollection at runtime?

Ask a Question related to Macromedia Flex General Discussion, Design and Development.

  1. #1

    Default How to update ArrayCollection at runtime?

    Am facing some problem with arraycollection..
    am having an arraycolelction like this...
    var dpHierarchy:ArrayCollection = new ArrayCollection([
    {Region:"Demand1"},
    {Region:"Demand2"},
    {Region:"Demand3"},
    {Region:"Demand4"}]

    now what am looking for is.. how to update this arraycollection at runtime
    using actions script?
    i need to update this array colelction something like this...

    var dpHierarchy:ArrayCollection = new ArrayCollection([
    {Region:"Demand1", Year:"2008"},
    {Region:"Demand2", Year:"2008"},
    {Region:"Demand3", Year:"2008"},
    {Region:"Demand4", Year:"2008"}]

    How to add Year field in to existing arraycollection like shown in about
    example..

    thanks in advance
    Pratap


    Pratap Reddy Guest

  2. Similar Questions and Discussions

    1. How to update the ItemRenderer at runtime..?
      Hi.... am facing a hectic problem with ITemRenderes.. My requirement is like i need to insert a Label and Image in each item of Horizontal List....
    2. ArrayCollection to XML
      I have data in an ArrayCollection. I need to post the data to a web page for saving on the server. It seems the best way to do this is to convert...
    3. ArrayCollection
      How to navigate and get values of ArrayCollection?
    4. How to add a Dropdown list to a datagrid at runtime (dynamic) without using template columns in ASP.NET and still have the ability to us the datagrid Update event.
      How to add a Dropdown list to a datagrid at runtime (dynamic) without using template columns in ASP.NET and still have the ability to us the...
    5. using external cast to update content at runtime from a projector or shocked piece
      Hello List People: I am trying to create a projector (or shocked piece) that will use content from an external castLib so that I don't have to...
  3. #2

    Default Re: How to update ArrayCollection at runtime?

    How about have the ArrayCollection based on an Array, but add a dimension to the array to accomplish what you want.
    Greg Lafrance Guest

  4. #3

    Default Re: How to update ArrayCollection at runtime?

    hi,,
    thanks for reply...
    can u help me to give some example how to do that?

    thanks in advance
    Pratap Reddy Guest

  5. #4

    Default Re: How to update ArrayCollection at runtime?

    There are two ways you can do this. One would be setting it straight like this.

    private function updateDP():void {
    dpHierarchy[0].Year = "2008";
    }

    This will also make it so that every other item in your ArrayCollection has
    the Year identifier however nothing will be filled in for the values. The other
    way you could do this would be to user setItemAt which would look like this.

    dpHierarchy.setItemAt({Region:"Demand1", Year:"2008"}, 0);

    which essentially does the exact same thing except your setting all the
    properties of that item instead of just adding the identifier Year.

    Kaotic101 Guest

  6. #5

    Default Re: How to update ArrayCollection at runtime?

    hi.. s this works fine..

    Any idea how to make item name dynamic..
    something like..

    private function updateDP():void {
    for(var i:int=0;i<10;i++)
    {
    dpHierarchy[0].Year = "2008"; /// How to add that 'i' value over here?
    }
    }

    i wanna add Year1, Year2, Year3 --------- like this...
    is its possible??

    thanks in Advance
    PRatap


    Pratap Reddy Guest

  7. #6

    Default Re: How to update ArrayCollection at runtime?

    hey got it...

    just i need to give

    dpHierarchy[0]["Year"] = "2008";

    :-)

    Pratap Reddy Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139