Hey Ravi,
man that's true that you will not get compile time error, but rather
you will get Run Time Error.
I am sure, when we say error, it includes both compile time and rum
time errors. :)
also, not sure why you are saying data is already arraycollection.
When it is getting retrived using httpservice, it is an object unless
and untill you define the "resultFormat" and to use that data as a
Arraycollectin source, you do need to parse that object into
arraycollection.
I see only this xml which KKH's is using.
Xml:
<?xml version="1.0" encoding="utf-8"?>
<img>
<src>
<path>assets/1.png</path>
</src>
<src>
<path>assets/2.png</path>
</src>
<src>
<path>assets/3.png</path>
</src>
</img>
I am sure, whatever I suggested is correct in all respect. Please
correct me if I am wrong. :)
-HTH
Thanks,
Shaleen Jain
http://shaleenjain.blogspot.com
On Apr 15, 2:40 pm, Ravi Mishra <[email protected]> wrote:
> @Shaleen
>
> The error you have mentioned is actually not an error. Flex compiler
> gives you a compile time error when you try to do something like this
>
> myData = event.result
>
> because result is defined as an object type.
> But if you write something like event.result.img.src then compiler
> itself doesn't know about the data type of img.src therefore it does
> not throw error at compile time. And as soon as u are sure of the data
> type of event.result.img.src you need not to typecast it into some
> data type.
>
> In the KKH's case event.result.img.src is coming out as
> ArrayCollection itself so he doesn't actually requires to type cast it
> again in ArrayCollection.
>
> HTH,
>
> -Ravi
>
> On Apr 15, 1:12 am, Shaleen Jain <[email protected]> wrote:
>
> > Ist error in this piece of code
>
> > [Bindable]
> > private var myData:ArrayCollection;
>
> > private function resultHandler(event:ResultEvent):void
> > {
> > myData = event.result.img.src;
> > }
>
> > you forget to make the instance of the arrycollection
> > Second you didn't parse event.result.img.src into arraycollection
>
> > The correct code is
> > [Bindable]
> > private var myData:ArrayCollection;
>
> > private function resultHandler(event:ResultEvent):void
> > {
> > myData = new ArrayCollection();
> > myData = event.result.img.src as ArrayCollection;
> > }
>
> > Second there is no method like getListItems which you are trying to
> > access.
> > Instead you should use getItemAt(indexValue);
>
> > HTH
>
> > Thanks,
> > Shaleen Jainhttp://shaleenjain.blogspot.com
>
> > On Apr 6, 5:21 pm, Ravi Mishra <[email protected]> wrote:
>
> > > set a breakpoint on the resultHandler function and check what
> > > event.result is returning. This will help you.
>
> > > -Ravi
>
> > > On Apr 6, 4:21 pm, KKH <[email protected]> wrote:
>
> > > > Hi Friends,
>
> > > > I am new comer in flex. i have one dought . how to get the list of
> > > > value and dispaly it from the xml file. plz verify following prg
> > > > correct or not
>
> > > > this is Mxml:
>
> > > > <?xml version="1.0" encoding="utf-8"?>
> > > > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
> > > > backgroundGradientColors="[0xFFFFFF, 0xAAAAAA]"
> > > > horizontalAlign="left"
> > > > verticalGap="15" horizontalGap="15" initialize="myService.send()">
> > > > <mx:Script>
> > > > <![CDATA[
> > > > import mx.collections.ArrayCollection;
> > > > import mx.rpc.events.ResultEvent;
>
> > > > [Bindable]
> > > > private var myData:ArrayCollection;
>
> > > > private function resultHandler(event:ResultEvent):void
> > > > {
> > > > myData = event.result.img.src;
> > > > }
>
> > > > ]]>
> > > > </mx:Script>
>
> > > > <mx:HTTPService id="myService" url="assets/img_path.xml"
> > > > result="resultHandler(event)"/>
>
> > > > <mx:Text id="something" text="{myData.getListItems.path}"
> > > > enabled="true" visible="true"/>
>
> > > > <mx:Image id="myimg" source="{myData.getListItems.path}" />
>
> > > > <!-- <mx:Text id="something" text="{myData.getItemAt
> > > > (0).path}"
> > > > enabled="true" visible="true"/>
>
> > > > <mx:Image id="myimg1" source="{myData.getItemAt(0).path}" /> --
>
> > > > </mx:Application>
>
> > > > Xml:
>
> > > > <?xml version="1.0" encoding="utf-8"?>
> > > > <img>
> > > > <src>
> > > > <path>assets/1.png</path>
> > > > </src>
> > > > <src>
> > > > <path>assets/2.png</path>
> > > > </src>
> > > > <src>
> > > > <path>assets/3.png</path>
> > > > </src>
> > > > </img>
>
> > > > Thanks & Regards
> > > > KKH
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Flex
India Community" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/flex_india?hl=en
-~----------~----~----~----~------~----~------~--~---