Saturday, 17 April 2010

Horizontal sliding menu in AS3 part 2

This is the second part of the Horizontal sliding menu in Actionscript 3 tutorial where you will learn how to add a different URL to each of the buttons. Some knowledge of opening URL’s in Actionscript 3 will be useful for this tutorial. The same code in this post can be applied to the other navigation menus on this blog.


Horizontal sliding menu in AS3 part 2

Step 1

Open the Horizontal sliding menu in AS3 tutorial.


Step 2

Open up the Actions panel and add the following code in red colour to the previous tutorial.

//Array to hold the URL’s of the buttons.
var linkArr:Array = new Array();
linkArr.push("http://www.ilike2flash.com/");
linkArr.push("http://www.ilike2flash.com/2008/03/tutorials.html");
linkArr.push("http://feeds2.feedburner.com/blogspot/YLDd");
linkArr.push("http://www.ilike2flash.com/2008/06/contact_09.html");

//Add the click events to all the buttons in the array.
for (var i:uint = 0; i < buttonsArr.length; i++) {
buttonsArr[i].addEventListener(MouseEvent.ROLL_OVER, moveFollow);
buttonsArr[i].addEventListener(MouseEvent.CLICK, clickURL);
}

//This function goes to the appropriate URL when the button is clicked.
function clickURL(event:MouseEvent):void {
for(var j:uint =0;j < linkArr.length; j++){
if(event.currentTarget == buttonsArr[j]){
navigateToURL(new URLRequest(linkArr[j]));
}
}
}

Step 3

Test your movie Ctrl + Enter.

0 comments:

  COPYRIGHT © 2014 · ILIKE2FLASH · Theme by Ourblogtemplates

Back to TOP