Conquering ENTER_FRAME :)

**touching **is a Boolean which is declared as false;
it becomes true in here:

mc.addEventListener(MouseEvent.MOUSE_OVER, onRollOver);
      function onRollOver(e:MouseEvent):void {
      touching = true;
}

and then false again in here:

mc.addEventListener(MouseEvent.MOUSE_OUT, onRollOut);
      function onRollOut(e:MouseEvent):void {
      touching = false;
}

first of all, i wanted to say it like this:

if (touching == true) {
addEventListener(Event.ENTER_FRAME, scrollMouse);
function scrollMouse(e:Event):void {
        TweenLite.to(container, 1, {x:((stage.stageWidth - container.width)/stage.stageWidth * mouseX)});
   }
}
if (touching == false) {
removeEventListener(Event.ENTER_FRAME, scrollMouse);
}

But it doesnt work, the listener is never added, dont understand why…

it WORKS like this:

addEventListener(Event.ENTER_FRAME, scrollMouse);
function scrollMouse(e:Event):void {
if (touching == true) {
        TweenLite.to(container, 1, {x:((stage.stageWidth - container.width)/stage.stageWidth * mouseX)});
   }
}
if (touching == false) {
}

But it defeats a purpose of adding/removing event listener when not necessary, especially ENTER_FRAME.

how can i make this work so that i add that listener only when i want and remove it accordingly?
i dont want to have ENTER_FRAME on my neck all the time…