I’m populating dynamic text fields within (timeline) animated movieclips. For some reason, this only works with the first movieclip even though the rest are formatted identically. I’m getting no errors.
I can load other nodes into this MC so I think the XML and the code targeting the nodes seems fine (tracing the node values works as well).
The problem seems to be with the target movieclips, however I cannot find any differences in their settings compared to the one that is working. AS and XML below:
function loadXML(loaded) {
if (loaded) {
var format1:TextFormat = new TextFormat();
format1.letterSpacing = -4;
var format2:TextFormat = new TextFormat();
format2.letterSpacing = -1;
format2.leading =-15;
_root.hdeal_right1.hdr1_price.text = this.firstChild.childNodes[1].childNodes[0].firstChild.nodeValue;
_root.hdeal_right1.hdr1_offer.text = this.firstChild.childNodes[1].childNodes[1].firstChild.nodeValue;
_root.hdeal_left1.hdl1_price.text = this.firstChild.childNodes[0].childNodes[0].firstChild.nodeValue;
_root.hdeal_left1.hdl1_offer.text = this.firstChild.childNodes[0].childNodes[1].firstChild.nodeValue;
_root.hdeal_right2.hdr2_price.text = this.firstChild.childNodes[2].childNodes[0].firstChild.nodeValue;
_root.hdeal_right2.hdr2_offer.text = this.firstChild.childNodes[2].childNodes[1].firstChild.nodeValue;
_root.hdeal_right1.hdr1_price.setTextFormat(format1);
_root.hdeal_right1.hdr1_offer.setTextFormat(format2);
_root.hdeal_left1.hdl1_price.setTextFormat(format1);
_root.hdeal_left1.hdl1_offer.setTextFormat(format2);
_root.hdeal_right2.hdr2_price.setTextFormat(format1);
_root.hdeal_right2.hdr2_offer.setTextFormat(format2);
} else {
trace("XML file not found");
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("deals.xml");
And the XML:
<?xml version="1.0" encoding="iso-8859-1"?>
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<deals>
<deal>
<price>from £295</price>
<offer>sample text for deal 1</offer>
<link>link url</link>
</deal>
<deal>
<price>from £5</price>
<offer>sample text for deal 2</offer>
<link>link url</link>
</deal>
<deal>
<price>from £5</price>
<offer>sample text for deal 3</offer>
<link>link url</link>
</deal>
</deals>
I have attached the FLA and XML for reference, version CS4.
I’ve been scratching my head for a couple of hours now so any help would be greatly appreciated!