I am a relative newbie with AS3. I have a client who has an event that they would like to list their sponsors for each year. Each year their list change. I would like to figure out a way to create that list using XML and AS3 and have it animate so that I won’t have to do it by “hand” using the timeline. The list consists of sponsors broken into categories like Gold, Silver and Bronze. I’ve followed the Using XML in Flash CS3/AS3 on this site and I can see the XML data when I trace it. However when I try to get the information to display in a textbox that I create in AS3 it will only display the last entry in the list. What am I doing wrong?
Ideally I would like each item of my list to be in a separate text box so I can animate them individually or in small groups depending on how much text there is in each one. Also I’d like the category to be displayed while the items of that category fade in and out. Structured like this:
The title Group A displays while the individual items names faded in and out. Then Group B’s title displays while the item from Group B fade in and out.
This animation is all text. No images.
Your assistance is greatly appreciated.
here’s the code I have so far. Its messy I know but I’ve been trying different thing to get it to work.
var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();
var goldText = new TextField();
var tfWidth:Number = 430;
var tfX:Number = 200;
xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
xmlLoader.load(new URLRequest(“2009nohs.xml”));
function LoadXML(e:Event):void
{
xmlData = new XML(e.target.data);
ParseGSponsors(xmlData);
}
function ParseGSponsors(sponsorsInput:XML):void
{
trace(“Gold XML Output”);
trace("------------------------");
var goldList:XMLList = sponsorsInput.GoldSponsors.Sponsor;
/*for each (var SponsorElement:XML in goldList)
{
//trace(SponsorElement);
goldText.text = SponsorElement;
trace(goldText.text);
}*/
for (var i:int = 0; i < goldList.length(); i++)
{
var SponsorElement:XML = goldList*;
goldText.text = SponsorElement;
trace(SponsorElement);
}
}
goldText.width = tfWidth;
goldText.x = tfX;
goldText.y = 50;
goldText.multiline = true;
goldText.selectable = false;
addChild(goldText);