Log in

View Full Version : XML events with blurb help



nate51
02-03-2009, 03:44 PM
I got some help way back when from Medyman in regards to XML and events with an image and blurb. The AS is clean, simple and perfect for the situation. The only problem I am having right now is the menu the AS builds from the XML, builds itself, with no real variables to help it blend (i.e. fonts style, colour and positioning.

I tried to move the MC from the library onto the stage and position it and assign font styles and it still builds in the top left corner. The AS is below, I just need help figuring out how to assign the menu to a MC so I can do all the above things mentioned.....


var xml:XML = new XML();
xml.ignoreWhite = true;

// Variables
var Images;
var Events;
var current:Number = 0;

xml.onLoad = function(success) {
Images = xml.firstChild.childNodes
Events = xml.firstChild.childNodes
buildNavigation();
}

function buildNavigation() {
for(i=0;i<Images.length;i++) {
var item:MovieClip = this.attachMovie("menu_item", "menu_item_"+i, i);
item._y = i*24;
item.id = i;
item.title_text.text = Images[i].childNodes[0].firstChild
item.onRelease = function() { showImage(this.id); }
item.onRollOver = over;
item.onRollOut = out;
}
}

function showImage(node) {
image_holder.loadMovie(Images[node].childNodes[1].firstChild);
event_caption.text = Events[node].childNodes[2].firstChild
}

xml.load("events.xml");

Any help would be great as I am drawing blanks.

nate51
02-04-2009, 06:44 PM
I tried changing the code to this

var xml:XML = new XML();
xml.ignoreWhite = true;

// Variables
var Images;
var Events;
var Navigation;
var current:Number = 0;

xml.onLoad = function(success) {
Images = xml.firstChild.childNodes
Events = xml.firstChild.childNodes
Navigation = xml.firstChild.childNodes
}

function Navigation() {
for(i=0;i<Images.length;i++) {
var item:MovieClip = this.attachMovie("menu_item", "menu_item_"+i, i);
item._y = i*24;
item.id = i;
item.title_text.text = Images[i].childNodes[0].firstChild
item.onRelease = function() { showImage(this.id); }
item.onRollOver = over;
item.onRollOut = out;
}
}

function showImage(node) {
image_holder.loadMovie(Images[node].childNodes[1].firstChild);
event_caption.text = Events[node].childNodes[2].firstChild
menu_item.text = Navigation[node].childNodes[3].firstChild
}

xml.load("events.xml");

And that's not doing the trick. Does anyone have any input on this?