# Need to populate MCs with XML file, then change value every 30 seconds

**URL:** <https://forum.kirupa.com/t/need-to-populate-mcs-with-xml-file-then-change-value-every-30-seconds/168983>\
**Category:** Uncategorized\
**Created:** [November 11, 2005, 9:38pm UTC](https://forum.kirupa.com/t/need-to-populate-mcs-with-xml-file-then-change-value-every-30-seconds/168983 "2005-11-11T21:38:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bchalker](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/bchalker/32/441_2.png) [@bchalker](https://forum.kirupa.com/u/bchalker)\
**Post date:** [November 11, 2005, 9:38pm UTC](https://forum.kirupa.com/t/need-to-populate-mcs-with-xml-file-then-change-value-every-30-seconds/168983/1 "2005-11-11T21:38:50Z")

</div>

XML:  
\<adList\>  
\<ads\>  
\<ad id=“thisNumber0” imageFile=“thisAd.jpg” videoFile=“video.flv” couponImage=“this.bmp”/\>  
\<ad id=“thisNumber1” imageFile=“thisAd.jpg” videoFile=“video.flv” couponImage=“this.bmp”/\>  
\<ad id=“thisNumber2” imageFile=“thisAd.jpg” videoFile=“video.flv” couponImage=“this.bmp”/\>  
…  
\</ads\>  
\</adList\>

There will be 1000-1200 “ads” in the XML file.

What I am needing:  
I have 10 MCs, named adBlock0-adBlock9

I am needing the XML to load and assign the 1st ad to adBlock0, 2nd to adBlock1, and so on (through adBlock9). I then need (after 30 sec.) adBlock0 to go to the next (unassigned) ad, followed by adBlock1 30 sec. later, and so on.

Make sense?

So far I have in my AS:  
contentXML = new XML();  
contentXML.ignoreWhite = true;  
contentXML.onLoad = function(success){if (success){parseThis();trace(“Loaded”);}}  
contentXML.load(“adFile.xml”)

function adCounter(){  
if (currentAd\<adSets.length){  
currentAd++;  
counterNumber.text=currentAd  
} else if (currentAd==adSets.length){  
currentAd=0;  
}  
}

//the following parses the XML and traces what I am needing.  
function parseThis(){  
var adListing = contentXML.firstChild.firstChild;  
var adSets = adListing.childNodes  
for(var i=0;i\<adSets.length;i++){  
currAd=adSets\*;  
trace(currAd.attributes.id)  
}

Problem:  
How do I assign the ads to the adBlock MCs, in the fashion I am needing? Also, setInterval will be needed (I’m assuming) to change the ad every 30 sec., but how would I set this up?

Thanks
