Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7722899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:18:29+00:00 2026-06-01T04:18:29+00:00

Im having some trouble getting the syntax right. I have a movie clip that

  • 0

Im having some trouble getting the syntax right.

I have a movie clip that adds sounds to an array when it is touching other movie clips.
I have a stop button than i want to remove the event listener of the bar and send back to the original position.

My code is:

//event listener for the start button
playy.addEventListener(MouseEvent.CLICK, mouseClick2);

function mouseClick2(event:MouseEvent):void
{
    bar.addEventListener(Event.ENTER_FRAME, onEnter);
}


//Add event listener for the stop button
stopp.addEventListener(MouseEvent.CLICK, mouseClick3);


//when clicked remove listener send back to position
function mouseClick3(event:MouseEvent):void
{
    bar.removeEventListener(MouseEvent.CLICK, mouseClick3);

    function mouseClick3(evt:Event):void
    {
        if(bar.x > 780)
        {
             bar.x = 215;
        }
    }
}


function onEnter(evt:Event):void
{
    bar.x += 1;

    if(bar.x > 780)
    {
        bar.x = 215;
    }

    for(var i:int=0; i<blocks.length;i++)
    {
        if (bar.hitTestObject(blocks[i]))
        {
            blocks[i].start();
        }
        else
        {
            blocks[i].stopSound();
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T04:18:31+00:00Added an answer on June 1, 2026 at 4:18 am

    I’m guessing that your function should be this:

    //when clicked remove listener send back to position
    function mouseClick3(event:MouseEvent):void
    {
        bar.removeEventListener(MouseEvent.CLICK, mouseClick3);
    
        if(bar.x > 780)
        {
            bar.x = 215;
        }
    }
    

    The issue is that you have two “mouseClick3” functions in there. The inner mouseClick3 never actually executes, and the removeEventListener is going to target the mouseClick3 that never executes, since that is the variable local in the function. If you remove the inner mouseClick3, the code will execute and your listener will target the correct function.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having some trouble getting Python IO redirected to a console that I've
Having trouble getting this syntax right: SELECT DISTINCT id FROM metadata WHERE (meta_key =
I'm having some trouble getting an object to follow a path that is drawn
Im having some trouble getting on with my first codeigniter project, and i have
I'm having some trouble getting NH to persist my object graph. I have (something
I'm having some trouble getting a view to flip. I have the following code
I am having some trouble getting a List of one of my classes that
I'm having some trouble getting large background images I have for a site in
I am having some trouble getting general files to read into a program that
Having some trouble getting a screenscraper webservice up and running on a weblogic 10.3.3

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.