1 Reply Latest reply on May 7, 2007 11:50 AM by ntsiii

    associative array with ArrayCollection?

      I maybe totally confused about the right question to ask, so here's a quick description of what I want to do.
      I have a list of subscription objects. I want to be able to know when the list changes, and I want to have only one list that other objects can reference. What's the best way to do this?
      Subscription object has properties:

      1) I tried putting this in an ArrayCollection acMySubscriptions, but when I do the following it doesn't work:
      var itemToFind:Subscription = new Subscription("blue",1)

      Since I really want to find things by name, I thought I ought to use an object instead.
      objMySubscriptions["blue"] =new Subscription("blue",1);

      Now I can find the subscription easily with:

      However, now I don't get the advantages of an ArrayCollection in generating events for collectionChange, sorting, length etc.
      I also want the advantage of arrays in that I have only one copy of the data, so I can have another object do something like this.
      myACReference:ArrayCollection = new ArrayCollection();
      myACReference = holderObject.acMySubscriptions;
      myACReference[0].qty = 5;

      so now the acMySubscriptions would hold one Subscription item in it with properties
      name = blue
      qty = 5

      I tried using ICursorView, but then when I wanted to change something in the object I found in the ArrayCollection, it didn't seem to change.

      Also I thought of using named elements like the following, but I read that is frowned on/bad practice.

      acMySubscriptions["blue"] = new Subscription("blue",1)
      This works dandy, in that I can get my item later easily enough. But I understand if I do that, I no longer get full functionality
      of arrays - e.g., acMySubscriptions.length would yield 0

      Bottom line is I want something like an ArrayCollection where I can get items by name and have all the functionality of arrays and ArrayCollections. Any help would be GREATLY appreciated!!!