I assume you solved this by now but it sounds like you need a copy of
the array itself, not a copy of all that data.  You can get an array
copy by calling concat() on the array.  Then in one place you can use
the service result, and in the place where you do the drag and drop to
assign you would use the copy.

Matt

-----Original Message-----
From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of digital_eyezed
Sent: Monday, March 20, 2006 2:19 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] I don't want a binding!

HI,

I have an issue with an array which created on the result of a 
remoteObject call. The result is set to an array like this inside 
the result function:

array = new Array();
array = mx.utils.ArrayUtil.toArray(event.result);

The array is substantiated outside this function like so:

var array:Array;

The result from the remoteObject is also used as a dataProvider to a 
List, which has drag and drop functionality and the dataProvider is 
assigned as such:

dataProvider="{service.getMethod.result}"

Now, this lists' dataProvider can enlarge as objects are added to it 
through dragging and dropping, irrelevant I hear you say.

The problem is, I set the array when the result is received in order 
for me to check it against the datProvider of the List before I 
return it to the server (i.e. I do a diff on the array from the 
result and the dataProvider on the List and I get a new array of the 
new Objects dragged to the List), like this:

public function addNewObjects(){
var newArray:Array = new Array();
var newArray2:Array = new Array();
arrayOfListObjects = mx.utils.ArrayUtil.toArray(list.dataProvider);
newArray = NotInB(arrayOfListObjects,array);
        if(newArray.length != 0){
        for(var k = 0;k<newArray.length;k++){
        var newObjectVO:ObjectVO = new ObjectVO();
        newObjectVO.label = newArray[k].label;
        newObjectVO.data = newArray[k].data;
        newArray2.push(newObjectVO);
        }
        service.addObjects(newArray2);
        }else{
        mx.core.Application.alert("Complain a lot about not adding 
anything!");
   }
}

for clarity the NotInB function does this:

public function NotInB(arrayA,arrayB) {
        var tempAry= new Array();
        var i,j;
        for (i=0; i<arrayA.length; i++) {
                for (j=0; j<arrayB.length; j++) {
                        if (arrayA[i].data==arrayB[j].data) {
                                break;
                        }
                }
                if (j==arrayB.length) {
                        tempAry.push(arrayA[i]);
                }
        }
        return tempAry;
}

No problem, this all works first time without an issue, and the 
objects are passed to the server as expected, then everything goes 
wrong. From then on the array which is set from the result object is 
set ok (I have traced out the array when it is created every time 
and it is correct), but when I drag objects to the List they are 
also added to this array, why? there is no binding to it! so every 
time after the first time I add the new objects I 'Complain a lot 
about not adding anything!'.

Please help.

Cheers,

Iain






--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives:
http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links



 




--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to