Adobe Flex
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Tutorialized ForumsWeb Design & DevelopmentAdobe Flex

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Tutorialized Forums Sponsor:
  #1  
Old April 14th, 2008, 09:15 AM
stinkytofu stinkytofu is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 4 stinkytofu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 46 m 54 sec
Reputation Power: 0
XML and ResultEvent parsing

I have the following XML created by a PHP file:

Code:
<output>
<projects>
<project id="1" name="SL Recruitment"/>
</projects>
<taskLists>
<taskList id="1" name="Iteration 1"/>
</taskLists>
</output>


I have set up a handler function that will grab the event and parse the XML. The code looks something like this:

Code:
httpService.addEventListener(ResultEvent.RESULT, resultHandler);
httpService.send();

private function resultHandler(event:ResultEvent):void
{
Alert.show(event.result.output.projects.project);
Alert.show(event.result.output.taskLists.taskList)  ;
}


The strange thing is that the first Alert call works and [object][object] is displayed, and I can parse that data and put it into an ArrayCollection object. However, the second Alert call cannot seem to find event.result.output.taskLists.taskList, and returns the following error:

TypeError:Error 1010: A term is undefined and has no properties

Seems Flex cannot find the 'taskLlists' element in the XML file and is returning a null object.

Any idea what may be wrong? Why am I only able to access the first element in the XML file, but not the second element? Am I missing something? I just can't figure out what I am doing wrong here. Help!

Thanks!

Last edited by stinkytofu : April 14th, 2008 at 09:17 AM.

Reply With Quote
  #2  
Old April 14th, 2008, 09:48 AM
stinkytofu stinkytofu is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 4 stinkytofu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 46 m 54 sec
Reputation Power: 0
It works now

Never mind, managed to figure it out. It appears that there was something wrong with the PHP script and it was outputing the wrong XML code.

Just for future reference so I can avoid these stupid mistakes, does anybody know how I can use Alert.show to view the contents of the ResultEvent.result object? I've tried using:

Alert.show(event.result.toString());
Alert.show(event.result.output.toString();
Alert.show(event.result);

But all of these simply display the text "[object Object]". How can I view the actual contents of the resultEvent.result object? I want to be able to see something like this in the alert window:

<output>
<projects>
<project id="1" name="SL Recruitment"/>
</projects>
<taskLists>
<taskList id="1" name="Iteration 1"/>
</taskLists>
</output>

This would really make debugging much easier.

Last edited by stinkytofu : April 14th, 2008 at 10:02 AM.

Reply With Quote
Reply

Viewing: Tutorialized ForumsWeb Design & DevelopmentAdobe Flex > XML and ResultEvent parsing


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT