Welcome Guest [Log In] [Register]
Welcome to Brackenwood. We hope you enjoy your visit.


You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
Retreive Data From Xml Feed?; how would i do that?
Topic Started: Apr 19 2005, 08:42 PM (115 Views)
demented_yam
Member Avatar
Brackenwood Heavyweight
there is an online political simulation game that i am a member of, and i am interested in making the world map for it in flash.

however, the map cannot be static, it needs to retrieve data from an XML document (to see who is in control of which region, ect.)

to put it simply: how do i do that?
Offline Profile Quote Post Goto Top
 
Markham Carroll
Member Avatar
Custom member title
Code:
 

var movieclip:XML = new XML();
movieclip.ignoreWhite = true;

movieclip.onLoad = function(success) {
//do whatever with what is loaded. Check the Flash help files and do a search for XML in the actionscript reference section
};

movieclip.load("data.xml");
Offline Profile Quote Post Goto Top
 
demented_yam
Member Avatar
Brackenwood Heavyweight
the .xml file already exists, i just need to pull the data off of it.

but yea, i'll check out the help menus

(never even occurred to me that i might find something useful in there :P )
Offline Profile Quote Post Goto Top
 
Markham Carroll
Member Avatar
Custom member title
You misunderstand - to get XML data, you need to create an XML object in Flash using actionscript and then load an XML file into it.
Offline Profile Quote Post Goto Top
 
demented_yam
Member Avatar
Brackenwood Heavyweight
Markham Carroll
Apr 20 2005, 11:45 AM
You misunderstand - to get XML data, you need to create an XML object in Flash using actionscript and then load an XML file into it.

...


oh.


well then.
Offline Profile Quote Post Goto Top
 
mikepol
Member Avatar
Brackenwood Newbie
and to make parsing easy, i'd use

http://www.xfactorstudio.com/

fer sure!
Offline Profile Quote Post Goto Top
 
Squidclops
Member Avatar
Guy with a hat.
To access the data in your xml file vie flash you need 2 things:

1. an XML object

2. you need to know the structure of the xml document

The XML object in flash lets you access xml nodes and their attributes but you need to know the structure of the data in your xml document otherwise you wont know what data to access and how.

You can access the xml data through querying various properties of the xml object, for example childNodes, and firstChild.

The easiest way to think of an xml document is as a multi - dimensional array.

You will find that when you want to read a property of your xml object you will most likely be looking at an array or information held in an array. As an example you will see that the property childNodes will return an array of xml nodes from your xml object. Likewise the property firstChild returns the first array item from a list of xml nodes.

You can also use the array index square brackets to access xml data. For example indices in an array of childNodes can be accessed thus: childNodes[x]. This comes in very handy.

And because the childNodes property is an array you can apply the length property to it to see how many items there are in the array.

And so on and so forth.
Offline Profile Quote Post Goto Top
 
BonzaiRob
Member Avatar
The Demon Plasterer
Is it possible to send data to XML? I'm trying to make a 2d interaction envionment... I'll have sprites for the people in the area (8 max) which get instructions such as the direction they are facing and position from the XML; of course, to move your character, it would send updated info to the XML for the others in the area to see you move.
This could also be used for chats, you'd just have a node for the chatroom and anyone could add to it...
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Actionscript · Next Topic »
Add Reply