I am new to XML and am having a small problem in Flash. I have a number of buttons. Each of these buttons need to open up a different URL which is in a xml file (I have added only one button for now (banstead), as I wasn´t sure how to add more).
My XML:
<?xml version="1.0" encoding="utf-8"?>
<banstead targ="_self" href="http://www.marca.com"> </banstead>
My AS:
weblinkXML = new XML();
weblinkXML.ignoreWhite = true;
weblinkXML.load("xml/counties.xml");
weblinkXML.onLoad = function (success)
{
var url = weblinkXML.firstChild.attributes.href;
banstead.onRelease = function ()
{
getURL(weblinkXML.url);
}
}
For some reason when I test the movie and click on the button it doesn´t open the URL I requested.
Appreciate any help
You’ve defined the variable
url, but then called a different (undefined) variableweblinkXML.urlin your getURL call.Try this instead:
To add more buttons, you might try changing your XML file to look more like this:
Then make a loop which goes through the XML and makes a button for each item it finds:
I have made some assumptions about how your project is set up… but I’ve tested it and it seems to work for me
Let me know how you get on (and don’t forget to click the big tick mark to accept this answer if it has helped you – thanks).