removeEventListener with arguments

By DudeCreative | Jul 6, 2009

actionscript3

Hi,

I’m working on a website navigation wherein I want that on clicking the navigation buttons, a movie clip eases out to that clicked button to show the current page.

I’m able to move the movieclip to the button’s location but I need to remove the event listener once the movieclip stops over the navigation button.

Can you please help me where my code is going astray?

Here’s my code:
================================================== ========

Code:

import flash.events.Event;

btnStart.addEventListener(MouseEvent.CLICK, startMovie);

function startMovie(e:Event):void {
  ball.addEventListener(Event.ENTER_FRAME, moveBall(btnStart));
}

function moveBall(bt:SimpleButton):Function {
  return function(e:Event):void {
      var _mc = e.target;
      _mc.x += (bt.x - _mc.x)/7;
      _mc.y += (bt.y - _mc.y)/7;
      if (Math.round(_mc.x) == Math.round(bt.x) && Math.round(_mc.y) == Math.round(bt.y)) {
        ball.removeEventListener(Event.ENTER_FRAME, moveBall(btnStart));
      }
  }
}


actionscript3

Please reply at our Forum

Leave a Comment

If you would like to make a comment, please fill out the form below.

Name (required)

Email (required)

Website

Comments

© 2007 ActionScript 3.0