Merge/Concat two arrays of objects

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

  1. #1

    Default Merge/Concat two arrays of objects

    Hi,

    This seems a simple thing but I can not find a solution.

    Has I run through some data I create an inner array and outer array

    The outer array is then made into an array collection.

    I need to concat the inner array to the outer.

    I have tried array.concat(array), ObjectUtil.copy but no joy.
    Code cut for space

    out loop {
    inner loop {
    permSet.push({permtype:'Test',value:Number(current Perm)});
    }

    newVolume.push({label:String(volume.@label),path:S tring(volume.@volpath),subpath
    :String(volume.@subpath),modtime:String(volume.@mo dtime)});
    }
    volumeList = new ArrayCollection(newVolume);

    Thanks in advance
    Dean


    flashharry! Guest

  2. Similar Questions and Discussions

    1. Objects and Arrays...
      Hi, this is probably a stupid question. The question is that I want a particular class of objects to have several attributes, one of them a...
    2. Storing Objects/Arrays in Stored Objects
      Hello All, I recently came across a very frustrating issue when trying to create and store arrays within objects in a Shared object. It took me...
    3. [PHP-DEV] Objects as Arrays
      Hello internals, IIRC it was intended to use object properties as arrays. Currently most array_*() functions do explicitly check for IS_ARRAY....
    4. Need bit of PHP code to merge arrays
      Hi Al! On Tue, 05 Aug 2003 19:42:13 -0700, "Adams-Blake Co." <atakeoutcanton@adams.takeme.out.-blake.com> wrote: From the array_merge() page:...
    5. Using & for arrays of objects
      On Fri, 27 Jun 2003 09:48:56 +0900 "Krishna Dole" <kpdole@ucdavis.edu> wrote: & uses hashes under the hood. You need to define #hash and #eql?...
  3. #2

    Default Re: Merge/Concat two arrays of objects

    Not following. Maybe you cut too much code. i can't tell what you want to do. Be a bit more verbose, use the Attach Code window so you code does not lose its formatting.
    Tracy
    ntsiii Guest

  4. #3

    Default Re: Merge/Concat two arrays of objects

    I want to end up with a data grid that shows all the data from both arrays per
    row

    The volume permissions are a integer of a binary representation. So I convert
    the integer back to binary and split to an array. Now I have a array with 32
    elements either on or off (1 or 0), representing arbitrary user permissions per
    volume.

    We skip 3 of the elements as there not used. But I end up with an array
    "permSet" of 29 object either 1 or 0.
    Now I want to add these 29 elements to the outer array "newVolume" so I end up
    with the original 4 elements plus the 29 from the inner array, my grid will end
    up with 33 columns, 29 of which will be an item renderer of tick marks

    I hope that makes more sense,

    Thanks in advance
    Dean

    public function init():void {
    //trace("VolumePerms" + volumePerms);
    var newVolume:Array = new Array;
    var permSet:Array;
    var binaryPerms:Array;
    var currentPerm:int;
    var binaryLength:int;
    var newArrayConcat:Array;
    for each (var volume:XML in volumePerms.volume) {
    //convert flags to binary equivelent
    iBinaryCount = 1;
    permSet = new Array;
    binaryPerms = new Array
    binaryPerms = String(Number(volume.@flags).toString(2)).split('' );
    binaryLength = binaryPerms.length; //store length as we will alter in
    loop
    trace(binaryPerms);
    for (var i:int = 0; i < binaryLength; i++){
    currentPerm = binaryPerms.pop();
    if (iBinaryCount == 128 || iBinaryCount == 1048576 || iBinaryCount ==
    2097152) {
    iBinaryCount = iBinaryCount * 2;
    continue;
    }
    iBinaryCount = iBinaryCount * 2
    // now lets push value
    permSet.push({permtype:'Test',value:Number(current Perm)});
    }

    newArrayConcat = new Array();

    newVolume.push({label:String(volume.@label),path:S tring(volume.@volpath),sub
    path:String(volume.@subpath),modtime:String(volume .@modtime)});

    trace(ObjectUtil.toString(permSet));
    newArrayConcat = newVolume.concat(ObjectUtil.copy(permSet));
    }
    volumeList = new ArrayCollection(newVolume);
    }

    flashharry! Guest

  5. #4

    Default Re: Merge/Concat two arrays of objects

    Could you not create your base volume object above the inner loop, then in the loop, add each permSet elemtne to that object?
    Tracy
    ntsiii 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