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 7685755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:19:27+00:00 2026-05-31T19:19:27+00:00

I have create a custom contextMenu using AS3 and can apply that to the

  • 0

I have create a custom contextMenu using AS3 and can apply that to the stage. Any movie clip I place onto the stage does not inherit the contextMenu from the stage, i.e. they display the default contextMenu.

How do I apply my custom contextMenu to every child in my application?

[edit]

This is a simplified version of what I have in my main.as file:

var my_menu:ContextMenu = new ContextMenu();
my_menu.hideBuiltInItems();

var my_copyright = new ContextMenuItem("Copyright - 2012");
my_copyright.enabled = false;
my_copyright.separatorBefore = true;

my_menu.customItems.push(my_copyright);

stage.contextMenu = my_menu;

If I right-click on the stage then I get the copyright. If I add a movieclip (or anything else) to the stage then right-click on that, then I get the default context-menu.

[edit]

I have found the problem, and fixed it. I was adding a background image using stage.addChildAt(mc, 0);. For some reason this removes the context menu. Placing the child at 1 fixes this and allows everything to inherit the contextMenu.

Before: http://richard.parnaby-king.co.uk/examples/stackoverflow/stackoverflow.swf

After: http://richard.parnaby-king.co.uk/examples/stackoverflow/stackoverflow-after.swf

I am changing the purpose of the bounty – can someone explain WHY this happens!?

  • 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-31T19:19:28+00:00Added an answer on May 31, 2026 at 7:19 pm

    Ok, so after a bit of testing this is what I have. I can’t say it’s that definitively, as flash doesn’t give the events for right-click, so it’s only a guess, but it seems to hold up.

    On a side note, you can’t add a context menu to the stage, it won’t allow it, so the lowest item you can add it to is the document class

    When you right-click on a DisplayObject, it’ll look for a ContextMenu on that object. It it doesn’t find one, it’ll continue on up the hierarchy for that object looking for one, stopping when it finds one. Something like this:

    stage
        - document (has context menu1)
            - parent (has context menu2)
                - child
            - parent2
    

    In this example, if you right click on child, there’s no menu, so it looks to parent. Here it finds context menu2 so it shows that. However if you right-click on parent2, there’s no menu, so it looks to document and here it finds context menu1.

    There seems to be a bit of a hack though when you right-click somewhere else on the stage (i.e. somewhere with no graphics). In this case, as the stage can’t have a ContextMenu (or at least you can’t set one), it seems to decide to use the context menu of the child at depth 0 (normally the document class).

    When you added your background image at depth 0, you were bumping up your document class to depth 1. Your hierarchy now looks something like this:

    stage
        - bg
        - document (has context menu1)
            - parent (has context menu2)
                - child
            - parent2
    

    I’m assuming you’re adding your context menu to the document class (in this example context menu1), so unless your document class has some graphics in it, your event would search up to the stage, find no context menu, then try to look for the context menu of child 0 – in this case bg which doesn’t have one.

    You can test this by drawing something in the graphics object of your document class (or clicking on one of the nested elements). If you right click on the graphics, you’ll see your custom menu, even though bg is at depth 0. Alternatively, you can add another menu to bg to see what I mean.

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

Sidebar

Related Questions

I have managed to create a custom action in C# using MakeSfxCA which is
I have a web app where people can create custom content on the web
I have a WPF application where I'd like to create a custom pop-up that
I'd like to create a custom window using WPF that doesn't look like the
I have to create the custom TableView with the picker control in multiple rows,can
I have create a custom url for my plugin in WordPress that I don't
I have created a custom style and template for MenuItem and ContextMenu, and for
I have to create a custom compound button bar control in Android like the
I'm trying to create a custom loading/throbber icon for my app. I have an
The task: I am trying to create a custom data type and have it

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.