Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 02-11-2004, 06:10 AM   #1
theMonitor
Member
 
Join Date: Mar 2003
Posts: 62
Default problem applying stylesheet in MX

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 ¬
theMonitor is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:45 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.