Subscribe to our newsletter:
Page 1
DOWNLOAD SOURCE FILE FOR THIS TUTORIAL
In this tutorial I show how to create a flash menu using nothing but Actionscript. Creating menus and other flash elements with only Actionscript makes updating, modifying, and experimenting extremely quick and easy.
//Set an Array to store the button names //Push the button names into namesArray//Set an Array to store the button urls //Push the button urls into urlArray//Set a for loop to loop 5 times. 5 referse to the number of buttons//Create a movie clip named i on the next highest level.//Create a movie clip named buttonBkg inside the button movie clip on the next highest level.//Set the lineStyle for buttonBkg//Begin the buttonBkg fill]//The lineTo parameters define the shape of the buttonBkg//End the fill//Set the text formate//Set myFormat parameters//Create a new text field inside the button movie clip on the next highest level and define the x, y, width, and length.//Place the name of the button into the textBox from the namesArray defined on line 7//Set the text formate to the textBox//Set the X position of the button equal to the last button plus the width of this button plus 5 (5 is the space between each button).
//This move the button over so all the buttons don’t lay on top of each other.//Set the onRelease function to the buttonRelease function//Set the buttonRelease function //Set a varible named buttonName equal to the instance name of the current button being clicked on //Set a varible named buttonIndex equal to the 6th character of the buttons instance name.
//This will return a number between 0 and 5. We will use this to pull the correct url from the urlArray //get the url from the urlArray of the current button being clicked on. and target a blank window
In this tutorial I show how to create a flash menu using nothing but Actionscript. Creating menus and other flash elements with only Actionscript makes updating, modifying, and experimenting extremely quick and easy.
//Set an Array to store the button names
var namesArray:Array = new Array();namesArray.push("HOME", "ABOUT", "LICENSE", "SUBMIT", "CONTACT");var urlArray:Array = new Array();urlArray.push("http://www.flashframer.com",
"http://flashframer.com/about/",
"http://flashframer.com/license/",
"http://flashframer.com/submit/",
"http://flashframer.com/contact/");for(i=0;i<5;i++){this.createEmptyMovieClip("button"+i, this.getNextHighestDepth());this["button"+i].createEmptyMovieClip("buttonBkg", this["button"+i].getNextHighestDepth());this["button"+i].buttonBkg.lineStyle(0, 0×000000, 100, true, "none", "square", "round");this["button"+i].buttonBkg.beginFill(0×999999);this["button"+i].buttonBkg.lineTo(99, 0);
this["button"+i].buttonBkg.lineTo(99, 24);
this["button"+i].buttonBkg.lineTo(0, 24);
this["button"+i].buttonBkg.lineTo(0, 0);this["button"+i].buttonBkg.endFill();<b>var myFormat:TextFormat = new TextFormat();</b><b>myFormat.align = "center";
myFormat.font = "Tahoma";
myFormat.size = 13;
myFormat.color = 0xFFFFFF;
this["button"+i].textBox.embedFonts = false;
this["button"+i].textBox.selectable = false;
this["button"+i].textBox.antiAliasType = "advanced";</b>this["button"+i].createTextField("textBox", this["button"+i].getNextHighestDepth(), 0, 2, this["button"+i]._width, this["button"+i]._height);this["button"+i].textBox.text = namesArray[i];this["button"+i].textBox.setTextFormat(myFormat);//This move the button over so all the buttons don’t lay on top of each other.
this["button"+i]._x = this["button"+(i-1)]._x + this["button"+i]._width + 5;this["button"+i].onRelease = buttonRelease;
}function buttonRelease(){var buttonName:String = this._name;//This will return a number between 0 and 5. We will use this to pull the correct url from the urlArray
var buttonIndex = buttonName.substr(6,1);getURL(urlArray[buttonIndex],"_blank");
}




help
and feedback
latest
news
latest
forum entries