Skip to main content
Participant
March 23, 2009
Question

Button on Top of Movie Clip producing Strange Results

  • March 23, 2009
  • 2 replies
  • 991 views
So, at one time I w s fairly familliar with Flash, but I am now returning to it and need some help. I have a movie clip that I am using AS3 to control, basically it slides out when your rollover it and then slides out when you mouse off it. This is my code:

OPEN:
stop();
import flash.events.MouseEvent;
slider.addEventListener(MouseEvent.MOUSE_OVER, Open);
function Open(event:MouseEvent):void{
gotoAndPlay("start");
}

CLOSE:
stop();
import flash.events.MouseEvent;
slider.addEventListener(MouseEvent.MOUSE_OUT,Close);
function Close(event:MouseEvent):void {
gotoAndPlay("stop");
}

I would like to place a series of button images on top of that sliding panel and add links to them. I started to so this, but when you rollover the button, the movie clip gets really freaky. Code for button:

import flash.events.MouseEvent;
btn1.addEventListener(MouseEvent.CLICK, corinthianCoin);
function corinthianCoin(event:MouseEvent)
{
navigateToURL(new URLRequest(" http://www.si.edu") ("_self"));
}

Here is what I am dealing with. I would like the coin to function as a link.

http://darrenmilligan.com/testflash.html

Any ideas?

Thanks,

Darren
This topic has been closed for replies.

2 replies

Inspiring
March 24, 2009
I did not take time to comprehend everything but here is what may help. There is no onRolloutOutside function in AS3 any longer. So, one needs to add MouseEvent.ROLL_OUT and such to stage - not objects (and properly remove it).

Also, to fine-tune mouse events functionality you have to play with adding/removing listeners to the object and stage to achieve a desired result.

I know it is, at first, very cumbersome, but in awhile it feels pretty natural.
Ned Murphy
Legend
March 23, 2009
You need to make the coin's ROLL_OVER code work to keep the slider doing its thing, otherwise, as you can see, it is seeing the MOUSE_OUT of the slider when you go over the coin and starts to retreat. You may need to pull in some conditional code that keeps the MOUSE_OUT from occuring... maybe have a value that both the slider and coin rollovers set false, and only the slider rollout turns true.


var allowSliderToHide:Boolean = true; // set false with MOUSE_OVER's of slider and coin, set true with MOUSE_OUT of slider

slider.addEventListener(MouseEvent.MOUSE_OUT,Close);

function Close(event:MouseEvent):void {
if(allowSliderToHide){
gotoAndPlay("stop");
}
}
Participant
March 23, 2009
Thank you Ned. It seems like when I do this the slider just opens and closes constantly on its own?

OPEN:
stop();
import flash.events.MouseEvent;

var allowSliderToHide:Boolean = false; // set false with MOUSE_OVER's of slider and coin, set true with MOUSE_OUT of slider

slider.addEventListener(MouseEvent.MOUSE_OVER, Open);
function Open(event:MouseEvent):void{
if(allowSliderToHide){
gotoAndPlay("start");
}}

CLOSE:
stop();
import flash.events.MouseEvent;
var allowSliderToHide:Boolean = true; // set false with MOUSE_OVER's of slider and coin, set true with MOUSE_OUT of slider

slider.addEventListener(MouseEvent.MOUSE_OUT,Close);

function Close(event:MouseEvent):void {
if(allowSliderToHide){
gotoAndPlay("stop");
}
}

BUTTON:
import flash.events.MouseEvent;

var allowSliderToHide:Boolean = false; // set false with MOUSE_OVER's of slider and coin, set true with MOUSE_OUT of slider

btn1.addEventListener(MouseEvent.CLICK, corinthianCoin);
function corinthianCoin(event:MouseEvent)
{if(allowSliderToHide){
navigateToURL(new URLRequest(" http://www.si.edu") ("_self"));
}
}
Ned Murphy
Legend
March 24, 2009
You only want the conditional in the function that closes the slider... you don't want it to close unless it is a genuine mouseout of the slider. Doublecheck what I offered... I think I explained it right