Hi
I want to start by saying that my AS-skills are pretty limited, because I am new to the subject, so please bear with me
After having seen through this tutorial
http://www.kirupa.com/developer/flashcs3/using_xml_as3_pg6.htm I got help from a nice person to get a code, that would load my XML data into my SWF, after pressing a button. He even made an explanation for me through the code:
// this objects loads the xml file
var xmlLoader:URLLoader = new URLLoader();
// this will be your xml data once loaded, now its empty
var xmlData:XML;
// my_button is the instance name of the button on the stage
my_button.addEventListener( MouseEvent.CLICK, onClickFunction );
// hey, someone pressed the button, lets do something
function onClickFunction( a_event:MouseEvent ):void
{
// we want to know when its loaded, so we can do stuff with it
xmlLoader.addEventListener(Event.COMPLETE, onXMLLoaded);
// we want to load the xml
xmlLoader.load(new URLRequest("tracks.xml"));
}
// the xml is loaded so lets do what this function says
function onXMLLoaded( a_event:Event ):void
{
// you remember? the xml data object created before? now it gets content
xmlData = new XML( xmlLoader.data );
trace("horray, the xml is here" );
trace( xmlData );
}
And and Content of my XML data is following so far:
I would like to make a button in Flash that reads the XML file, and when pressed, it shows the track Title, corresponding to the Genre or the Mood, specified in the XML file.
For instance: The buttons name is Aggressive and when I press it, all the tracks that have “Aggressive” as the Mood (in the XML file), will be called forth.
How do I do that?
Here are the files for the project: http://www.toonhaze.com/project.rar
…
…