|
-
Senior Member
Okay, so you have got your XML imported and everything, right? So you don't need me to continue on that translation, right?
In that case, I would go about it kind of like this:
Add another tag to your menu items, like this for example:
<menu>
<item linkURL="http://www.google.com">item1txt</item>
</menu>
Then when you load your XML on the complete handler poplulate arrays with your your buttons created and URLs:
btnArray.push(btnNameInFunction);
linkArray.push(linkNameInFunction);
The way you have your XML set up you would import the link like I listed similar to this:
Say your imported xml variable was myXML.
And your using a loop to call these
btnNameInFunction.linkName = myXML.menu.item[i].@linkURL
Then in your function you would do something like this:
private function linkIt(evt:Event):void {
if(evt.target.name == btnArray[i]) {
this.navigateToURL(new URLRequest(this[linkArray[i]]), "_blank");
}
}
Something similar to this, where I just had tracing calls.
var btnArray:Array = new Array();
var linkArray:Array = new Array("blah1","blah2","blah3");
var linkName:String;
for (var i:Number = 0; i<linkArray.length; i++) {
btnArray.push(this["mc"+i]);
trace(btnArray);
}
for (var a:Number = 0; a<btnArray.length; a++) {
btnArray[a].addEventListener(MouseEvent.CLICK, linkIt);
btnArray[a].linkName = linkArray[a];
trace(linkArray[a]);
trace(btnArray[a].linkName);
}
function linkIt(evt:Event):void {
for (var i:Number = 0; i<linkArray.length; i++) {
if (this[evt.target.name].linkName == linkArray[i]) {
trace(linkArray[i]);
}
}
}
Am I totally off kilter in helping? If so let me know and I'll try to go more in depth, and more specific. Good luck.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|