Ok, iv’e done a bit of web search, but havn’t had any luck.
What I want to do is have 6 menu buttons with states (such as mouseOver, mouseOut and mouseClick). I have my MC’s on stage as:
menuMC.homeMC
menuMC.flashMC
menuMC.videoMC
menuMC.threedMC
menuMC.aboutMC
menuMC.contactMC
I want to be able to set up a rather dynamic function that uses the movie clip name (menitoned above). I’m not really sure how to do it though. I figure i may need to use an array somehow like :
var buttonsList:Array=new Array('menuMC.homeMC','menuMC.flashMC','menuMC.videoMC','menuMC.threedMC','menuMC.aboutMC', 'menuMC.contactMC');
But I dont know what the rest of the code would be and I am new to arrays.
My current code is something along the lines of:
menuMC.homeMC.addEventListener(Event.ENTER_FRAME, button1);
menuMC.flashMC.addEventListener(Event.ENTER_FRAME, button2);
menuMC.videoMC.addEventListener(Event.ENTER_FRAME, button3);
menuMC.threedMC.addEventListener(Event.ENTER_FRAME, button4);
menuMC.aboutMC.addEventListener(Event.ENTER_FRAME, button5);
menuMC.contactMC.addEventListener(Event.ENTER_FRAME, button6);
var buttonID:MovieClip;
var playForward:Number;
function button1(event:Event) {
buttonID=menuMC.homeMC;
button(null);
}
function button2(event:Event) {
buttonID=menuMC.flashMC;
button(null);
}
function button3(event:Event) {
buttonID=menuMC.videoMC;
button(null);
}
function button4(event:Event) {
buttonID=menuMC.threedMC;
button(null);
}
function button5(event:Event) {
buttonID=menuMC.aboutMC;
button(null);
}
function button6(event:Event) {
buttonID=menuMC.contactMC;
button(null);
}
function button(event:MouseEvent) {
buttonID.mouseChildren=false;
buttonID.buttonMode=true;
buttonID.useHandCursor=true;
buttonID.addEventListener(MouseEvent.CLICK, buttonClick);
buttonID.addEventListener(MouseEvent.MOUSE_OUT, buttonMouseOut);
buttonID.addEventListener(MouseEvent.MOUSE_OVER, buttonMouseOver);
buttonID.addEventListener(Event.ENTER_FRAME, onEnterFrames);
}
function buttonClick(Event:MouseEvent) {
trace("mouse clicked: " + buttonID);
}
function buttonMouseOut(Event:MouseEvent) {
trace("mouse out: " + buttonID);
playForward=0;
}
function buttonMouseOver(Event:MouseEvent) {
trace("mouse over: " + buttonID);
playForward=1;
}
function onEnterFrames(event:Event) {
if ((buttonID.currentFrame != buttonID.totalFrames) || (buttonID.currentFrame != 0)) {
if (playForward==1) {
buttonID.nextFrame();
}
if (playForward==0) {
buttonID.prevFrame();
}
}
}
The above code works, but when i mouse over one button, it appears as if the ‘onEnterFrames’ function is applying to all of them…
Any help is much appreciated…