- Create a MovieClip and give it a name "button1"
- Dublicate that MovieClip as many Buttons you want and give names as "button2" "button3" etc
- Create another MovieClip and give it the name "main" put it in your Layer 1 and add "Main" as an instanceName
- Inside the "Main" MovieClip add the two Buttons and add "Button1" and "Button2" as an Instancename each
- Create a Class file for main MovieClip
- Copy paste the following code as class
or download the examples.zip to see it http://www.comvos.net/downloads/examples.zip
class main extends MovieClip
{
function main() { super(); }
function onLoad()
{
this.ControlMyMC();
}
function ControlMyMC()
{
//Turn OFF the HandCursor of Main MC
this.useHandCursor = false;
this.onRollOver = function()
{
this["AnimatedBG"].gotoAndPlay(2);
trace("RollOver Main MC");
}
this.onRollOut = function()
{
this["AnimatedBG"].gotoAndPlay(21);
trace("RollOut Main MC");
}
var ButtonInstanceNames:Array = [
"Button1",
"Button2"
];
for(var i:Number = 0; i < ButtonInstanceNames.length; i++)
{
this[ButtonInstanceNames[i]].onEnterFrame = function()
{
if (this.hitTest(_root._xmouse, _root._ymouse, true))
{
//ROLL OVER BUTTON
if (!this.isRollOver)
{
this.isRollOver = true;
trace("RollOver " + _name);
}
}
else
{
//ROLL OUT BUTTON
if (this.isRollOver)
{
this.isRollOver = false;
trace("RollOut " + _name);
}
}
}
//ON RELEASE ---(if you want to use onPress .... just replace the onMouseUp wit onMouseDown
this[ButtonInstanceNames[i]].onMouseUp = function()
{
if (this.hitTest(_root._xmouse, _root._ymouse, true))
{
switch (_name)
{
case "Button1": trace("You Clicked on Button 1 ... replace me with ---> this.getURL(\"page1.html\");"); break;
case "Button2": trace("You Clicked on Button 2 ... replace me with ---> this.getURL(\"page2.html\");"); break;
//example
case "Button3": this.getURL("name.html"); break;
default: trace("aa"); break;
}
}
}
}
}
}