[RESOLVED] AS 2.0 xml news ticker - scripting problem
Hi there!
I'm making a very simple news ticker that uses XML to load four items: copy text, an image, date and a URL. The script was pieced together from tutorials and a bit of self-teaching, so I know it's probably not great. The AS is pasted below. Everything loads just fine, but the button script returns an "undefined" error. I assume this is because the item is no longer found in the array, but I'm not entirely sure. I also think it may be that the loadMovie method isn't working well with a specific item in the array. Also the link does not work. Any ideas?
*Note* I know there are probably more advanced ways to tackle this but I'd like to keep this at my learning level so I can grow with it. :-) Thanks in advance for any advice!
AS2:
Actionscript Code:
function loadXML(loaded){ if(loaded){ xmlNode = this.firstChild; pic = []; date = []; copy = []; link = []; total = xmlNode.childNodes.length; for(i=0; i<total; i++){ pic[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue; date[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue; copy[i] = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue; link[i] = xmlNode.childNodes[i].childNodes[3].firstChild.nodeValue;
} first_item(); }else{ content = "file not loaded!"; } }
<item>
<pic>images/img1.jpg</pic>
<date>2 . 26 . 2010</date>
<copy>This will be our first news item. Hopefully we'll be able to have enough "featured" items to keep a consistent line of news. Updated items are important.</copy>
<link>http://www.google.com</link>
</item>
</news>
Sorry this took a little while; I was having problems logging into my account. I've attached the .fla file below but couldn't upload the XML. Thank you for any help you can provide!!
Thank you - for the solution and the code clean-up! This makes much more sense, and I see how I was being redundant by repeating the rollover function for each button's code. I can also see how the order of operations in the timer function (along with the heavy button code) was causing the problem. You've been a great help! Many thanks!