PDA

Click to See Complete Forum and Search --> : Movie with XML content loading into another movie clip



befidled
06-05-2001, 06:32 PM
a few posts ago I posted my dilemma, here is my code.

The main problem I run into is that my while this Flash movie works on its own, it doesn't work when imported into a movieclip on my main movie. I've provided code for both the XML and for the Flash movie that I'm having trouble with...please forgive some of the code...I'm a designer :0)

XML CODE:

<al_press>

<Press>
<Date>01-22-01</Date>
<Title>This will be the title of article one</Title>
<DescriptionURL>Article1.txt</DescriptionURL>
</Press>

<Press>
<Date>01-22-01</Date>
<Title>This is the title for article 2</Title>
<DescriptionURL>Article2.txt</DescriptionURL>
</Press>

<Press>
<Date>02-21-01</Date>
<Title>This is the title for article 3</Title>
<DescriptionURL>Article3.txt</DescriptionURL>
</Press>

</al_press>


ACTIONSCRIPT:

// Declare Catalog XML object, and load data file
myDoc = new XML();
myDoc.onLoad = handleLoad;
myDoc.load("al_pressReports2.xml");
// function handleLoad will preload the XML source code
// prior to any other events can take place
function handleLoad (success) {
if (success) {
output = "Product information received";
displayProduct();
// Call custom display function
} else {
output = "Attempt to load XML data failed";
displayError();
// Call custom display function
}
stripWhitespaceDoublePass(myDoc);
buildMenu(myDoc);
organizeMenuCalc(myDoc);
_root.movement_limit = _root.myDoc.childNodes[0].childNodes.Length-3;
trace (_root.menuBuild._height);

trace ("Menu0 has an x value of "+_root.gMenuBuild._X);
trace ("Menu0 has an y value of "+_root.menuBuild.menu0._y);

trace (myDoc.childNodes[0].childNodes[0].childNodes[0].childNodes[0].nodeValue);
trace (myDoc.childNodes[0].childNodes[0].childNodes[1].childNodes[0].nodeValue);
trace (myDoc.childNodes[0].childNodes[0].childNodes[2].childNodes[0].nodeValue);
}
// Strip whitespace using function recursion
// Strips whitespace nodes from an xml document
// by passing twice through each level in the tree
function stripWhitespaceDoublePass (myDoc) {
// Loop through all the children of myDoc
for (var i = 0; i<myDoc.childNodes.Length; i++) {
// If the current node is a text node...
if (myDoc.childNodes.nodeType == 3) {
// ...check for any useful characters in the node
var j = 0;
var emptyNode = true;
for (j=0; j<myDoc.childNodes.nodeValue.length; j++) {
// A useful character is anything over 32 (space, tab,
// new line, etc. are all below)
if (myDoc.childNodes.nodeValue.charCodeAt(j)>32) {
emptyNode = false;
break;
}
}
// If no useful characters were found, delete the node
if (emptyNode) {
myDoc.childNodes.removeNode();
}
}
}
// Now that all the whitespace nodes have been removed from myDoc,
// call stripWhitespaceDoublePass() recursively on its remaining children.
for (var k = 0; k<myDoc.childNodes.length; k++) {
stripWhitespaceDoublePass(myDoc.childNodes[k]);
}
}

