Wolfpack'08
Wolfpack'08

Reputation: 4128

How to create a translations library of Flash symbols for action script from an XML file?

I have a list of 700 words that I would like to convert to symbols in Flash for a flash card game. I'm trying to make a game where a random symbol from a slice of the array of symbols will come into game play until the user performs an action.

Basically, I'm wondering how I can create an arrayed/indexed library of symbols from a dictionary, for a downloadable Flash game. Does anyone know how I could start to script this? Also, if I want to pair a 'word symbol' with its translation, do I need to use a database? Obviously, because it's a flash-card type game I'm working on, the translated symbol is just as valuable as the original-language symbol.

Upvotes: 0

Views: 192

Answers (1)

pho
pho

Reputation: 25489

Taking forward Lars's comment,

You first create a generic flashcard symbol. This should have a dynamic textfield in it. Then, on loading the swf, you load the xml (or the csv) containing the words, parse it and load the words into an array. Next, you generate a random number and select that index of the array to display in the textfield.

Code and screenshots coming soon... :)

EDIT

Creating the symbol

The source files are here

EDIT 2

Do you know how to parse XML? I have written this class which I use for converting an XML into an Object. You can get the swc from here

You just need to read in the xml file, and then run

var obj:Object=XMLUtilities.XMLStringToObject(string)

This will return an object of the xml For example, suppose your xml is

<words>
    <x id="1"><english>ball</english><spanish>pelota</spanish></x>
    <x id="2"><english>cat</english><spanish>gato</spanish></x>
</words>

The value of obj will be

obj=>words=>x:Array So you can access each x tag as

obj.words.x[index]

and, then you have x.id=1; x.english="ball"; x.spanish="pelota" and so on.

So, in that case, the word selection code would be a little different. I've uploaded all files here

Upvotes: 1

Related Questions