I am trying to implement a modification of the squirrel finder xml tutorial here on Kirupa, such that when you click on one of the attached buttons it loads an external .swf file into a container on the root level.
Here’s how I’ve structured the XML.
<item type="unit">
<name>2D</name>
<beds>2</beds>
<baths>2</baths>
<sf>1214sf</sf>
<views>N,W</views>
<flashy>2d.swf</flashy>
</item>
The actions in flash are as follows:
function DisplayInfo(){
container._visible = true;
_root.container.loadMovie(flashy.firstChild.nodeValue);
}
// define basic variables for setting up the menu
var item_spacing = 35; // how far menu items are spaced veritcally
var item_count = 0; // counts menu items as they are added from the XML
// CreateMenu creates a menu based on the XML object passed.
// It loops through all the items with a for loop adding clips to the menu_mc
// movieclip on the timeline, defining the appropriate text where needed
function CreateMenu(menu_xml){
// start with the first item in the XML
var items = menu_xml.firstChild.firstChild.childNodes;// menu -> menuitems -> child nodes array
for (var i=0; i<items.length; i++) {
// only continue if the type of this item is a squirrel
if (items*.attributes.type == “unit”) {
// create variables for our elements
var name = items*.firstChild; // same as items*.childNodes[0]
var beds = items*.childNodes[1];
var baths = items*.childNodes[2];
var sf = items*.childNodes[3];
var views = items*.childNodes[4];
var flashy = items*.childNodes[5];
// Create a menu item movie clip in the menu_mc instance on the main timeline
// for each item element offsetting each additional further down the screen
var item_mc = main_scroller.mytarget.menu_mc.attachMovie("menu_item","item"+item_count, item_count);
item_mc._x = 0;
item_mc._y = item_count * item_spacing;
item_count++;
// assign text using nodeValue to get the text
// from the text nodes and CDATA sections
item_mc.name_text.text = name.firstChild.nodeValue;
item_mc.beds_text.text = beds.firstChild.nodeValue;
item_mc.baths_text.text = baths.firstChild.nodeValue;
item_mc.sf_text.text = sf.firstChild.nodeValue;
item_mc.views_text.text = views.firstChild.nodeValue;
// set the onRelease of the item button to the DisplayInfo function
item_mc.main_btn.onRelease = DisplayInfo;
}
}
}
// manage XML
// create new XML object instance, remembering to ignore white space
var squirrel_xml = new XML();
squirrel_xml.ignoreWhite = true;
// define an onLoad to create our location menu when the XML has successfully loaded.
squirrel_xml.onLoad = function(success){
if (success) CreateMenu(this);
else trace(“Error loading XML file”); // no success? trace error (wont be seen on web)
}
// load the xml file!
squirrel_xml.load(“units_final.xml”);
So all of the buttons will attach fine with all of the pertinant information loading correctly. However, I can’t seem to get the button actually load the external .swf file. Any thoughts on what I might be doing wrong?
Thanks so much!
pooryorick