Reputation: 1075
I've tried every example I could find, but nothing really worked. What I'm looking for the to actionscript code (without using classes - i'd like to do all the code in the section of the mxml file) to load in an XML file that is stored in the same location as the swf file.
My XML is set up like the following:
<?xml version="1.0" encoding="utf-8"?>
<projects>
<project>
<projName>project1</projName>
<startDate>5/5/2011</startDate>
<positions>
<position>
<startOffset>1</startOffset>
<numDays>4</numDays>
<role>1D</role>
<student>Project 1 - Name 1</student>
</position>
... repeat for however many position pieces there are
</positions>
</project>
... repeat for however many project pieces there are
</projects>
I am looking to read this in as a simple XML (projectsXML for the variable name) so that i can do something like:
<mx:Repeater id="singleProject" dataProvider="{projectsXML.projects.project}">
<mx:Text id="projectName" text="{singleProject.currentItem.projName}" />
</mx:Repeater>
What I'll actually be doing is calling components within the repeater and passing along the variables, but if i can achieve the above, I'm pretty sure I can figure out the rest.
If anybody can help me out here, it'd be greatly appreciated... so i can stop pounding my head against the wall :(
Thanks in advance, Alex
Upvotes: 0
Views: 1020
Reputation: 3957
Try this and see if it works ...
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
minWidth="955" minHeight="600"
creationComplete="{projectsHttp.send()}" layout="vertical">
<mx:HTTPService id="projectsHttp" url="projects.xml" />
<mx:Repeater id="rpt"
dataProvider="{projectsHttp.lastResult.projects.project}" >
<mx:Label text="{rpt.currentItem.projName}" />
</mx:Repeater>
</mx:Application>
Upvotes: 2
Reputation: 609
You would use the HTTPService (or a similar method) to load the XML data, then use the result to populate your list after it has loaded.
Here is an example: http://blog.flexexamples.com/2008/03/29/dynamically-loading-xml-files-using-the-httpservice-tag/
The URLLoader class is also an option in lieu of HTTPService. The general method is the same for both.
Upvotes: 1