Ask a Question related to Macromedia Flex General Discussion, Design and Development.
-
flashharry! #1
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
-
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... -
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... -
[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.... -
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:... -
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?... -
ntsiii #2
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
-
flashharry! #3
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
-
ntsiii #4
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



Reply With Quote

