Hello,
I’m new to the forums but have been a Kirupa fan for a long time. I just completed the tutorial for pulling in dynamic text from an XML file and it’s working great (big accomplishment for an XML/actionscript newbie).
I’m wondering if anyone can point me in the right direction of expanding that same information so that I can 1. load one image as the background (not random, just one entered in the XML file), and 2. assign the link value and target value for a button through the XML file?
Can anyone help start me out in the right direction?
Here’s the code I used in my Flash file:
function loadXML(loaded) {
if (loaded) {
_root.main = this.firstChild.childNodes[0].childNodes[0].firstChild.nodeValue;
_root.title = this.firstChild.childNodes[0].childNodes[1].firstChild.nodeValue;
_root.subtitle = this.firstChild.childNodes[0].childNodes[2].firstChild.nodeValue;
_root.description = this.firstChild.childNodes[0].childNodes[3].firstChild.nodeValue;
_root.date = this.firstChild.childNodes[0].childNodes[4].firstChild.nodeValue;
main_txt.text = _root.main;
title_txt.text = _root.title;
subtitle_txt.text = _root.subtitle;
description_txt.text = _root.description;
date_txt.text = _root.date;
} else {
trace("file not loaded!");
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("externaltext_01.xml");
and here’s the XML file I set up:
<?xml version="1.0" encoding="UTF-8"?>
<main>
<data>
<title><![CDATA[Title Here]]></title>
<subtitle><![CDATA[Subtitle Here]]></subtitle>
<description><![CDATA[This is the description]]></description>
<date><![CDATA[January 11, 1973]]></date>
<image>custom01_02.jpg</image>
</data>
</main>
I’ve tried several ways to get the “image” data to load, but haven’t had any success. And don’t really know how to start with assigning values to a button.
Thanks for any help!