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

  • Home
  • SEARCH
  • 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 540881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:17:10+00:00 2026-05-13T10:17:10+00:00

I am developing a website with nav items that cover the whole stage from

  • 0

I am developing a website with nav items that cover the whole stage from top to bottom (see altered image below) and it is pretty easy for the user to exit the stage with their mouse, not triggering the MouseEvent.MOUSE_OUT events required to “turn off” said nav items.

Should I be using Event.MOUSE_LEAVE to detect when the mouse has left the stage, and turn off any enabled nav items? That is what I been trying to do, but have had trouble getting any output from my listener. Any ideas?

alt text http://marcysutton.com/blog/wp-content/uploads/2010/01/redpropeller.png

For a class associated with a movieclip in the Flash IDE, is this the correct syntax for registering an Event.MOUSE_LEAVE listener? It doesn’t seem to do anything no matter what I do. Is it a case where I have to embed the movie in a browser for the event to fire?

this.stage.addEventListener(Event.MOUSE_LEAVE, mouseLeaveListener);

Here is my MainNav.as class:

package com.redpropeller {

import com.greensock.*;
import com.greensock.plugins.*;
import flash.display.*;
import flash.text.*;
import flash.events.*;

public class MainNav extends MovieClip { // MainNav is a movieclip in the IDE

    public var colors:Array;

    public function MainNav():void {
        colors = new Array(0xee3124, 0xc72a1f, 0xa62c24, 0x912923, 0x7e221c);
        TweenPlugin.activate([TintPlugin]);

        // trying to target stage through this object
        this.stage.addEventListener(Event.MOUSE_LEAVE, mouseLeaveListener);

        for(var i:Number=0; i<this.numChildren; i++){
            var n = this.getChildAt(i);
            n.useHandCursor = true;
            n.buttonMode = true;

            n.addEventListener(MouseEvent.MOUSE_OVER, navBtnOn);
            n.addEventListener(MouseEvent.MOUSE_OUT, navBtnOff);
        }
    }
    public function mouseLeaveListener(e:Event):void {
        trace('mouseleave'); // nothing ever happens

    }
    private function navBtnOn(e:MouseEvent):void {
        TweenLite.to(e.currentTarget.bar_mc, 0.01, {tint:0x333333});
    }
    private function navBtnOff(e:MouseEvent):void {
        TweenLite.to(e.currentTarget.bar_mc, 0.01,
            {tint:uint(colors[this.getChildIndex(MovieClip(e.currentTarget))])});
            // changes color back to specific tint
    }
}

}
  • 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-05-13T10:17:10+00:00Added an answer on May 13, 2026 at 10:17 am

    You’re trying to create the event listener for MOUSE_LEAVE in the constructor. It’s possible that the stage object does not exist yet if MainNav has not been added to the stage via an addChild() method. If MainNav is already on the stage at design time, it’s still possible that stage would not be available immediately. For classes that inherit from the DisplayObject (MovieClip, Sprite, etc.), I do only one thing in the constructor: set up an Event.ADDED_TO_STAGE listener. That listener triggers an init() method when the object has been added to the stage’s display stack via addChild() from a parent container, or if the object is already on the stage at design time. When my init() method is called, I know that the stage property will be available.

    In your constructor, stage may not exist in the instance yet, but you should get a runtime error. However, you’re using the ‘this’ keyword ahead of stage. When you use ‘this’ in a class that inherits from Object (your class does via MovieClip->DisplayObject->EventDispatcher->Object), the compiler won’t throw an error if the property does not exist because it attempts to create that property as a member of ‘this’. This happens because the Object class is dynamic, meaning that new properties can be created at any time without having to declare them as class variables in the header — you just have to use the ‘this’ keyword when using that dynamic property. When you use this.stage, if stage does not exist the class creates the property stage for you. However, this is not the stage you want, so the listener is just getting attached to an empty object that doesn’t do anything. Try removing ‘this’ when referencing stage and I’m sure you’ll see the error at some point. In general, it’s not good practice to use ‘this’ for properties, since the compiler will ignore type errors for that property.

    You mention in one comment above that MOUSE_LEAVE does not work in the IDE, but I tested this from CS4 and it does work. You may be witnessing a performance difference from the IDE’s Flash Player compared to the browser’s Flash Player plugin. In some cases your stage event listener will work from the constructor if the SWF loads quickly and stage is available immediately, but it’s not reliable. Move that listener to an init() method that is called after the ADDED_TO_STAGE event and don’t use the ‘this’ keyword.

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

Sidebar

Ask A Question

Stats

  • Questions 320k
  • Answers 320k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Yes, it is safe. bindParam() associates a parameter with a… May 14, 2026 at 12:17 am
  • Editorial Team
    Editorial Team added an answer It's a new string. Strings, in .NET, are always immutable.… May 14, 2026 at 12:17 am
  • Editorial Team
    Editorial Team added an answer Well, you don't provide any explanation about what jflickrfeed does,… May 14, 2026 at 12:17 am

Related Questions

Greetings. I am developing an animated homepage for a Flash-HTML hybrid website, and for
I am developing a website(web forms , not MVC) in VS 2008(with SP1 ).I
I am developing a website using SQL Server Express on my development machine. My
I am developing a website using forms and one of the browsers being targeted
I am developing a website in PHP and I would like to use a

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.