Monster Racer Rush
Select between 5 monster racers, upgrade your monster skill and win the competition!
4.18 / 5.00 3,534 ViewsBuild and Base
Build most powerful forces, unleash hordes of monster and control your soldiers!
3.80 / 5.00 4,200 Views[AS3] Im am working on a kind of dynamic conversation system. When talking to a character you will be given a variety of different dialog options, accompanying each of these dialog options is a cost to say it, Dialog option one might require 10 charisma etc
The problem being I need a way to store a large numbers of these dialog options without cluttering up my code with a big list of strings and variables. Obviously the solution is to store the dialogue options and the requirements to say them externally.
I dont have much knowledge of setting up either external class as files or xml but I think both of these options could be a potential solution. I have a friend in class who made flash app with lots of information about the solar system all his data was stored externally in an xml file.
All I want to know is would this bulk dialouge and dialouge cost information be better stored in an external XML, AS Class or some other file type?"
...
At 5/2/12 06:17 AM, the1manwiththeplan wrote: All I want to know is would this bulk dialouge and dialouge cost information be better stored in an external XML, AS Class or some other file type?"
First off, an AS Class isn't external. Secondly, if you are considering making an AS class, then why don't you and skip the hassle of file loading?
That being said, use XML.
At 5/2/12 06:34 AM, PSvils wrote:At 5/2/12 06:17 AM, the1manwiththeplan wrote: All I want to know is would this bulk dialouge and dialouge cost information be better stored in an external XML, AS Class or some other file type?"First off, an AS Class isn't external. Secondly, if you are considering making an AS class, then why don't you and skip the hassle of file loading?
That being said, use XML.
Sorry if I described AS3 classes in a way that was inconsistent with the nature of what they are. I have literally never used external AS3 from the flash application, am new to AS3 and always coded on the main timeline that's why I had to ask which would be more appropriate for my situation.
But thanks for the advice Ill look into how I could use XML to store my data and how to reference it later in my code.
Any good resource suggestions on the best site to learn how to do this?
...
At 5/2/12 06:56 AM, the1manwiththeplan wrote: Sorry if I described AS3 classes in a way that was inconsistent with the nature of what they are. I have literally never used external AS3 from the flash application, am new to AS3 and always coded on the main timeline that's why I had to ask which would be more appropriate for my situation.
But thanks for the advice Ill look into how I could use XML to store my data and how to reference it later in my code.
Any good resource suggestions on the best site to learn how to do this?
This is a start: http://www.republicofcode.com/tutorials/flash/as3xml/
There was another link I remember using, but I can't find it atm (just google it).
And BE SURE to include the doctype at the top of your XML file...I had so many errors before I realized that I forgot to put it
This is a start: http://www.republicofcode.com/tutorials/flash/as3xml/
There was another link I remember using, but I can't find it atm (just google it).
And BE SURE to include the doctype at the top of your XML file...I had so many errors before I realized that I forgot to put it
Thanks that resource was super helpful I had googled a site already but this one explained things much better.
When you say to include the doctype at the top of the file or it will throw an error are you referring to...
<?xml version="1.0" encoding="utf-8"?>
If so I remember the tutorial saying that this part was just good practice and optional.Why does it have to be included?
Also so far i understand that in the following xml
<IMAGE TITLE="shop">image3.jpg</IMAGE>
IMAGE is the name of the node and TITLE is an attribute with the value shop.
Is it possible to have more than one attribute? for example TITLE = "shop" SUBTITLE = "description"?
...
At 5/2/12 11:38 PM, the1manwiththeplan wrote: <?xml version="1.0" encoding="utf-8"?>
Yes, but mine has more words, pretty sure it specifically has "DOCTYPE" in it. It has something to do with E4X not recognizing it's XML without it. I made that up; I honestly have no idea.
Is it possible to have more than one attribute? for example TITLE = "shop" SUBTITLE = "description"?
Yeah.
I made a dialogue prototype for later on that also uses XML. Attributes are useful, but one can't have multiple values, which kinda bugged me. Nodes within nodes are very helpful to do that: for instance I have
<a1>
<text>I like pie and cake</text>
<speaker>Joe</speaker>
<next choice = "b1">b1</next>
<next choice = "c1">c1</next>
</a1>
I can have multiple "next" nodes, which all correspond to the dialogue that can possibly follow.
Regularly, XML code requires the version number in the first line. It is declared as:
<?xml version="1.0"?>
This is pretty standard for most languages, so a program running the file knows what, interrupters/libraries to access in order to run the code.
The encoding declaration:
<?xml version="1.0" encoding="UTF-8"?>
is not mandatory for XML code, however it is good practice to improve the readability of your code. If it is used, it must appear right after the version number in the XML declaration, and must be a valid encoding.
When using AS3, (Flash), it is not required. Flash automatically understands that it is using version 1.0. Flash Builder does not, so it must be included, and I am unsure how Flash Develop works. However, it's generally a good idea to get used to including it, so when it is required - it's there. This will also allow greater modularity, reuse of your code, and improve it's readability.
DOCTYPE does not need to be declared, using that calls for specific mx libraries, and usually pertains to programming in Microsoft or Air/Flex platforms. You probably won't require it if using it for simple storage.