Still creating the menu I ran into this problem with getURL.
I’ve tried a lot of things, but it still won’t go to the URL.
Here’s my AS code.
I marked out where the getURL is.
[AS]
// Create xml-object
menuXml = new XML();
// Ignore tabs, spaces etc.
menuXml.ignoreWhite = true;
menuXml.onLoad = function(success) {
// When loaded, start building up the menu
if (success) {
// Create array topMenus that will hold
// the number of topMenuItems in the frame
_root.topMenus = new Array();
// Create variable topMenuItemStartPosX
// for positioning the topMenuItems
var topMenuItemStartPosX = 0;
var topMenuItem = this.firstChild.childNodes;
for (var i = 0; i<topMenuItem.length; i++) {
var item = _root.attachMovie(“topMenuItem”, “topMenuItem”+i, i);
// Set the label of the new item
item.itemLabel.text = unescape(topMenuItem*.attributes.itemLabel);
// Set appropriate width for the textfield holding the label of
// the item (7pxnumber of letters in the label)
item.itemLabel._width = item.itemLabel.text.length7;
// Set appropriate backlight width based on the width of itemLabel
item.backlight._width = 4+item.itemLabel._width;
// Set the _x value for the new item, based on previous topMenuItems
item._x = 2+topMenuItemStartPosX;
item._y = 2;
// Check for subMenus
if (topMenuItem*.childNodes.length) {
// Attach a subMenu to current item
var subMenu = item.attachMovie(“subMenu”, “subMenu”, _root);
// Create variable subMenuItemStartPosX for positioning the subMenuItems
var subMenuItemStartPosX = 0;
subMenuItem = topMenuItem*.childNodes;
for (var j = 0; j<subMenuItem.length; j++) {
var subItem = subMenu.attachMovie(“subMenuItem”, “subMenuItem”+j, j);
// Set the label of the new subItem
subItem.itemLabel.text = unescape(subMenuItem[j].attributes.itemLabel);
// Set the url of the new subItem
subItem.itemURL = subMenuItem[j].attributes.itemUrl;
// Set the _x value for the new subItem, based on previous
// subMenuItems and minus the current topMenuItemStartPosX
subItem._x = 50+subMenuItemStartPosX-topMenuItemStartPosX;
// Set the _y value for the new subItem, and increase
// with 22px for every new subItem
subItem._y = 48+(20*j);
// If the new subItem is too far down, move it to the
// top of a new “column”
while (subItem._y>180) {
subItem._x += 150;
subItem._y -= 140;
}
//////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////
// When subItem is clicked, go to the subItems url
subItem.onRelease = function() {
// Why doesn't this work?
getURL(this.itemUrl, "_blank");
};
//////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////
}
// Hide the subMenu by default
subMenu._xscale = 0;
}
// Set new value of topMenuItemStartPosX, where the width of
// the current (topMenu)item is added, so that the next item
// will be placed to the left of the current item
topMenuItemStartPosX += item.backlight._width;
// Add the current name to the topMenus-array
_root.topMenus* = item.name;
// When onRollOver is trigged, it will be lit up
item.onRollOver = function() {
this.backlight._alpha = 100;
};
item.onRollOut = function() {
// When onRollOut is trigged, check if the var clicked is set
if (!this.clicked) {
// If not, don't lit up
this.backlight._alpha = 0;
} else if (this.clicked) {
// If it is
if (this.clicked=false) {
// ...but if clicked is false, don't lit up
this.backlight._alpha = 0;
} else if (this.clicked=true) {
// ...and clicked = true, keep lit
this.backlight._alpha = 100;
}
}
};
item.onRelease = function() {
// "Disable" all other topMenuItems (how many there are is
// based on the number of topMenuItems in the array topMenus)
for (var k = 0; k<_root.topMenus.length; k++) {
_root["topMenuItem"+k].backlight._alpha = 0;
_root["topMenuItem"+k].clicked = false;
// If there is a subMenu in the current topMenuItem that
// is to be "disabled", hide it
if (_root["topMenuItem"+k].subMenu) {
_root["topMenuItem"+k].subMenu._xscale = 0;
}
}
// Set var clicked for reference in the item.onRollOut
this.clicked = true;
// Lighten up current item
this.backlight._alpha = 100;
// If the current item has a subMenu, show it
if (this.subMenu) {
this.subMenu._xscale = 100;
}
};
}
}
};
// Load the xml
menuXml.load(“nav.xml”);
[/AS]
and my XML looks like this:
<?xml version="1.0" encoding="iso-8859-1"?>
<topMenu>
<topMenuItem itemLabel="KIRUPA.COM">
<subMenuItem itemLabel="Tutorials overview" itemUrl="http://www.kirupa.com/developer" />
<subMenuItem itemLabel="Flash MX2004 tutorials" itemUrl="subMenuItem1.htm" />
<subMenuItem itemLabel="Flash MX tutorials" itemUrl="subMenuItem2.htm" />
<subMenuItem itemLabel="Flash 5 tutorials" itemUrl="subMenuItem3.htm" />
<subMenuItem itemLabel="Kirupa Forums" itemUrl="http://www.kirupaforum.com/forums/" />
<subMenuItem itemLabel="subItem 5" itemUrl="#" />
<subMenuItem itemLabel="subItem 6" itemUrl="#" />
<subMenuItem itemLabel="subItem 7" itemUrl="#" />
<subMenuItem itemLabel="subItem 8" itemUrl="#" />
<subMenuItem itemLabel="subItem 9" itemUrl="#" />
</topMenuItem>
<topMenuItem itemLabel="ITEM 2">
<subMenuItem itemLabel="subItem 0" itemUrl="#" />
</topMenuItem>
<topMenuItem itemLabel="ITEM 3" />
</topMenu>
Please help!
Greetings
Kalliban