0

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)
                            }
      }
4

2 回答 2

0

我认为你需要有 (event.currentTarget as Tile).outline.gotoAndStop("blank"); 在鼠标点击中。

另外,我假设 tilehover 是一些用于跟踪悬停状态的全局变量。在处理程序中明确设置它的真/假只是为了调试目的!!

于 2013-04-22T19:25:11.273 回答
0

见下文。您设置一个属性并立即检查该属性的值是什么。它将永远为真,因为您只是将其设置为真。

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

另外,不要忘记您的数据类型。

于 2013-04-22T19:01:53.817 回答