mjperry51
02-04-2009, 08:17 PM
I have created a six button Movie Clip menu. Each clip has three labeled frames -- mouseOut, mouseOver, and mouseClicked.
I want the menu movie for the currently loaded Web page to gotoAndPlay the mouseOver frame. I have a flashvars procedure working so the swf knows the name of the page that is loaded, and listeneingevents set up for four mouse events - MOUSE_OVER, MOUSE_DOWN, MOUSE_UP and MOUSE_OUT.
I've tried various strategies for preventing the MOUSE_OUT event from firing when the cursor moves out of the active clip, with no success. Since the movie effectively "reloads" with every page transition I've tried to use the pagename flashvar in a switch statement to send the MovipClip to the mouseOut frame if it's not the active page, and to the mouseOver frame if it is.
I've attached the code associated with the Home button only; the code for the other buttons is identical except where a specific object name is required.
I'm real new to AS -- thanks for any suggestions. . .
Mike
btnHome.addEventListener(MouseEvent.MOUSE_OUT, btnHomeOut, false, 0, true);
btnHome.addEventListener(MouseEvent.MOUSE_OVER, btnHomeOver, false, 0, true);
btnHome.addEventListener(MouseEvent.MOUSE_DOWN,btn HomeDown, false, 0, true);
btnHome.addEventListener(MouseEvent.MOUSE_UP, btnHomeUp, false, 0, true);
var page:String = loaderInfo.parameters.pagename;
var currentBtn:MovieClip;
var btnName:String;
switch (page) { // sets button to active page mouseOver
case "index":
btnHome.gotoAndStop("mouseOver");
break;
case "image":
btnImage.gotoAndStop("mouseOver");
break;
case "build":
btnBuild.gotoAndStop("mouseOver");
break;
case "sponsors":
btnSponsors.gotoAndStop("mouseOver");
break;
case "press":
btnPress.gotoAndStop("mouseOver");
break;
case "contact":
btnContact.gotoAndStop("mouseOver");
break;
}
function btnHomeOver(evt:MouseEvent):void {
btnHome.gotoAndStop("mouseOver");
}
function btnHomeDown(evt:MouseEvent):void {
btnHome.gotoAndStop("mouseClick");
}
function btnHomeUp(evt:MouseEvent):void {
var req:URLRequest = new URLRequest ("index.html");
navigateToURL (req, "");
currentBtn = btnHome;
}
function btnHomeOut(evt:MouseEvent):void {
switch (currentBtn) {
case btnHome:
btnHome.gotoAndStop("mouseOver");
break;
default:
btnHome.gotoAndStop("mouseOut");
break;
}
}
Disregard -- found solution.
Referenced the string 'page' in the switch statement. Works fine.
I want the menu movie for the currently loaded Web page to gotoAndPlay the mouseOver frame. I have a flashvars procedure working so the swf knows the name of the page that is loaded, and listeneingevents set up for four mouse events - MOUSE_OVER, MOUSE_DOWN, MOUSE_UP and MOUSE_OUT.
I've tried various strategies for preventing the MOUSE_OUT event from firing when the cursor moves out of the active clip, with no success. Since the movie effectively "reloads" with every page transition I've tried to use the pagename flashvar in a switch statement to send the MovipClip to the mouseOut frame if it's not the active page, and to the mouseOver frame if it is.
I've attached the code associated with the Home button only; the code for the other buttons is identical except where a specific object name is required.
I'm real new to AS -- thanks for any suggestions. . .
Mike
btnHome.addEventListener(MouseEvent.MOUSE_OUT, btnHomeOut, false, 0, true);
btnHome.addEventListener(MouseEvent.MOUSE_OVER, btnHomeOver, false, 0, true);
btnHome.addEventListener(MouseEvent.MOUSE_DOWN,btn HomeDown, false, 0, true);
btnHome.addEventListener(MouseEvent.MOUSE_UP, btnHomeUp, false, 0, true);
var page:String = loaderInfo.parameters.pagename;
var currentBtn:MovieClip;
var btnName:String;
switch (page) { // sets button to active page mouseOver
case "index":
btnHome.gotoAndStop("mouseOver");
break;
case "image":
btnImage.gotoAndStop("mouseOver");
break;
case "build":
btnBuild.gotoAndStop("mouseOver");
break;
case "sponsors":
btnSponsors.gotoAndStop("mouseOver");
break;
case "press":
btnPress.gotoAndStop("mouseOver");
break;
case "contact":
btnContact.gotoAndStop("mouseOver");
break;
}
function btnHomeOver(evt:MouseEvent):void {
btnHome.gotoAndStop("mouseOver");
}
function btnHomeDown(evt:MouseEvent):void {
btnHome.gotoAndStop("mouseClick");
}
function btnHomeUp(evt:MouseEvent):void {
var req:URLRequest = new URLRequest ("index.html");
navigateToURL (req, "");
currentBtn = btnHome;
}
function btnHomeOut(evt:MouseEvent):void {
switch (currentBtn) {
case btnHome:
btnHome.gotoAndStop("mouseOver");
break;
default:
btnHome.gotoAndStop("mouseOut");
break;
}
}
Disregard -- found solution.
Referenced the string 'page' in the switch statement. Works fine.