Array Collection cast as Object

In my app i am pushing data into an array collection. When I debug or trace the AC i get [object Object]. Am i doing something wrong?
         public var newsDB:ArrayCollection = new ArrayCollection;
then I add to the AC here.
                  if(archive.selected == true){
                    newsDB.addItem( {
                    title: titleText.label,
                    clickURL: clickURL.text,
                    info: itemInfo.text,
                    abstract: abstract.text,
                    category: category.selectedLabel,
                    rateItem: rateItem.selectedItem });               
                    trace(newsDB);          
When I debug, i can see that the items are in the AC, but as generic objects. Thoughts?

How are you tracing the objects in the array?  If you want to see the particular properties, you have to specify them... trace(newsDB[i].title);

Similar Messages

  • How to convert an array collection instance to a complex object for interaction with webservice

    Hi there,
    I have a stubborn problem that I am trying to work out the best way to solve the problem.  I am interacting with a WebService via HTTPService calling a method called find(String name) and this returns me a List of ComplexObjects that contain general string and int params and also lists of other Complex Objects.  Now using the code:
    ArrayCollection newOriginalResultsArray = new ArrayCollection(event.result as Array)
    flex converts my complex objects results to an arraycollection so that I can use it in datagrids etc.  Now up until this part is all good.  My problem is when getting a single instance from the results list, updating it by moving data around in a new datagrid for example - I want to interact with the webservice again to do an create/update.  This is where I am having problems - because these webservice methods require the complex object as a parameter - I am struggling to understand how I can convert the array collection instance back to my complex object without iterating over it and casting it back (maybe this is the only way - but I am hoping not).
    I am hoping that there is a simple solution that I am missing and that there is some smart cookie out there that could provide me with an answer - or at least somewhere to start looking. I guess if I have no other alternative - maybe I need to get the people who built the service to change it to accept an array - and let them do the conversion.
    Any help would be greatly appreciated.
    Bert

    Hi Bert,
    According to my knowledge you can use describeType(Object) method which will return an XML... That XML will contain Properties and values just iterate through the XML and create a new Object..   Probably u can use this method...
    public function getObject(reqObj:Object,obj:Object,instanceName:String,name:String=null,index:int=-1):Obj ect
                if(!reqObj)
                    reqObj = new Object();
                var classInfo:XML = describeType(obj);
                var className:String = instanceName;
                if(name!=null)
                    className=name+"."+className;
                if(index!=-1)
                    className=className+"["+index+"]";
                for each (var v:XML in classInfo..accessor)
                    var attributeName:String=v.@name;
                    var value:* = obj[attributeName]
                    var type:String = v.@type;
                    if(!value)
                        reqObj[className+"."+attributeName] = value; 
                    else if(type == "mx.collections::ArrayCollection")
                        for(var i:int=0;i<value.length;i++)
                            var temp:Object=value.getItemAt(i);
                            getReqObject(reqObj,temp,attributeName,className,i);
                    else if(type == "String" || type == "Number" || type == "int" || type == "Boolean")
                        reqObj[ className+"."+attributeName] = value; 
                    else if (type == "Object")
                        for (var p:String in value)
                            reqObj[ className+"."+attributeName+"."+p] = value[p];
                    else
                        getReqObject(reqObj,value,attributeName,className);
                return reqObj;
    Thanks,
    Pradeep

  • Object Array --- Collection

    Is there any way to directly convert and object Array to a Collection object. Basically i need to create a ArrayList from Object Array. The ArrayList has a constructor and also provides a method addAll() that accept Collection as parameter. So the problem becomes , how to convert Object Array to collection. As per my understanding all arrays should be essentially Collection Interface subclass.
    So why am i not able to cast?
    What is wrong in calling Object Array a sub class of Collection?
    // OrderLineItem[] is the object array that i wish to have as ArrayList
    // This code generates error -
    //"ErpOrder.java": Error #: 364 : cannot cast gal.ERP.OrderLineItem[] to java.util.Collection
      public void setLineItems( OrderLineItem[] arrOrderLineItem ) {
        m_arrLineItems = new ArrayList((Collection)arrOrderLineItem);
      }Is there no way except iterating through the array and adding individual Objects to ArrayList?

    By "Object array" do you mean an Array class, or do you mean an Object[]? They are different. The Array class wraps an Object[] and provides useful methods to manipulate it.
    There is no such thing as a Collection object, per say. "Collection" is an interface implemented by many objects such as LinkedList, Vector, ArrayList, HashSet, and TreeSet.
    The Collection interface is designed to be an interface to any object that can keep a mutable list of other Objects, check to see if an Object is in that list, and iterate through all Objects in the list.
    As far as resources go, I suggest the API reference at http://java.sun.com/j2se/1.4.1/docs/api/index.html.

  • Object array type casting?

    Hi. I still can't get the hang of array type casting. Is it possible to type caste an array of objects? I tried the following
    LabelledPanel[] comp = (LabelledPanel[])(content.getComponents());
    in my program and I got the ClassCastException.
    Exception occurred during event dispatching:
    java.lang.ClassCastException: [Ljava.awt.Component;
    LabelledPanel is a descendent of JPanel and getComponents() supposed to return Component[]

    java does support casting with arrays. The following code will work:
    String [] strings = new String[] { "1", "2" };
    Comparable [] comps = (Comparable[])strings;
    Object [] objects = (Object [])strings;That is, you can cast following the normal rules of assignment. You are having problems because your casting violates the normal rules of assignment- you're trying to cast a type into a differnt type that it does not extend or implement.
    the toArray() in the Collections API really has nothing to do with casting. That method converts the current Collection into an array of the same type. Since all arrays extend java.lang.Object, it returns the new array as an Object, which you then cast into the specific type.
    You may want to read the language guidlines on casting if you are having problems with it:
    http://java.sun.com/docs/books/jls/second_edition/html/jIX.fm.html
    you can also look at the documenation for Class.isAssignableFrom , which explains casting more briefly.

  • Using An Array Collection Produced From XML In Conjunction With Shared Object

    I have an old app that Greg LaFrance helped me out with greatly which allows the user to drag items between two tilelists and then save the contents of both tilelists by clicking a save button using the sharedObject method. The tilelists are populated by array collections defined in the app. I want to change this so that the tilelists are instead populated by an array collection which I've retrieved from a remote xml file via http request but I can't get this to work. Basically I need to replace both the predefined array collections profile1NewsAndSportaddLinksFullAC and profile1NewsAndSportaddLinksAC with my xml/httprequest produced newsAC array collection and still make the tilelists saveable. Can anyone help me out? Here's the code:-
    <?xml version="1.0" encoding="utf-8"?>
    <mx:WindowedApplication
    xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="newsService.send(); initprofile1NewsAndSportSO()">
    <mx:Script>
    <![CDATA[
    import mx.rpc.events.ResultEvent;
    import mx.collections.*;
    import flash.net.SharedObject;
    Bindable]
    private var newsAC:ArrayCollection;
    private function newsResultHandler(event:ResultEvent):void{
    newsAC=newsService.lastResult.newscategory.news;
    public var profile1NewsAndSportSO:SharedObject;
    private var profile1NewsAndSportaddLinksFullAC:ArrayCollection = new ArrayCollection([{label:
    "BBC News"},{label:
    "ITV"},{label:
    "Sky News"}]);
    private var profile1NewsAndSportaddLinksAC:ArrayCollection = new ArrayCollection([{label:
    "BBC News"},{label:
    "ITV"},{label:
    "Sky News"}]);
    private function profile1NewsAndSportReset():void{resetprofile1NewsAndSportAC();
    profile1NewsAndSportAddLinksTilelist.dataProvider
    = profile1NewsAndSportaddLinksAC;
    profile1NewsAndSportLinkChoice.dataProvider =
    new ArrayCollection([]); }
    private function resetprofile1NewsAndSportAC():void{profile1NewsAndSportaddLinksAC.removeAll();
    for each(var obj:Object in profile1NewsAndSportaddLinksFullAC){profile1NewsAndSportaddLinksAC.addItem(obj);
    private function initprofile1NewsAndSportSO():void{profile1NewsAndSportSO = SharedObject.getLocal(
    "profile1NewsAndSport");
    if(profile1NewsAndSportSO.size > 0){
    if(profile1NewsAndSportSO.data.profile1NewsAndSportaddList){
    if(profile1NewsAndSportSO.data.profile1NewsAndSportaddList != "empty"){
    var profile1NewsAndSportaddList:Array = profile1NewsAndSportSO.data.profile1NewsAndSportaddList.split(",");
    var profile1NewsAndSporttempAC1:ArrayCollection = new ArrayCollection();
    for each(var str:String in profile1NewsAndSportaddList){
    for each(var obj1:Object in profile1NewsAndSportaddLinksAC){
    if(str == obj1.label){profile1NewsAndSporttempAC1.addItem(obj1);
    continue;}
    if(profile1NewsAndSporttempAC1.length > 0){profile1NewsAndSportAddLinksTilelist.dataProvider = profile1NewsAndSporttempAC1;
    if(profile1NewsAndSportSO.data.profile1NewsAndSportchoiceList){
    var profile1NewsAndSportchoiceList:Array = profile1NewsAndSportSO.data.profile1NewsAndSportchoiceList.split(",");
    var profile1NewsAndSporttempAC2:ArrayCollection = new ArrayCollection();
    for each(var str2:String in profile1NewsAndSportchoiceList){
    for each(var obj2:Object in profile1NewsAndSportaddLinksAC){
    if(str2 == obj2.label){profile1NewsAndSporttempAC2.addItem(obj2);
    continue;}
    if(profile1NewsAndSporttempAC2.length > 0){profile1NewsAndSportLinkChoice.dataProvider = profile1NewsAndSporttempAC2;
    else{profile1NewsAndSportReset();
    private function saveprofile1NewsAndSport(event:MouseEvent):void{
    var profile1NewsAndSportaddList:String = "";
    if(profile1NewsAndSportAddLinksTilelist.dataProvider){
    if(ArrayCollection(profile1NewsAndSportAddLinksTilelist.dataProvider).length > 0){
    for each(var obj1:Object in profile1NewsAndSportAddLinksTilelist.dataProvider){
    profile1NewsAndSportaddList += obj1.label +
    else{profile1NewsAndSportaddList =
    "empty";}
    profile1NewsAndSportSO.data.profile1NewsAndSportaddList = profile1NewsAndSportaddList;
    var profile1NewsAndSportchoiceList:String = "";
    for each(var obj2:Object in profile1NewsAndSportLinkChoice.dataProvider){
    profile1NewsAndSportchoiceList += obj2.label +
    profile1NewsAndSportSO.data.profile1NewsAndSportchoiceList = profile1NewsAndSportchoiceList;
    profile1NewsAndSportSO.flush();
    ]]>
    </mx:Script>
    <mx:HTTPService id="newsService" resultFormat="object" result="newsResultHandler(event)" url="http://www.coolvisiontest.com/getnews.php"/>
    <mx:Button click="profile1NewsAndSportReset()" id="reset" label="
    Reset" y="5" height="25" x="5"/>
    <mx:TileList id="profile1NewsAndSportLinkChoice" fontWeight="bold" dragEnabled="
    true" dragMoveEnabled="true" dropEnabled="true" height="129" width="
    650" top="5" left="521" columnCount="5" rowHeight="145" columnWidth="
    125" backgroundColor="#000000" color="#FFFFFF"/>
    <mx:TileList id="profile1NewsAndSportAddLinksTilelist" fontWeight="bold" dragEnabled="
    true" dragMoveEnabled="true" dropEnabled="true" height="129" width="
    385" top="5" left="128" columnCount="3" rowHeight="145" columnWidth="125" backgroundColor="
    #000000" color="#FFFFFF"/>
    <mx:Button click="saveprofile1NewsAndSport(event)" id="save" label="Save Changes" x="
    5" y="38" width="113" height="25.5"/>
    </mx:WindowedApplication>

    It might be easy to solve these issues if you post your form.
    Post your form if it doesn't contain any confidential information.
    Nith

  • How to create a spidar chart (Radar chart) with an array collection object...

    Hi All,
              I need to create Spidar (Radar) chart in my application with the help of an array collection object........can any one help me ?? do i need to import any external library ???
    Please provide the required code for it .........
    Thanks in advance....

    You'll need to set the "series" property of the chart. This will be an array of BarSeries objects.
    You may also need to set the horizontalAxis and verticalAxis properties for the chart. (I forget if there are defaults for these.)

  • Multiple Comboboxes with single instance of Array Collection

    First off - thanks to everyone for their contributions.  This forum provides a lot of good information.
    I'm stuck on a particular problem and I suspect I'm not thinking about the issue correctly.
    I'm developing a dynamic module that instantiates components at runtime based on an XML scheme.  Many of these components are drop-downs that are chained togther (a selection in one drives the population of the next)
    I loop through the initial XML document to create and layout the components.  I have been using a single Array Collection to populate the drop-down.  This worked fine with the chained comboboxes since I only load one combox initially.  However, when I add a couple of static combo boxes, the arraycollection seemed to be binding to the orginal combobox.  For example, if I create 3 combo boxes they have drop-down values that display all 3 lists appended together.  I was a bit surprised because I didn't think that I could bind an Array Collection.  I certainly haven't defined a Binable ArrayCollection.
    I thought I could solve the issue by simply creating a unique Array Collection at runtime - one for each element.  However, I don't think this is possible or I can't figure out how to create a new Array Collection with a dynamic name - something like this:
    I was hoping this would work -
    var newDropDown_[numOfElement]:ArrayCollection = new ArrayCollection(); 
    I've tried to use a Dictionary object to store each ArrayCollection.  I couldn't get that to work properly.
    Essentially - my code loops on the number of components to add:
    for (var i:int = 0; i < numFormElements; i++)
              for (var j:int = 0; j < numvalues; j++)
                                    var valuefield:String = 'value_' + [j+1];
                                    var obj:Object=new Object();
                                    obj.label=instFields[i][valuefield].@label;
                                    obj.data=instFields[i][valuefield].@data;
                                    newDropDown.addItemAt(obj,j);
    Then I add the components:
              var c:ComboBox = new ComboBox ();
                c.labelField='label';
                c.name=numberOfElement.toString();                                  
                c.dataProvider=    newDropDown;
                _h1.addChild(c);
                numComboDropDwns.push(c);
    I need a way of looping, getting data and populating each component independently??
    Any ideas?
    Thanks,
    John

    I went a different route and solved the issue.  For someone looking at a similar problem - this what I ended up doing:
    I just loaded one array collection with data for all of the drop-downs on the form.  I then populated each dataprovider with individual elements from the array.
    for (var i:int = 0; i < numFormElements; i++)
    for (var j:int = 0; j < numvalues; j++)
                                    var valuefield:String = 'value_' + [j+1];
                                    var obj:Object=new Object();
                                    obj.label=instFields[i][valuefield].@label;
                                    obj.data=instFields[i][valuefield].@data;
                                    newDropDown.addItemAt(obj,elementCounter);
                                    elementCounter = elementCounter + 1;
    I keep track of the element #, number of values for each element and the overall index for the array.
    Each data provider is then loaded with the subset from the array:
    for (var z:int = (_counter - _numvalues) ; z < _counter; z++)
                                var _label:String=    newDropDown.getItemAt(z).label.toString();
                                var _data:String = newDropDown.getItemAt(z).data.toString();
                                c.dataProvider.addItem({label:[_label],data:[_data]});
    This seems to work nicely - each component is created and loaded with only their data.  I spent 3 days searching for a way to create a dynamic arraycollection at runtime.  I don't think it's possible - but I'm not sure it was the best method anyway.

  • Trouble with primitive arrays and casting, lesson 521

    hi everyone!
    there is a problem i discovered right now - after years with java where was no necessity to do this.....
    and i'm shure this must have been the topic already, but i couldn't find any helpful resource :-/
    right here we go:
    1. an array is a (special) kind of object.
    2. there are "primitive" arrays and such containing references to objects. of course - and i imagine why - they are treated differently by the VM.
    3. then both are - somehow - subclasses of Object. whereas primitive types are not really, primitive-arrays are. this is hidden to the programmer....
    4. any array can be "pointed" at via local Object variable, like this:
    Object xyz = new int[6];
    5. arrays of Objects (with different dimensions) can be casted, like this:
      Object pointer = null;
      Object[]   o  = new SomeClass[42] ;
      Object[][] oo = new OtherClass[23] [2] ;
      Object[][][] ooo = new OtherClass[23] [2] [9] ;
      o = oo = ooo;     // this is save to do,
                                   //because "n-dimensional" object-arrays
                                  // are just arrays of  other arrays, down to simple array
    pointer = o;         // ok, we are referencing o via Object "pointer"6. but, you cannot do this with primitive types:
      int[]  i1 = new int [99] ;
      int[][] i2 = new int [1] [3] ;
      i1 = i2                  // terror: impossible. this is awful, if you ask me.
                                   // ok, one could talk about "special cases" and
                                   // "the way the VM works", but this is not of interest to me as
                                   // a programmer. i'm not happy with that array-mess!
      pointer = i2;       // now this is completely legal. i2, i1 etc is an object!7. after the preparation, let's get into my main trouble (you have the answer, i know!) :
    suppose i have a class, with methods that should process ANY kind of object given. and - i don't know which. i only get it at runtime from an unknown source.
    let's say: public void BlackBox( Object x );
    inside, i know that there might be regular objects or arrays, and for this case i have some special hidden method, just for arrays... now try to find it out:
    public void BlackBox( Object x )
      if ( x == null)
           return;
       Class c = x.getClass();
       if ( c.isArray() )
              // call the array method if it's an array.........
              BlackBoxes(     (Object [] )  x );         // wait: this is a cast! and it WILL throw an exception, eventually!
              return;
       else
               DoSpecialStuffWith( x );
    }ok ? now, to process any kind of array, the special method you cannot reach from outside:
    private void BlackBoxes( Object[] xs )
       if ( xs != null )
            for ( Object x : xs )
                 BlackBox( x );
    // this will end up in some kind of recursion with more than one array-dimension, or when an Object[] has any other array as element!this approach is perfectly save when processing any (real) Object, array or "multi-dimensional" arrays of Objects.
    but, you cannot use this with primitive type arrays.
    using generics wouldn't help, because internally it is all downcasted to Object.
    BlackBox( new Integer(3) ) ---- does work, using a wrapper class
    BlackBox( new Integer[3] ) ----- yep!
    BlackBox( 3 ) ---- even this!
    BlackBox( new int[42] ) ---- bang! ClassCastException, Object[] != int[]
    i'm stuck. i see no way to do this smoothly. i could write thousands of methods for each primitive array - BlackBox( int[] is ) etc. - but this wouldn't help. because i can't cast an int[][] to int[], i would also have to write countless methods for each dimension. and guess, how much there are?
    suppose, i ultimately wrote thousands of possible primitive-type methods. it would be easy to undergo any of it, writing this:
    BlackBox( (Object) new int[9] [9] );
    the method-signature would again only fit to my first method, so the whole work is useless. i CAN cast an int[] to Object, but there seems no convenient way to get the real array out of Object - in a generic way.
    i wonder, how do you write a serialisation-engine? and NO, i can't rely on "right usage" of my classes, i must assume the worst case...
    any help appreciated!

    thanks, brigand!
    your code looks weird to me g and i think there's at least one false assumption: .length of a multidimensional array returns only the number of "top-level" subarrays. that means, every length of every subarray may vary. ;)
    well i guess i figured it out, in some way:
    an int is no Object;
    int[ ] is an Object
    the ComponentType of int [ ] is int
    so, the ComponentType of an Object int[ ] is no Object, thus it cannot be casted to Object.
    but the ComponentType of int [ ] [ ] IS Object, because it is int [ ] !
    so every method which expects Object[], will work fine with int[ ] [ ] !!
    now, you only need special treatment for 1-dimensional primitive arrays:
    i wrote some code, which prints me everything of everything:
        //this method generates tabs for indentation
        static String Pre( int depth)
             StringBuilder pre = new StringBuilder();
             for ( int i = 0; i < depth; i++)
                  pre.append( "\t" );
             return pre.toString();
        //top-level acces for any Object
        static void Print( Object t)
             Print ( t, 0);
        //the same, but with indentation depth
        static void Print( Object t, int depth)
            if ( t != null )
                 //be shure it is treated exactly as the class it represents, not any downcast
                 t = t.getClass().cast( t );
                if ( t.getClass().isArray() )
                     //special treatment for int[]
                     if ( t instanceof int[])
                          Print( (int[]) t, depth);
                     // everything else can be Object[] !
                     else
                          Print( (Object[]) t, depth );
                     return;
                else
                    System.out.println( Pre(depth) + " [ single object:] " + t.toString() );
            else
                System.out.println( Pre(depth) + "[null!]");
        // now top-level print for any array of Objects
        static void Print( Object [] o)
             Print( o, 0 );
        // the same with indentation
        static void Print( Object [] o, int depth)
            System.out.println( Pre(depth) + "array object " + o.toString() );
            for ( Object so : o )
                    Print( so, depth + 1 );
        //the last 2 methods are only for int[] !
        static void Print( int[] is)
             Print( is, 0 );
        static void Print( int[] is, int depth)
            System.out.println( Pre(depth) + "primitive array object " + is.toString() );
            // use the same one-Object method as every other Object!
            for ( int i : is)
                 Print ( i, depth + 1 );
            System.out.println( "-----------------------------" );
        }now, calling it with
    Print ( (int) 4 );
    Print ( new int[] {1,2,3} );
    Print( new int[][] {{1,2,3}, {4,5,6}} );
    Print( new int[][][] {{{1,2,3}, {4,5,6}} , {{7,8,9}, {10,11,12}}, {{13,14,15}, {16,17,18}} } );
    Print( (Object) (new int[][][][] {{{{99}}}} ) );
    produces this fine array-tree:
    [ single object:] 4
    primitive array object [I@9cab16
          [ single object:] 1
          [ single object:] 2
          [ single object:] 3
    array object [[I@1a46e30
         primitive array object [I@3e25a5
               [ single object:] 1
               [ single object:] 2
               [ single object:] 3
         primitive array object [I@19821f
               [ single object:] 4
               [ single object:] 5
               [ single object:] 6
    array object [[[I@addbf1
         array object [[I@42e816
              primitive array object [I@9304b1
                    [ single object:] 1
                    [ single object:] 2
                    [ single object:] 3
              primitive array object [I@190d11
                    [ single object:] 4
                    [ single object:] 5
                    [ single object:] 6
         array object [[I@a90653
              primitive array object [I@de6ced
                    [ single object:] 7
                    [ single object:] 8
                    [ single object:] 9
              primitive array object [I@c17164
                    [ single object:] 10
                    [ single object:] 11
                    [ single object:] 12
         array object [[I@1fb8ee3
              primitive array object [I@61de33
                    [ single object:] 13
                    [ single object:] 14
                    [ single object:] 15
              primitive array object [I@14318bb
                    [ single object:] 16
                    [ single object:] 17
                    [ single object:] 18
    array object [[[[I@ca0b6
         array object [[[I@10b30a7
              array object [[I@1a758cb
                   primitive array object [I@1b67f74
                         [ single object:] 99
    -----------------------------and i'll have to write 8 methods or so for every primitive[ ] type !
    sounds like a manageable effort... ;-)

  • Referencing values in Array Collection?

    I'm using a Remote Object to pass an argument to a CFC. I
    then query a table according to the value of the argument passed in
    ('where' clause). I return a single record result as a query in
    Flex (event.result) and set it as an Array Collection, example:
    myAC = new ArrayCollection;
    myAC.source = event.result as Array;
    I can take this AC and set it as a dataprovider for a data
    grid or list without problem. What I'd like to do is pull specific
    data from the AC and use it in my Flex app. For example, the
    results of my query will return 1 record only, but contains many
    columns from my table. It might contain an ID, a username, a first
    and last name, maybe a phone number, etc. All this info for that
    single record will be stored in the array collection. What I want
    to do is be able to reference this data in Flex.
    For instance, if I need to display the phone number (stored
    as phoneNumber from my query) in the array collection, how can I do
    this? myAC.phoneNumber? myAC.getItemAt(0).phoneNumber?
    Any guidance is appreciated

    I'm not sure about dealing with a Remote Object / CFC
    configuration, but if your collection essentially ends up like:
    var myAC:ArrayCollection = new ArrayCollection([{name:
    'First', phoneNumber: '555'}]);
    Then yes you should be able to access it with:
    myAC.getItemAt(0).phoneNumber
    I take this has not worked?

  • How to find and modify  item in a nested array collection?

    Hi,
    would anybody know how to find and modify item in a nested
    array collection:
    private var ac:ArrayCollection = new ArrayCollection([
    {id:1,name:"A",children:[{id:4,name:"AA",children:[{id:8,name:"AAA"}]},{id:5,name:"AB"}]} ,
    {id:2,name:"B",children:[{id:6,name:"BA"},{id:7,name:"BB"}]},
    {id:3,name:"C"}
    Let's say I've got object {id:8, name:"X"} , how could I find
    item in a collection with the correspoding id property, get handle
    on it and update the name property of that object?
    I'm trying to use this as a dataprovider for a tree populated
    via CF and remoting....
    Thanks a lot for help!

    Thanks a lot for your help!
    In the meantime I've come up with a recursive version of the
    code.
    This works and replaces the item on any level deep:
    private function findInAC(ac:ArrayCollection):void{
    var iMatchValue:uint=8;
    for(var i:uint=0; i<ac.length; i++){
    if(ac
    .id == iMatchValue){
    ac.name = "NEW NAME";
    break;
    if(ac
    .children !=undefined){
    findInAC( new ArrayCollection(ac.children));
    However, if I use the array collection as a dataprovider for
    a tree and change it, the tree doesn't update, unless I collapse
    and reopen it.
    Any ideas how to fix it ?

  • Adding property/field to an item inside array collection

    Hi
    I'm newbie. But I'm spending a huge amout of time trying to figure out something that should be simple.
    in short:
    I wanted to add a new field/property to an item inside an arraycollection(ac).
    I thought something like:
    ac.souce[i].push(object:value)
    would do (its inside a loop, since I have ac.length) but it didnt.
    ITS IMPORTANT TO SAY THAT:
    i think addItem, or addItemAt IS NOT THE CASE.
    I want to add an new item INSIDE the array that is wrapped in ac.
    in long:
    I have a ORDERS table that comes with a client_id (int).
    I need to retrieve the client's name from a CLIENTS table.
    Ok i have to put everything on the same datagrid. So, first i've tried to ivoke a function like this that would use the getClientsByID and return a string with its name.
    It didn't worked, maybe due to the syntax.
    SO, i thought i had to put all those 2 tables into 1 array collection to use this as a 'formated' data provider for the datagrid.
    What should I do? this is a simples example.
    Thanks a lot
    Btp~

    Just borrow code from ListBase.as, don't actually use an instance of ListBase.  That pattern should work for non-display classes as well.
    Alex Harui
    Flex SDK Developer
    Adobe Systems Inc.
    Blog: http://blogs.adobe.com/aharui

  • Array Collection

    Hi,
    I'm using the following code in conjunction with amfPHP to pull information from a database, this info is then (as far as I know) returned to flex as an array collection.
    What I'm looking to do is populate the list with the data within the array collection,
    Heres my code
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">
        <mx:Script>
            <![CDATA[
                import flash.net.*;
                import mx.collections.ArrayCollection;
                import mx.rpc.events.ResultEvent;
                public function connect():Object
                    var gw:NetConnection = new NetConnection();
                    gw.connect("http://localhost/amfphp/gateway.php");
                    var res:Responder = new Responder(onResult, onFault);
                    function onResult(responds:Object):void
                      trace(responds.serverInfo.initialData[0][1]);
                    function onFault(responds:Object):void
                        for(var i in responds)
                            trace(responds[i]);
                    gw.call("Test.getRecordset", res);
                    return res;
                public function init()
                    connect();
            ]]>
        </mx:Script>
        <mx:List x="75" y="113"></mx:List>
    </mx:Application>

    I've modified my code as follows,
    the idea being that when the user selects a category from the list, the tile list is populated with the icons, I can get this to poulate with the icon reference but can't actually get the icons to appear. Also for some reason when i select business, the communications results come up and vice versa
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" width="800" layout="absolute" creationComplete="init()">
        <mx:Script>
            <![CDATA[
                import flash.net.*;
                import mx.collections.ArrayCollection;
                import mx.rpc.events.ResultEvent;
    [Bindable]
                private var categoryResult:ArrayCollection;
    [Bindable]
                private var iconResult:ArrayCollection;
                public function getDistinct():Object
                var gw:NetConnection = new NetConnection();
                    gw.connect("http://localhost/amfphp/gateway.php");
                    var res:Responder = new Responder(onResult, onFault);
                    function onResult(responds:Object):void
                      categoryResult = new ArrayCollection(responds.serverInfo.initialData);  
                      //trace(arrResult); 
                    function onFault(responds:Object):void
                        for(var i in responds)
                            trace(responds[i]);
                   gw.call("Test.getDistinct", res);
                    return res;
                public function getIcons(cats:String):Object
                var gw2:NetConnection = new NetConnection();
                    gw2.connect("http://localhost/amfphp/gateway.php");
                    var res2:Responder = new Responder(onResult, onFault);
                    function onResult(responds2:Object):void
                      iconResult = new ArrayCollection(responds2.serverInfo.initialData);  
                      trace(iconResult); 
                    function onFault(responds2:Object):void
                        for(var i in responds2)
                            trace(responds2[i]);
                   trace(cats);
                   gw2.call("Test.getCategoryIcons", res2, cats);
                   return res2;
                public function init()
                    getDistinct();
                    getIcons("business");
               public function changeIcons(cat)
               trace(cat);
               getIcons(cat);
               iconTiles.dataProvider = iconResult;
               iconTiles.labelField = iconResult[0];
               iconTiles.iconField = iconResult[0];
            ]]>
        </mx:Script>
    <mx:List id="categoryList"
    width="150" x="75" y="113"
    dataProvider = "{categoryResult}" labelField="1"
    change="changeIcons(categoryList.selectedItem)" >
    </mx:List>
    <mx:TileList id="iconTiles"
    x="223" y="113" height="156"
    width="500"
    labelField=""
    ></mx:TileList>
    </mx:Application>

  • Filtering array collections

    I am trying to filter an array collection.
    It is a list of rooms. The rooms have a type, "Boardroom",
    "Classroom" etc.
    Also they have equipment properties which are set with a
    boolean value.
    ex. Screen = true, Whiteboard = false etc.
    What I want to do is filter the array collection using
    multiple conditions.
    Scenario:
    Choose room type from combo. --- this works great :)
    Screen(Check if needed) ---- Here is where my problem lies,
    When I check the box, the false results are filtered out great! But
    if I uncheck the box, only the false results are shown. However,I
    would like to show both true and false results for the screen
    property. If it is unchecked it means the user is not interested in
    screens thus the data doesn't need to be filtered for that
    property.
    I have tried various ways.
    This is where I'm at so far
    private function filterByRoomType():void{
    allRooms.filterFunction = roomTypeFilter;
    allRooms.refresh();
    private function roomTypeFilter(item:Object):Boolean{
    seatingText.text = "+"+seatingSlider.value;
    if(roomTypeCombo.selectedItem=="All"){
    return item.SeatingCap >= seatingSlider.value&&
    item.Desks >= deskSlider.value&&
    item.Beds >= bedSlider.value&&
    item.Screen == screenCB.selected;
    }else{
    return item.RoomType ==
    roomTypeCombo.selectedLabel&&
    item.SeatingCap >= seatingSlider.value&&
    item.Desks >= deskSlider.value&&
    item.Beds >= bedSlider.value&&
    item.Screen == screenCB.selected;
    I have tried changing "item.Screen == screenCB.selected" to
    "item.Screen == screenCB.selected||false;" but with no joy.
    Once I get the screen checkbox working I would like to
    increase the amount of checkBoxes(properties) the user can search
    on.
    This one has got me ripping my hair out, any help would be
    muchly appreciated
    thanks
    bazjapan
    Oh yes, This is a room object.
    package dto
    [Bindable]
    public class Room
    public var RoomID:int;
    public var RoomName:String="";
    public var RoomType:String="";
    public var SeatingCap:int;
    public var Desks:int;
    public var Beds:int;
    public var Screen:Boolean;
    public var OHP:Boolean;
    public var Sink:Boolean;
    public var FlipChart:Boolean;
    public var Hoist:Boolean;
    public function Room(obj:Object = null)
    if (obj != null)
    this.RoomID = obj.RoomID;
    this.RoomName = obj.RoomName;
    this.RoomType = obj.RoomType;
    this.SeatingCap = obj.SeatingCap;
    this.Desks = obj.Desks;
    this.Beds = obj.Beds;
    this.Screen = obj.Screen;
    this.OHP = obj.OHP;
    this.Sink = obj.Sink;
    this.FlipChart = obj.FlipChart;
    this.Hoist = obj.Hoist;

    That change won't make an iota of difference logically if
    screenCB.selected = false. You're doing:
    if (item.Screen == false || false)
    What it looks like you want to say is
    (screenCB.selected ? item.Screen == screenCB.selected : true)
    HTH =)

  • Re-casting of object from control reference

    I feel like this question is likely answered elsewhere, but after days of searching I couldn't find an answer. Sorry if I'm missing the answer in some obvious place.
    I'm given a reference to a cluster control and told that the elements of the cluster are all children of parent class A. Using the controls[] property I get an array of the elements, and the value property of each of those elements gives a variant that can be turned into class A. At that point, all of the object oriented overriding and private data stuff works as expected.
    So far so good.
    But one method I call on those objects changes the private data, and I need to update the control with the updated object. There I get a runtime error because the control isn't A but some child class of A.
    I think this is where Preserve Runtime Class comes into play, but since I only get a reference to work with, what do I do? This is especially frustrating because debugging probes show that LabVIEW knows the child class on the wire, but I can't see how to tell LabVIEW to cast down to the class that it knows it has.
    For example, is there some way to use the ClassName property of the control to cast the object of class A into the child that the control is expecting?
    Solved!
    Go to Solution.

    nathand wrote:
    So your trying to write to the specific control within the cluster, by reference, as a variant, and you're getting an error? What's the actual text of the error?
    Really you shouldn't ever be using a front panel object this way, especially one where the user never sees the data in it. For passing data around you should use a wire. Neither a wire nor a DVR will get you the ability to pass an arbitrary cluster, though, which it sounds like is what you're trying to do. With a bit more information we might be able to suggest a better approach.
    I don't have the text of the error handy, but it comes from the write value property node and basically says the given variant can't be converted to the type of the control. It happens only when the value is cast to the parent class, which makes sense.
    In other words, given a control of child type,
    control.value ---> variant ---> to parent ---> variant ---> control.value     failes with the error
    control.value ---> variant ---> to child ---> variant ---> control.value       succeeds
    So a solution would be a way to cast to the child instead of to the parent. LabVIEW knows what class the control contains; it is listed in a number of places from the ClassName property through the probe window. The problem is I know of no way to bridge the gap from "LabVIEW knows what class this thing is" to "have LabVIEW cast the variant to that class."
    I completely agree that I shouldn't have to ever be using a front panel control this way, but I don't want to get sidetracked into talking about the shortcomings of LabVIEW that have required such a use. Suffice it to say, that is the assignment.

  • Accessing Query ColumnList in Array Collection

    I want to get the Column names in a query object returned
    from a WebService as an Array Collection.
    I have a WebService that is returning the following SOAP
    data:
    <?xml version="1.0"
    encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="
    http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsd="
    http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="
    http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Body>
    <ns1:sStockQuotesResponse soapenv:encodingStyle="
    http://schemas.xmlsoap.org/soap/encoding/"
    xmlns:ns1="
    http://cfc.private">
    <sStockQuotesReturn xsi:type="ns2:QueryBean" xmlns:ns2="
    http://rpc.xml.coldfusion">
    <columnList soapenc:arrayType="xsd:string[4]"
    xsi:type="soapenc:Array" xmlns:soapenc="
    http://schemas.xmlsoap.org/soap/encoding/">
    <columnList
    xsi:type="xsd:string">name</columnList>
    <columnList
    xsi:type="xsd:string">symbol</columnList>
    <columnList
    xsi:type="xsd:string">lastprice</columnList>
    <columnList
    xsi:type="xsd:string">lastpricedate</columnList>
    </columnList>
    <data soapenc:arrayType="xsd:anyType[][7]"
    xsi:type="soapenc:Array" xmlns:soapenc="
    http://schemas.xmlsoap.org/soap/encoding/">
    <data soapenc:arrayType="xsd:anyType[4]"
    xsi:type="soapenc:Array">
    <data xsi:type="soapenc:string">ALCOA INC</data>
    <data xsi:type="soapenc:string">AA</data>
    <data xsi:type="soapenc:string">35.87</data>
    <data xsi:type="soapenc:string">11/12/2007
    4:00pm</data>
    </data>
    </data>
    </sStockQuotesReturn>
    </ns1:sStockQuotesResponse>
    </soapenv:Body>
    </soapenv:Envelope>
    I have no problem converting the data to a Flex Array
    Collection, and populating a DataGrid with this data.
    However, I want to grab the Column Names, so that I can
    create the DataGrid columns dynamically. I have searched the FB3
    documentation, but cannot find an answer. Please help.
    Thank you.
    Eric.

    I'm not sure about dealing with a Remote Object / CFC
    configuration, but if your collection essentially ends up like:
    var myAC:ArrayCollection = new ArrayCollection([{name:
    'First', phoneNumber: '555'}]);
    Then yes you should be able to access it with:
    myAC.getItemAt(0).phoneNumber
    I take this has not worked?

Maybe you are looking for

  • Where do you buy A Macbook Air's Macintosh HD disk. Also how much does a 125gb cost?

    Where do you buy A Macbook Air's Macintosh HD disk. Also how much does a 125gb cost?

  • Which privilege to access active SQL instruction tab

    Hi all, On sqldeveloper when I am supervising the sessions on my new database, the screen shows the complete list of sessions. But if I click on one of the sessions to have more details, like running SQL query, an error occurs : SEVERE     1378     2

  • AMD64 3200+ & MSI Neo FIS2R. Working great after some problems!!

    Hi all... after have some troubles with my new computer, now all is working near to OK. (EDIT:  I've changed my sig because I've done many changes to my PC. The memory I had before was 2x512 VDATA pc3200) As you can see in my sig my power suply is PA

  • JMS Access in OSB

    Hi I am trying to enqueue data in a queue. Syntax for End Point Uri is:      jms://host:port(,host:port)*/FactoryJndiName/DestJndiName In my case FactoryJndiName and destJndiName contains '/'. How to escape '/' in Endpoint uri, so that it will read F

  • HELP! Audio Sync Problem????

    Recorded Audio (60mins) using 'Samplitude' and can't sync the Audio with captured footage! It seems to lose sync 15mins in. Please help, it's a major job I need to finish! Used Clapper board to visually sync and cant explain why this happens? MacBook