// Build Menu w/rollover capabilities
function buildMenu (myDoc) {
// var myMenu = new Array ();
// Here I already know which Childnodes are populated
// with the content that I want. So I begin by counting
// the number of childNodes(for date) there are and assigning
// a respective menu # for each one. Then duplicate the existing movieclip
// on the stage so that the # of movieclip menus == the number of elements in the XML.
l = myDoc.childNodes[0].childNodes.Length;
for (var m = 0; m<l; m++) {
lvl = lvl+1;
// Create Menu item for each instance of childNode "Press"
menuBuild.menuitem.duplicateMovieClip("menu"+[m], lvl);
trace ("just created menu"+m);
// Set up the positioning of the menu items
}
}
// function organize menu
function organizeMenuCalc () {
i = 10;
horiz_loc = 15;
vert_loc = 15;
menuBuild.menu0._x = horiz_loc;
menuBuild.menu0._y = vert_loc;
menuBuild.menu0.date.date = (myDoc.childNodes[0].childNodes[0].childNodes[0].childNodes[0].nodeValue);
menuBuild.menu0.title.title = (myDoc.childNodes[0].childNodes[0].childNodes[1].childNodes[0].nodeValue);
menuBuild.menu1._x = horiz_loc;
menuBuild.menu1._y = (menuBuild.menu0._y+menuBuild.menu0._height+i);
menuBuild.menu1.date.date = (myDoc.childNodes[0].childNodes[1].childNodes[0].childNodes[0].nodeValue);
menuBuild.menu1.title.title = (myDoc.childNodes[0].childNodes[1].childNodes[1].childNodes[0].nodeValue);
menuBuild.menu2._x = horiz_loc;
menuBuild.menu2._y = (menuBuild.menu1._y+menuBuild.menu1._height+i);
menuBuild.menu2.date.date = (myDoc.childNodes[0].childNodes[2].childNodes[0].childNodes[0].nodeValue);
menuBuild.menu2.title.title = (myDoc.childNodes[0].childNodes[2].childNodes[1].childNodes[0].nodeValue);
menuBuild.menu3._x = horiz_loc;
menuBuild.menu3._y = (menuBuild.menu2._y+menuBuild.menu2._height+i);
menuBuild.menu3.date.date = (myDoc.childNodes[0].childNodes[3].childNodes[0].childNodes[0].nodeValue);
menuBuild.menu3.title.title = (myDoc.childNodes[0].childNodes[3].childNodes[1].childNodes[0].nodeValue);
menuBuild.menu4._x = horiz_loc;
menuBuild.menu4._y = (menuBuild.menu3._y+menuBuild.menu3._height+i);
menuBuild.menu4.date.date = (myDoc.childNodes[0].childNodes[4].childNodes[0].childNodes[0].nodeValue);
menuBuild.menu4.title.title = (myDoc.childNodes[0].childNodes[4].childNodes[1].childNodes[0].nodeValue);
menuBuild.menu5._x = horiz_loc;
menuBuild.menu5._y = (menuBuild.menu4._y+menuBuild.menu4._height+i);
menuBuild.menu5.date.date = (myDoc.childNodes[0].childNodes[5].childNodes[0].childNodes[0].nodeValue);
menuBuild.menu5.title.title = (myDoc.childNodes[0].childNodes[5].childNodes[1].childNodes[0].nodeValue);
menuBuild.menu6._x = horiz_loc;
menuBuild.menu6._y = (menuBuild.menu5._y+menuBuild.menu5._height+i);
menuBuild.menu6.date.date = (myDoc.childNodes[0].childNodes[6].childNodes[0].childNodes[0].nodeValue);
menuBuild.menu6.title.title = (myDoc.childNodes[0].childNodes[6].childNodes[1].childNodes[0].nodeValue);
menuBuild.menu7._x = horiz_loc;
menuBuild.menu7._y = (menuBuild.menu6._y+menuBuild.menu6._height+i);
menuBuild.menu7.date.date = (myDoc.childNodes[0].childNodes[7].childNodes[0].childNodes[0].nodeValue);
menuBuild.menu7.title.title = (myDoc.childNodes[0].childNodes[7].childNodes[1].childNodes[0].nodeValue);
menuBuild.menu8._x = horiz_loc;
menuBuild.menu8._y = (menuBuild.menu7._y+menuBuild.menu7._height+i);
menuBuild.menu8.date.date = (myDoc.childNodes[0].childNodes[8].childNodes[0].childNodes[0].nodeValue);
menuBuild.menu8.title.title = (myDoc.childNodes[0].childNodes[8].childNodes[1].childNodes[0].nodeValue);
menuBuild.menu9._x = horiz_loc;
menuBuild.menu9._y = (menuBuild.menu8._y+menuBuild.menu8._height+i);
menuBuild.menu9.date.date = (myDoc.childNodes[0].childNodes[9].childNodes[0].childNodes[0].nodeValue);
menuBuild.menu9.title.title = (myDoc.childNodes[0].childNodes[9].childNodes[1].childNodes[0].nodeValue);
menuBuild.menu10._x = horiz_loc;
menuBuild.menu10._y = (menuBuild.menu9._y+menuBuild.menu9._height+i);
menuBuild.menu10.date.date = (myDoc.childNodes[0].childNodes[10].childNodes[0].childNodes[0].nodeValue);
menuBuild.menu10.title.title = (myDoc.childNodes[0].childNodes[10].childNodes[1].childNodes[0].nodeValue);
menuBuild.menu11._x = horiz_loc;
menuBuild.menu11._y = (menuBuild.menu10._y+menuBuild.menu10._height+i);
menuBuild.menu11.date.date = (myDoc.childNodes[0].childNodes[11].childNodes[0].childNodes[0].nodeValue);
menuBuild.menu11.title.title = (myDoc.childNodes[0].childNodes[11].childNodes[1].childNodes[0].nodeValue);
menuBuild.menu12._x = horiz_loc;
menuBuild.menu12._y = (menuBuild.menu11._y+menuBuild.menu11._height+i);
menuBuild.menu12.date.date = (myDoc.childNodes[0].childNodes[12].childNodes[0].childNodes[0].nodeValue);
menuBuild.menu12.title.title = (myDoc.childNodes[0].childNodes[12].childNodes[1].childNodes[0].nodeValue);
menuBuild.menu13._x = horiz_loc;
menuBuild.menu13._y = (menuBuild.menu12._y+menuBuild.menu12._height+i);
menuBuild.menu13.date.date = (myDoc.childNodes[0].childNodes[13].childNodes[0].childNodes[0].nodeValue);
menuBuild.menu13.title.title = (myDoc.childNodes[0].childNodes[13].childNodes[1].childNodes[0].nodeValue);
menuBuild.menu14._x = horiz_loc;
menuBuild.menu14._y = (menuBuild.menu13._y+menuBuild.menu13._height+i);
menuBuild.menu14.date.date = (myDoc.childNodes[0].childNodes[14].childNodes[0].childNodes[0].nodeValue);
menuBuild.menu14.title.title = (myDoc.childNodes[0].childNodes[14].childNodes[1].childNodes[0].nodeValue);
menuBuild.menu15._x = horiz_loc;
menuBuild.menu15._y = (menuBuild.menu14._y+menuBuild.menu14._height+i);
menuBuild.menu15.date.date = (myDoc.childNodes[0].childNodes[15].childNodes[0].childNodes[0].nodeValue);
menuBuild.menu15.title.title = (myDoc.childNodes[0].childNodes[15].childNodes[1].childNodes[0].nodeValue);
menuBuild.menu16._x = horiz_loc;
menuBuild.menu16._y = (menuBuild.menu15._y+menuBuild.menu15._height+i);
menuBuild.menu16.date.date = (myDoc.childNodes[0].childNodes[16].childNodes[0].childNodes[0].nodeValue);
menuBuild.menu16.title.title = (myDoc.childNodes[0].childNodes[16].childNodes[1].childNodes[0].nodeValue);
menuBuild.menu17._x = horiz_loc;
menuBuild.menu17._y = (menuBuild.menu16._y+menuBuild.menu16._height+i);
menuBuild.menu17.date.date = (myDoc.childNodes[0].childNodes[17].childNodes[0].childNodes[0].nodeValue);
menuBuild.menu17.title.title = (myDoc.childNodes[0].childNodes[17].childNodes[1].childNodes[0].nodeValue);
menuBuild.menu18._x = horiz_loc;
menuBuild.menu18._y = (menuBuild.menu17._y+menuBuild.menu17._height+i);
menuBuild.menu18.date.date = (myDoc.childNodes[0].childNodes[18].childNodes[0].childNodes[0].nodeValue);
menuBuild.menu18.title.title = (myDoc.childNodes[0].childNodes[18].childNodes[1].childNodes[0].nodeValue);
menuBuild.menu19._x = horiz_loc;
menuBuild.menu19._y = (menuBuild.menu18._y+menuBuild.menu18._height+i);
menuBuild.menu19.date.date = (myDoc.childNodes[0].childNodes[19].childNodes[0].childNodes[0].nodeValue);
menuBuild.menu19.title.title = (myDoc.childNodes[0].childNodes[19].childNodes[1].childNodes[0].nodeValue);
menuBuild.menu20._x = horiz_loc;
menuBuild.menu20._y = (menuBuild.menu19._y+menuBuild.menu19._height+i);
menuBuild.menu20.date.date = (myDoc.childNodes[0].childNodes[20].childNodes[0].childNodes[0].nodeValue);
menuBuild.menu20.title.title = (myDoc.childNodes[0].childNodes[20].childNodes[1].childNodes[0].nodeValue);
menuBuild.menu21._x = horiz_loc;
menuBuild.menu21._y = (menuBuild.menu20._y+menuBuild.menu20._height+i);
menuBuild.menu21.date.date = (myDoc.childNodes[0].childNodes[21].childNodes[0].childNodes[0].nodeValue);
menuBuild.menu21.title.title = (myDoc.childNodes[0].childNodes[21].childNodes[1].childNodes[0].nodeValue);
menuBuild.menu22._x = horiz_loc;
menuBuild.menu22._y = (menuBuild.menu21._y+menuBuild.menu21._height+i);
menuBuild.menu22.date.date = (myDoc.childNodes[0].childNodes[22].childNodes[0].childNodes[0].nodeValue);
menuBuild.menu22.title.title = (myDoc.childNodes[0].childNodes[22].childNodes[1].childNodes[0].nodeValue);
menuBuild.menu23._x = horiz_loc;
menuBuild.menu23._y = (menuBuild.menu22._y+menuBuild.menu22._height+i);
menuBuild.menu23.date.date = (myDoc.childNodes[0].childNodes[23].childNodes[0].childNodes[0].nodeValue);
menuBuild.menu23.title.title = (myDoc.childNodes[0].childNodes[23].childNodes[1].childNodes[0].nodeValue);
menuBuild.menu24._x = horiz_loc;
menuBuild.menu24._y = (menuBuild.menu23._y+menuBuild.menu23._height+i);
menuBuild.menu24.date.date = (myDoc.childNodes[0].childNodes[24].childNodes[0].childNodes[0].nodeValue);
menuBuild.menu24.title.title = (myDoc.childNodes[0].childNodes[24].childNodes[1].childNodes[0].nodeValue);
menuBuild.menu25._x = horiz_loc;
menuBuild.menu25._y = (menuBuild.menu24._y+menuBuild.menu24._height+i);
menuBuild.menu25.date.date = (myDoc.childNodes[0].childNodes[25].childNodes[0].childNodes[0].nodeValue);
menuBuild.menu25.title.title = (myDoc.childNodes[0].childNodes[25].childNodes[1].childNodes[0].nodeValue);
menuBuild.menu26._x = horiz_loc;
menuBuild.menu26._y = (menuBuild.menu25._y+menuBuild.menu25._height+i);
menuBuild.menu26.date.date = (myDoc.childNodes[0].childNodes[26].childNodes[0].childNodes[0].nodeValue);
menuBuild.menu26.title.title = (myDoc.childNodes[0].childNodes[26].childNodes[1].childNodes[0].nodeValue);
menuBuild.menu27._x = horiz_loc;
menuBuild.menu27._y = (menuBuild.menu26._y+menuBuild.menu26._height+i);
menuBuild.menu27.date.date = (myDoc.childNodes[0].childNodes[27].childNodes[0].childNodes[0].nodeValue);
menuBuild.menu27.title.title = (myDoc.childNodes[0].childNodes[27].childNodes[1].childNodes[0].nodeValue);
menuBuild.menu28._x = horiz_loc;
menuBuild.menu28._y = (menuBuild.menu27._y+menuBuild.menu27._height+i);
menuBuild.menu28.date.date = (myDoc.childNodes[0].childNodes[28].childNodes[0].childNodes[0].nodeValue);
menuBuild.menu28.title.title = (myDoc.childNodes[0].childNodes[28].childNodes[1].childNodes[0].nodeValue);
menuBuild.menu29._x = horiz_loc;
menuBuild.menu29._y = (menuBuild.menu28._y+menuBuild.menu28._height+i);
menuBuild.menu29.date.date = (myDoc.childNodes[0].childNodes[29].childNodes[0].childNodes[0].nodeValue);
menuBuild.menu29.title.title = (myDoc.childNodes[0].childNodes[29].childNodes[1].childNodes[0].nodeValue);
menuBuild.menu30._x = horiz_loc;
menuBuild.menu30._y = (menuBuild.menu29._y+menuBuild.menu29._height+i);
menuBuild.menu30.date.date = (myDoc.childNodes[0].childNodes[30].childNodes[0].childNodes[0].nodeValue);
menuBuild.menu30.title.title = (myDoc.childNodes[0].childNodes[30].childNodes[1].childNodes[0].nodeValue);
}

