the main reason why you’ll find this sounds kind of stupid is because… it is. I’ve looked around for solutions, but I couldn’t find any, mostly because I don’t know what the hell I’m doing wrong.
I’ve got this menu composed of several images loaded dynamically. I’ve written all of it in an onLoad function for conceptual purposes, whatever. everything does what it should, the clips are created, the pics are loaded into them, nice and sweet. now, here’s the deal: the buttons ain’t buttons - they’re not ‘clickable’, no little hand is shown when the mouse goes over them, they don’t obey to the instructions they’re given, nuttin’!
the reason why I find this stupid is because I’ve done this before with text buttons and they worked fine. I’ve used the exact same code, but it doesn’t work.
//loads xml
var contentXML = new XML();
contentXML.ignoreWhite = true;
contentXML.load("xml/contentXML.xml");
_root.contentXML.onLoad = function() {
//variables
_root.content = _root.contentXML.firstChild.childNodes;
var pic = _root.picHolder_mc.pic_mc;
//arrays for storing items
var currentItems = [];
var currentIDs = [];
//loop that stores info in its proper array
for (i=0; i<_root.content.length; i++) {
var contentXMLnode = _root.content*;
currentItems.push(contentXMLnode.childNodes[1].childNodes[1].firstChild);
currentIDs.push(contentXMLnode.attributes.id);
}
//loop that creates empty clip to hold pics and assigns each to its proper clip
for (j=0; j<currentItems.length; j++) {
var currentPic = currentItems[j];
//creates empty clip
var menuItem = pic.createEmptyMovieClip("menuItem"+j+"_mc", j);
//assigns pic to clip
menuItem.loadMovie(currentPic);
//stuff required to position created clips
if (previousX<540) {
menuItem._x = previousX+90;
} else {
menuItem._x = 0;
}
menuItem._y = (Math.floor(j/7))*90;
var previousX = pic["menuItem"+j+"_mc"]._x;
//function to make each button pressable
//THIS IS WHAT DOESN'T WORK
pic["menuItem"+j+"_mc"].onPress = function() {
trace("you've just pressed a button");
}
}
}
(hope the code chunk isn’t too chaotic)
I’m figuring it might have to do with the fact that the dynamically generated clips are nested inside other clips, so the pointer might not see them, but the other times I’ve used this code they we’re nested even deeper, so it doesn’t make sense…
if anyone knows about any tutorial or information that might help to clear this out, or if you feel like taking a look at it, help would be very appreciated…