|
-
[F8] XML and MovieClips
Am I missing something here, basically the app loads three random images and a related caption from an XML.. the image across the page, when clicked the image expands and fades displaying a caption behind. The code works but every once and a while it breaks not simply switching the movie to the text without any animation, i've tried tracing all the variables but can't see whats causing it:
http://www.roptix.co.uk/test/test3.swf - what i've got, click the images a for a while and eventually one will not work properly, but then some still will.
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()
}
}
Apologise for the messiness of code, i am relatively new if anyone can offer an obvious improvements i'd appreciate it, but why is that working most the time but then on the odd occasion not?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|