PDA

View Full Version : how to define object


Suspiria
02-28-2006, 11:08 PM
Right,

Well the situation is I have a container swf, that calls a second swf movie. This swf parses an xml array etc etc. It works fine on its own, but when called from the container swf it stops processing (tracing stops after "1") .

I think i know what the problem is in that i'm using _root, but I'm not sure what to change it to in the below code.

//load xml doc
_root.site = "http://localhost/webdev/samppa/";
if (path ==undefined) {
path = _root.site + "galllist.php";
}else{
path = ""+_root.site +_root.currentscreen+"";
}
trace(path);
objXML = new XML();
objXML.onLoad = loadXML;
objXML.ignoreWhite = true;
objXML.sendAndLoad(path, objXML, "POST");
//trace(objXML);
titleArray = [];
linksArray = [];
descriptionsArray = [];
nameArray = [];
morelinks._visible = 0;
//onLoad XML function
function loadXML(success) {
if (success) {
_root.linkCount = this.firstChild.childNodes.length;
_root.pushArray();
trace("1");
} else {
//
}
}
function pushArray() {
trace("2");
for (var count = 0; count<_root.linkCount; count++) {
var nodeObj = objXML.firstChild.childNodes[count];
_root.titlesArray[count] = nodeObj.attributes.title;
_root.descriptionsArray[count] = nodeObj.attributes.description;
_root.linksArray[count] = nodeObj.attributes.link;
_root.nameArray[count] = nodeObj.attributes.name;
trace("array" + count);
}
createButtons();
trace("3");
}
function removeClips() {
if (_root.linkCount>0) {
for (count=0; count<_root.linkCount; count++) {
_root["links"+count].removeMovieClip();
}
}
}
function createButtons() {
removeClips();
pageNumber[currentPage] = startPos;
xPos = random(40)+80;
yPos = 30;
//main function bit
for (count=startPos; count<_root.linkCount; count++) {
_root.attachMovie("links", "links"+count, count);
//_root.duplicateMovieClip(_root.pages["links"], "links"+count, count);
//adjsut *9 to fit font
_root["links"+count]._width = nameArray[count].length*60;
_root["links"+count]._x = xPos;
_root["links"+count]._y = yPos+random(10);
_root["links"+count].text = nameArray[count];
//set the position of xPos ready for next button
xPos = xPos+_root["links"+count]._width+40;
//move row down if xPos plus the next button width is over 450
if (xPos+(nameArray[count+1].length*60)>600) {
yPos = yPos+50+random(10);
//check to see if next row will fit on stage
if (yPos>maxY) {
//set the start position of the next links
startPos = count+1;
//make button visible
morelinks._visible = 1;
//break out of loop if needs new row
break;
}
//if moving down a row reset xPos to the left
xPos = random(20)+60*Math.random();
}
}
}
startPos = 0;
maxY = 300;
pageNumber = new Array();
currentPage = 0;

any pointers be great

spaace
03-07-2006, 12:46 AM
I had a similar problem due to the code executing before the child swf was loaded completely. You could try using a loader for the child swf, it seemed to fix the problem i was seeing.

Hope that helps!