Thanks very much, that worked a treat.

Best Regards,

Iain

--- In [email protected], "Doug Lowder" <[EMAIL PROTECTED]> 
wrote:
>
> Sorry for the typo - 
> 
>    editableArray = originalArray.slice();
> 
> should be
> 
>    editableArray = array.slice();
> 
> 
> --- In [email protected], "Doug Lowder" <douglowder@> 
wrote:
> >
> > What you are doing is accessing two different references to the 
same
> > array object.  The mx.utils.ArrayUtil.toArray() function simply
> > returns a reference to the parameter if it is already an array, 
so in
> > that case it will always contain the same data as your list's
> > dataprovider.
> > 
> > What you can do instead is the following:
> > 
> > // within the result function
> > array = mx.utils.ArrayUtil.toArray(event.result);
> > editableArray = originalArray.slice();
> > 
> > // outside the function
> > var array:Array;
> > var editableArray:Array;
> > 
> > And for your list's dataprovider:
> > 
> > dataProvider="{editableArray}"
> > 
> > Now you will have two different Array objects, array and
> > editableArray, that you can compare with your existing code.
> > 
> > Hope that helps,
> > Doug
> > 
> > --- In [email protected], "digital_eyezed" 
<iain.mclean@>
> > wrote:
> > >
> > > 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

<*> 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