Go Back   CodingForums.com > :: Client side development > Flash & ActionScript > Adobe Flex

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-11-2009, 11:47 PM   PM User | #1
ktiniatros
New to the CF scene

 
Join Date: Oct 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
ktiniatros is an unknown quantity at this point
passing xml data to a label with XMLList

Hi,

i read the data from an xml file and trying to pass some elements to a label:

Code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" 
	creationComplete="questionsData.send()">
<mx:HTTPService id="questionsData" url="assets/questions.xml" result="questionsHandler(event)" resultFormat="e4x"/>
	

<mx:Script>
	<![CDATA[
		 import mx.controls.Alert;
		 import mx.rpc.events.ResultEvent;
		 import mx.collections.ArrayCollection;
		 [Bindable]
		 public var questionsStock:XMLList;
		 public function questionsHandler(evt:ResultEvent):void {
		 	questionsStock=evt.result..title;
		 }
	]]>
</mx:Script>
<mx:Label x="210" y="113" text="{questionsStock.text()}" width="216" height="20" id="label1"/>
	</mx:Application>
the xml file is like this:
Code:
<?xml version="1.0" encoding="iso-8859-1"?>
<questions>
<question>
<title>An angle of 45 degrees is in radians:</title>
<correctAnswer>3</correctAnswer>
</question>
<question>
<title>Which angle is of the same terminal side with an angle of 60 degrees:</title>
<correctAnswer>2</correctAnswer>
</question>
</questions>
how can i get the content of one title at a time?? with questionsStock.text() i get the content of all titles.
ktiniatros is offline   Reply With Quote
Old 10-12-2009, 05:23 PM   PM User | #2
nikos101
Senior Coder

 
nikos101's Avatar
 
Join Date: Dec 2006
Location: London
Posts: 1,004
Thanks: 58
Thanked 10 Times in 10 Posts
nikos101 is an unknown quantity at this point
questionsStock=evt.result..title;

for each( var o : Object in questionsStock){
//do your stuff
}
__________________

nikos101 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:22 PM.


Advertisement
Log in to turn off these ads.