2

I have a banner with a ClickTag and a hover function.

My problem is that that the user can't click on the button because of the hover function.

My code is for the ClickTag:

knap1.addEventListener(MouseEvent.CLICK, ADFclicked);

function ADFclicked(event:MouseEvent) { AdfURLNavigator.navigateToUrl( AdfFlashVarsUtil.getParameter("clickTAG"), AdfFlashVarsUtil.getParameter("landingPageTarget")); }

And for the hover function:

var holder:MovieClip = new MovieClip();

btn.addEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler);
btn.addEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler);
btn.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);

function mouseOverHandler(e:MouseEvent):void{
    //creating a new tooltip instance
    var tooltip:Tooltip = new Tooltip();
    //we tell the holder to hold our tooltip
    holder = tooltip;
    //positioning the tooltip on the stage
    holder.x = 190;
    holder.y = 280;
    //adding the tooltip to the stage 
    addChild(tooltip);
}

function mouseOutHandler(e:MouseEvent):void{
    //we remove the holder when the cursor is outside our button
    removeChild(holder);
}

function mouseMoveHandler(e:MouseEvent):void{
    holder.x = 190;
    holder.y = 280;
}

Can anybody help?

shanethehat
  • 15,460
  • 11
  • 57
  • 87

2 Answers2

0

I would assume, not seeing the entire code, that btn object is covering knap1 object so you cannot click on anything that is beneath btn.

If you want to have hover function over whole banner try using MOUSE_LEAVE event to detect mouse leaving and them MOUSE_MOVE to track if mouse is back on flash object after leaving it. As for MOUSE_MOVE event you can add listener to stage to detect mouse movement without any additional containers.

Szczups
  • 131
  • 4
  • Yes. I have two buttons there is covering the holde stage. One named btn and the other named knap1. And i want it so it is only knap1 you can press and active the ClickTag. So i should use the Mouse_leave on the btn button? – Simon Rothenborg Nov 18 '13 at 13:32
  • I got it. I just need to add the listener ti the stage instead. Thanks a lot Szczups – Simon Rothenborg Nov 18 '13 at 13:42
0

Hey you are using mousevent for hover & click at one time. So better remove addeventlistener & write the mouseover in button as inline.

UI Dev
  • 689
  • 2
  • 9
  • 31