Well you have to design your UI and functionality and the field is wide open
there. You also need to decide the best way to load and link the data to
your UI and again there are options.
Here is an example of one of many ways you can go with both loading the data
and linking it to the UI. This is more hands on.
1. Remove all new line characters and spaces between XML tags. One long line
in the file. You can turn on wordwrap and line numbers is DW or TextPad as
you do and when you are done, only one line number will show.
2. Save it at data.xml for the example below.
3. Create a new Flash Movie, Save it.
4. Create a Layer call it AS.
5. Create another layer call it Display.
6. On the Display layer place two DataGrid components from the Flash
components panel on stage. Spread them out so they are wide as stage. Place
one at the top and one in the middle.
7. In each of their properties windows name them. For this example the names
are revelations_db for the top one and variations_dg for the bottom one.
8. Add this AS to the AS layer frame 1
var my_xmlData:Object = new Object() // Optional for holding all XML data
for future needs.
my_xmlData.revelationItems = new Array()
my_xmlData.variousItems = new Array()
var my_xml:XML = new XML()
my_xml.onLoad = function(success)
{
trace("my_xml.onLoad")
trace("\tsuccess = " + success)
if (success)
{
trace ("\tmy_xml (raw) = " + my_xml)
trace ("\n")
trace ("\tmy_xml.firstChild.firstChild (revelation node) = " +
my_xml.firstChild.firstChild)
var myRevelationNode:XMLNode = my_xml.firstChild.firstChild
for (var itemRevelationNode:XMLNode = myRevelationNode.firstChild;
itemRevelationNode != null; itemRevelationNode =
itemRevelationNode.nextSibling)
{
trace("\t\titemRevelationNode = " + itemRevelationNode);
trace ("\n")
var nextRevelationItem:Object = new Object
for (var itemRevelationChildNode:XMLNode = itemRevelationNode.firstChild;
itemRevelationChildNode != null; itemRevelationChildNode =
itemRevelationChildNode.nextSibling)
{
trace("\t\t\titemRevelationChildNode = " + itemRevelationChildNode);
trace ("\n")
nextRevelationItem[itemRevelationChildNode.nodeName] =
itemRevelationChildNode.firstChild.nodeValue
}
my_xmlData.revelationItems.push(nextRevelationItem)
revelations_dg.addItem(nextRevelationItem);
}
trace ("\n")
trace ("\tmy_xml.firstChild.childNodes[1] (various node) = " +
my_xml.firstChild.childNodes[1])
var myVariousNode:XMLNode = my_xml.firstChild.childNodes[1]
trace ("\n")
for (var itemVariousNode:XMLNode = myVariousNode.firstChild;
itemVariousNode != null; itemVariousNode = itemVariousNode.nextSibling)
{
trace("\t\titemVariousNode = " + itemVariousNode);
trace ("\n")
var nextVariousItem:Object = new Object
for (var itemVariousChildNode:XMLNode = itemVariousNode.firstChild;
itemVariousChildNode != null; itemVariousChildNode =
itemVariousChildNode.nextSibling)
{
trace("\t\t\titemVariousChildNode = " + itemVariousChildNode);
trace ("\n")
nextVariousItem[itemVariousChildNode.nodeName] =
itemVariousChildNode.firstChild.nodeValue
}
my_xmlData.variousItems.push(nextVariousItem)
variations_dg.addItem(nextVariousItem);
}
trace ("\n")
}
}
my_xml.load("data.xml")
9. Use Conttrol->Test Movie and you will see in the output window the data
elements of the program.
--
Lon Hosford
www.lonhosford.com May many happy bits flow your way!
[quoted text, click to view] "withhisstripes" <webforumsuser@macromedia.com> wrote in message
news:dm7t7v$npf$1@forums.macromedia.com...
Heya,
So I have the following XML script and I am trying to get it to
display
in my flash site but I don't have a clue how to use XML really. Can anyone
help? Thanks!
<?xml version="1.0" encoding="utf-8"?>
<revelation>
<item>
<title>The New Heaven and the New Earth</title>
<scripture>Revelation 21:1-8</scripture>
<teacher>John Mark Comer</teacher>
<date>10/28/2005</date>
<rm_size>5.63 MB</rm_size>
<rm_link>
http://srfchurch.org/theway/teachings/10-28-2005.rm</rm_link>
<mp3_size>16.2 MB</mp3_size>
<mp3_link>
http://srfchurch.org/theway/teachings/10-28-2005.mp3</mp3_link>
</item>
<item>
<title>The Millennium</title>
<scripture>Revelation 20</scripture>
<teacher>John Mark Comer</teacher>
<date>10/21/2005</date>
<rm_size>6.53 MB</rm_size>
<rm_link>
http://srfchurch.org/theway/teachings/10-21-2005.rm</rm_link>
<mp3_size>18.7 MB</mp3_size>
<mp3_link>
http://srfchurch.org/theway/teachings/10-21-2005.mp3</mp3_link>
</item>
</revelation>
<various>
<item>
<title>Choice to Rejoice</title>
<scripture>Isaiah 61:10</scripture>
<teacher>John Mark Comer</teacher>
<date>10/07/2005</date>
<rm_size>2.44 MB</rm_size>
<rm_link>
http://srfchurch.org/theway/teachings/10-07-2005.rm</rm_link>
<mp3_size>7 MB</mp3_size>
<mp3_link>
http://srfchurch.org/theway/teachings/10-07-2005.mp3</mp3_link>
</item>
</various>