0
votes

On my screen are tiles generated from an array. I have a mouse roll over function called rollover, that adds a movieclip that highlights the edge of the tiles that I am currently on. I want it so that once I click a tile, the roll over function doesn't work until another button is clicked. I tried putting removeEventListener for the roll over function in the click function, doesn't seem to work. How would I go about this if possible?

I will post more information if needed.

function rollover(event:MouseEvent)
      {
        var tileHover = true;
        if (tileHover == true){
                (event.currentTarget as Tile).outline.gotoAndStop("hover");
                }
        if(tileHover == false){
                (event.currentTarget as Tile).outline.gotoAndStop("blank");
                }
      }

Below is the mouseclick function

function mouseclick(event:MouseEvent)
      {
        tileHover = false;
        if (tileHover == false){
            tile_MC.removeEventListener(MouseEvent.ROLL_OVER, rollover)
                            }
      }
2

2 Answers

0
votes

See below. You set a property and immediately check what the value of that property is. It will always be true because you just set it as true.

var tileHover = true;
if (tileHover == true){
   (event.currentTarget as Tile).outline.gotoAndStop("hover");
}

Also, don't forget your data types.

0
votes

I think you need to have (event.currentTarget as Tile).outline.gotoAndStop("blank"); in mouseclick.

Also, I assume tilehover is some global variable used for tracking the hover state. Explicitly setting it true/false in the handler is just for debugging purposes!!