Posts Tagged ‘xml’

Two helpful resources on Flash, objects & arrays

Saturday, April 11th, 2009

For the Gotchi-Sim project, I am planning to store data from an XML file into an array of objects.

I think these two sites will be helpful to me when trying to program that:

Complex data types: Arrays and Objects
http://flash-creations.com/notes/actionscript_complexdata.php

briening.com: Flash Data Structures: Array vs Object
http://briening.com/flash/flash-array-vs-object

a break through with using XML in flash!

Saturday, April 11th, 2009

I’ve been struggling with XML in Flash for days… I found two pieces of information that really helped me a lot… so I thought I’d share them here.

1. The difference between an element node and a text node!

I found out today that some nodes were classed as element nodes and some are classed as text nodes. What I didn’t know was that the text is a node.

For example in this small XML document:

<conversation>
<INTERACTION>
<NPC_says>
What would you like to order?
</NPC_says>
<player_says>
I would like pizza.
</player_says>
</INTERACTION>
</conversation>

The node conversation, interaction, NPC_says and player_says are all element nodes.

I had thought that NPC_says & player_says would be text nodes… but that is not correct, they are both element nodes. The text inside these tags are text nodes. That is, What would you like to order? is a text node as is I would like pizza.

To reference the text what would you like to order? text, you would reference it as follows:

myXML.firstChild.firstChild.firstChild.firstChild

Previously, I thought it would be referenced by:

myXML.firstChild.firstChild.firstChild.nodeValue

Check out this site for more info: XML basics at www.kirupa.com
http://www.kirupa.com/web/xml/XMLbasics4.htm

2. There is an ignoreWhite property

If you don’t tell your xml documen to ignore white space it can pick up blank spaces and think they are nodes in the XML document.

ignoreWhite property
http://www.actionscript.org/resources/articles/9/1/XML-101/Page1.html

I now think I’m ready to take on the XML scripting of the Gotchi-Sim project for real! Yay!

using xml with flash

Sunday, April 5th, 2009

I am currently working through the best way to use XML with Flash. My previous experience has been in using text files with Flash – not XML files…. so I’m trying to find information about best practice before I dive in… I’m also trying to decide on the best structure for the conversation interchanges too – but that’s another story!

Here are some links that I’ve found helpful so far:

Peach pit guides (links to a series of articles on XML are near the bottom of the page)
Recursive functions & XML in Flash

more to come…

Peach pit recommends the XML fox editor.