PDA

View Full Version : Actionscript/xml Help


michaelespinosa
10-11-2008, 02:30 AM
I am working on flash site that is driven by an xml file. I need to have one of the nav buttons link to an external site in a new window. The nav is setup in the xml file under "menuItem" and link is in "contentPath." I think need a new attribute (ie "linkPath") that could be pulled into the AS. In flash I would usually use getUrl to link but I need help connecting the two. I need help pulling the variable in then having link out. If you need more information let me know. Thanks for any help.

Attachments:
fla file (http://vividtreasures.com/issues/template.fla)
xml file (http://vividtreasures.com/issues/template.xml)

gnomeontherun
10-13-2008, 08:42 PM
I don't understand what you are asking. I know you want to link the two, but this is a rather laborious process to redesign the template you have here. Could you explain better?

itsallkizza
10-17-2008, 04:22 PM
From what I can understand (if I'm wrong let me know, still willing to help ;)) you can go ahead and add another attribute (label it "url_target" or something) to each of those menu items in the xml, with the values "_self", "_blank", "_parent" or whatever you need (you get the picture). Then in the actionscript you can grab those and assign them to a variable and throw that variable in as the second parameter of getURL.

Since the .fla you posted requires an external actionscript file to run I can't test/debug this for you. But here's what it might look like:

//add this to your function parse() for loop
menuTargetsArray = recurse4(kids[i]);

//add this too
function recurse4(node){
var kids = node.childNodes
var tempItems = new Array();
for(var i=0;i < kids.length;i++){
tempItems.push(kids[i].attributes.backgroundPath);
if(kids[i].hasChildNodes()){
var temp = new Array();
temp = [kids[i].attributes.url_target, recurse4(kids[i])];
tempItems.splice(i,1);
tempItems.push(temp);
}
}
return tempItems;
}

//this was the only getURL function I could find, I have no idea if its the one you need to change or not, also you need to reference the url_target somehow
urlButtonMC.button.onRelease = function(){
getURL(imageURL,url_target);
}


hope this helps. again, I can't test/debug so you're going to have to do the deciphering yourself but the key points are:

1) add another target attribute to xml nav elements
2) you can access the attribute using node.attributes.url_target
3) parse through those attributes and add them as variables to each menu item movieclip
4) find the onRelease (or onPress) getURL function for the menu items and use the new variable as the target parameter