function movementLimitTest () {
if (_root.movement_limit<=0) {
break;
} else {
setProperty ("menuBuild", _y, _root.vertical_move-14);
_root.movement_limit = _root.movement_limit-(1/4);
break;
}
}
function movementLimitTest2 () {
if (_root.movement_limit>=_root.lvl-3) {
break;
} else {
setProperty ("menuBuild", _y, _root.vertical_move+14);
_root.movement_limit = _root.movement_limit+(1/4);
break;
}
}
// function to test which r/o is currently on.
// By testing this I can set the content of Press Release to the appropriate information
function testWhichRollover () {
myPressRelease = "";
if (menuBuild.menu0.buttonState == "on") {
myPressRelease = (myDoc.childNodes[0].childNodes[0].childNodes[2].childNodes[0].nodeValue);

} else if (menuBuild.menu1.buttonState == "on") {
myPressRelease = (myDoc.childNodes[0].childNodes[1].childNodes[2].childNodes[0].nodeValue);

} else if (menuBuild.menu2.buttonState == "on") {
myPressRelease = (myDoc.childNodes[0].childNodes[2].childNodes[2].childNodes[0].nodeValue);

} else if (menuBuild.menu3.buttonState == "on") {
myPressRelease = (myDoc.childNodes[0].childNodes[3].childNodes[2].childNodes[0].nodeValue);

} else if (menuBuild.menu4.buttonState == "on") {
myPressRelease = (myDoc.childNodes[0].childNodes[4].childNodes[2].childNodes[0].nodeValue);

} else if (menuBuild.menu5.buttonState == "on") {
myPressRelease = (myDoc.childNodes[0].childNodes[5].childNodes[2].childNodes[0].nodeValue);

} else if (menuBuild.menu6.buttonState == "on") {
myPressRelease = (myDoc.childNodes[0].childNodes[6].childNodes[2].childNodes[0].nodeValue);

} else if (menuBuild.menu7.buttonState == "on") {
myPressRelease = (myDoc.childNodes[0].childNodes[7].childNodes[2].childNodes[0].nodeValue);

} else if (menuBuild.menu8.buttonState == "on") {
myPressRelease = (myDoc.childNodes[0].childNodes[8].childNodes[2].childNodes[0].nodeValue);

} else if (menuBuild.menu9.buttonState == "on") {
myPressRelease = (myDoc.childNodes[0].childNodes[9].childNodes[2].childNodes[0].nodeValue);

} else if (menuBuild.menu10.buttonState == "on") {
myPressRelease = (myDoc.childNodes[0].childNodes[10].childNodes[2].childNodes[0].nodeValue);

} else if (menuBuild.menu11.buttonState == "on") {
myPressRelease = (myDoc.childNodes[0].childNodes[11].childNodes[2].childNodes[0].nodeValue);

} else if (menuBuild.menu12.buttonState == "on") {
myPressRelease = (myDoc.childNodes[0].childNodes[12].childNodes[2].childNodes[0].nodeValue);

} else if (menuBuild.menu13.buttonState == "on") {
myPressRelease = (myDoc.childNodes[0].childNodes[13].childNodes[2].childNodes[0].nodeValue);

} else if (menuBuild.menu14.buttonState == "on") {
myPressRelease = (myDoc.childNodes[0].childNodes[14].childNodes[2].childNodes[0].nodeValue);

} else if (menuBuild.menu15.buttonState == "on") {
myPressRelease = (myDoc.childNodes[0].childNodes[15].childNodes[2].childNodes[0].nodeValue);

} else if (menuBuild.menu16.buttonState == "on") {
myPressRelease = (myDoc.childNodes[0].childNodes[16].childNodes[2].childNodes[0].nodeValue);

} else if (menuBuild.menu17.buttonState == "on") {
myPressRelease = (myDoc.childNodes[0].childNodes[17].childNodes[2].childNodes[0].nodeValue);

} else if (menuBuild.menu18.buttonState == "on") {
myPressRelease = (myDoc.childNodes[0].childNodes[18].childNodes[2].childNodes[0].nodeValue);

} else if (menuBuild.menu19.buttonState == "on") {
myPressRelease = (myDoc.childNodes[0].childNodes[19].childNodes[2].childNodes[0].nodeValue);

} else if (menuBuild.menu20.buttonState == "on") {
myPressRelease = (myDoc.childNodes[0].childNodes[20].childNodes[2].childNodes[0].nodeValue);

} else if (menuBuild.menu21.buttonState == "on") {
myPressRelease = (myDoc.childNodes[0].childNodes[21].childNodes[2].childNodes[0].nodeValue);

} else if (menuBuild.menu22.buttonState == "on") {
myPressRelease = (myDoc.childNodes[0].childNodes[22].childNodes[2].childNodes[0].nodeValue);

} else if (menuBuild.menu23.buttonState == "on") {
myPressRelease = (myDoc.childNodes[0].childNodes[23].childNodes[2].childNodes[0].nodeValue);

} else if (menuBuild.menu24.buttonState == "on") {
myPressRelease = (myDoc.childNodes[0].childNodes[24].childNodes[2].childNodes[0].nodeValue);

} else if (menuBuild.menu25.buttonState == "on") {
myPressRelease = (myDoc.childNodes[0].childNodes[25].childNodes[2].childNodes[0].nodeValue);

} else if (menuBuild.menu26.buttonState == "on") {
myPressRelease = (myDoc.childNodes[0].childNodes[26].childNodes[2].childNodes[0].nodeValue);

} else if (menuBuild.menu27.buttonState == "on") {
myPressRelease = (myDoc.childNodes[0].childNodes[27].childNodes[2].childNodes[0].nodeValue);

} else if (menuBuild.menu28.buttonState == "on") {
myPressRelease = (myDoc.childNodes[0].childNodes[28].childNodes[2].childNodes[0].nodeValue);

} else if (menuBuild.menu29.buttonState == "on") {
myPressRelease = (myDoc.childNodes[0].childNodes[29].childNodes[2].childNodes[0].nodeValue);

} else if (menuBuild.menu30.buttonState == "on") {
myPressRelease = (myDoc.childNodes[0].childNodes[30].childNodes[2].childNodes[0].nodeValue);
}
}

befidled
06-05-2001, 06:35 PM
//XML CODE: (pretend that [ = < and ] = > )




01-22-01
This will be the title of article one
Article1.txt



01-22-01
This is the title for article 2
Article2.txt



02-21-01
This is the title for article 3
Article3.txt



[Edited by befidled on 06-05-2001 at 06:41 PM]