I added:
private function resultHandler(event:ResultEvent):void {
myData = event.result.sites.site;
trace("myData.length: "+myData.length);
myData.removeItemAt(0);
trace("myData.length: "+myData.length);
}
and corrected your xml by closing the <sites> markup.
and saw:
myData.length: 2
myData.length: 1
So, no problems with the solution!
Paul
----- Original Message -----
From: "flexawesome" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Sunday, November 04, 2007 2:13 AM
Subject: [flexcoders] Re: remove a item in ArrayCollection
>
> here is my completed code... I am going to remove the first site of
> *adobe* in xml
>
> this seems doesn't in this case, any suggestion? Thanks
>
> myData.removeItemAt(myData.getItemAt(0));
>
> ====== need to remove this part out from ArrayCollection ======
> <site>
> <label>ADOBE</label>
> <totals>500</totals>
> <doc_url>www.adobe.com</doc_url>
> </site>
> ===============================================================
>
> Code from here......
>
> ============ Main MXML File ============
>
> <?xml version="1.0"?>
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
> layout="absolute"
> creationComplete="dataServices.send()">
>
> <mx:Script>
> <![CDATA[
>
> import mx.events.*;
> import mx.rpc.events.*;
> import mx.collections.*;
> import mx.controls.*;
>
> [Bindable]
> private var myData:ArrayCollection;
>
>
> private function resultHandler(event:ResultEvent):void {
> myData = event.result.sites.site;
> }
>
> ]]>
> </mx:Script>
>
> <mx:HTTPService id="dataServices" url="myXML.xml"
> resultFormat="object"
> result="resultHandler(event)"/>
>
> </mx:Application>
>
> ========================================
>
> ============ myXML.xml =============
>
> <?xml version = "1.0" encoding="utf-8"?>
> <sites>
> <site>
> <label>ADOBE</label>
> <totals>500</totals>
> <doc_url>www.adobe.com</doc_url>
> </site>
>
> <site>
> <label>GOOGLE</label>
> <totals>300</totals>
> <doc_url>www.google.com</doc_url>
> </site>
> <sites>
>
> ===================================
>
> --- In [email protected], "Paul Andrews" <[EMAIL PROTECTED]> wrote:
>>
>> There shouldn't be a problem with Simons suggestion.
>>
>> Post your code. The message seems to suggest you didn't declare
> myData as an
>> ArrayCollection, but your original code did.
>>
>> Hmm..
>>
>> Paul
>> ----- Original Message -----
>> From: "flexawesome" <[EMAIL PROTECTED]>
>> To: <[email protected]>
>> Sent: Sunday, November 04, 2007 1:29 AM
>> Subject: [flexcoders] Re: remove a item in ArrayCollection
>>
>>
>> > hummm....
>> >
>> >
>> > I got this error msg:
>> >
>> > ===============================
>> >
>> > Severity and Description Path Resource Location Creation Time Id
>> > 1118: Implicit coercion of a value with static type Object to a
>> > possibly unrelated type mx.collections:ArrayCollection. test.mxml
>> > line 69 1194139654331 151789
>> >
>> >
>> > --- In [email protected], "simonjpalmer" <simonjpalmer@>
>> > wrote:
>> >>
>> >> how about
>> >>
>> >> myData.removeItemAt(0)?
>> >>
>> >> --- In [email protected], "flexawesome" <flexawesome@>
> wrote:
>> >> >
>> >> >
>> >> >
>> >> > Hey there,
>> >> >
>> >> > I have a problem to remove the first *object* in myData, any
>> > suggestion?
>> >> >
>> >> > Thank you
>> >> >
>> >> > ===========================
>> >> >
>> >> >
>> >> > [Bindable]
>> >> > private var myData:ArrayCollection;
>> >> >
>> >> > myData.removeItemAt(myData.getItemAt(0));
>> >> >
>> >>
>> >
>> >
>> >
>> >
>> > --
>> > 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
>
>
>
>