code:
var cnt = 0;
var n = 0;
my_xml = new XML();
my_xml.load("data.xml");
my_xml.onLoad = runthis;
my_xml.ignoreWhite = true;
function SwitchMovie(i, n){
trace(i+"-"+n+"-"+cnt)
_root["container"+n].onPress = function(){}
imagetext = my_xml.childNodes[i].childNodes[1].childNodes[0].nodeValue;
_root["container"+n].createTextField("desc"+i, this.getNextHighestDepth(),-50,100,200,100)
_root["container"+n]["desc"+i].text = imagetext;
myformat = new TextFormat();
myformat.size = 20
myformat.align = "center"
_root["container"+n]["desc"+i].setTextFormat(myformat);
_root["container"+n]["image"+i].onEnterFrame = function(){
_root["container"+n]["image"+i]._alpha-=10
_root["container"+n]["image"+i]._xscale+=10
_root["container"+n]["image"+i]._yscale+=10
_root["container"+n]["desc"+i]._xscale+=20
_root["container"+n]["desc"+i]._yscale+=20
if(_root["container"+n]["image"+i]._alpha < 0)
{
unloadMovie(_root["container"+n])
cnt--
runthis();
}
}
}
function LoadImage(i, n){
imageurl = my_xml.childNodes[i].childNodes[0].childNodes[0].nodeValue;
_root["container"+n]["image" + i].loadMovie(imageurl);
_root["container"+n].onPress = function(){
SwitchMovie(i, n);
}
}
function runthis(){
if(cnt < 3)
{
tspeed=random(10) + 1;
i =random(my_xml.childNodes.length)
_root.createEmptyMovieClip("container"+n, _root.getNextHighestDepth());
_root["container"+n].createEmptyMovieClip("image"+i, this.getNextHighestDepth());
_root["container"+n]._x=-30;
_root["container"+n]._y=random(400);
_root["container"+n]._xscale = 50;
_root["container"+n]._yscale = 50;
_root["container"+n].onEnterFrame = function(){
this._x+=6
if(this._x > 600){
unloadMovie(this)
cnt--
runthis()
}
}
LoadImage(i, n);
n++
cnt++
runthis()
}
}