having a problem applying neil webb's excellent tutorial on
Loading External XML formatted Content into Flash MX 2004.
i'm trying to apply the technique to a set of dynamically created textareas. i use createTextField to make five sets of three boxes, and load in xml data for a set of ringtone orders - 5 tones with title, artist and code. i'm trying to apply the stylesheet upon creation of each box. however, when i preview the movie the text isn't formatted according to the stylesheet.
the actionscript:
//load css
toneListStyle = new TextField.StyleSheet();
toneListStyle.load("toneListStyles.css");
//set up arrays
toneTitles = new Array();
toneArtists = new Array();
toneCodes = new Array();
//function to create textfields
function createTextfields () {
for (j=0; j<5; j++) {
_root.createTextField("outputTitle"+j, j, 20, y+(j*20), 200, 30);
_root["outputTitle"+j].html = true;
_root["outputTitle"+j].styleSheet = _root.toneListStyle;
_root.createTextField("outputArtist"+j, j+10, 100, y+(j*20), 200, 30);
_root["outputArtist"+j].html = true;
_root["outputArtist"+j].styleSheet = _root.toneListStyle;
_root.createTextField("outputCode"+j, j+20, 160, y+(j*20), 200, 30);
_root["outputCode"+j].html = true;
_root["outputCode"+j].styleSheet = _root.toneListStyle;
}
}
//what happens to xml when loaded
function sortXml () {
//textfields are actually created
createTextfields();
for (i=1; i<6; i++) {
//extract the data from toneListContent
toneTitles[i] = toneListContent.firstChild.childNodes[i-1].firstChild.firstChild;
toneArtists[i] = toneListContent.firstChild.childNodes[i-1].childNodes[1].firstChild;
toneCodes[i] = toneListContent.firstChild.childNodes[i-1].childNodes[2].firstChild;
_root["outputTitle"+(i-1)].text = toneTitles[i];
_root["outputArtist"+(i-1)].text = toneArtists[i];
_root["outputCode"+(i-1)].text = toneCodes[i];
}
}
//load toneList.xml
toneListContent = new XML();
toneListContent.ignoreWhite = true;
toneListContent.load("toneList.xml");
toneListContent.onLoad = function(success)
{
if(success) {
sortXml();
}
}
the xml:
<toneList>
<tone>
<title>song 1</title>
<artist>artist 1</artist>
<code>xxxx01</code>
</tone>
<tone>
<title>song 2</title>
<artist>artist 2</artist>
<code>xxxx02</code>
</tone>
<tone>
<title>song 3</title>
<artist>artist 3</artist>
<code>xxxx03</code>
</tone>
<tone>
<title>song 4</title>
<artist>artist 4</artist>
<code>xxxx04</code>
</tone>
<tone>
<title>song 5</title>
<artist>artist 5</artist>
<code>xxxx05</code>
</tone>
</toneList>
the stylesheet:
title {
color: #FF0000;
font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
font-size: 18px;
font-weight: bold;
display: inline;
}
artist {
color: #0000FF;
font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
font-size: 10px;
font-weight: normal;
display: inline;
}
code {
color: #00FF00;
font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
font-size: 12px;
font-weight: bold;
display: inline;
}
thanks in advance for any help you are able to give
||| O ^ | + O ¬