14 Replies Latest reply on May 21, 2007 9:19 AM by Flash Cus

    Context Menu

    Flash Cus
      OK, so i thought...i can make a menu when the user right clicks...A Context menu. I created a snazzy orange menu. I made the AS so that when a user right clicks, the movie appears when they click, and when the choose an option, the menu disappears. There are two things on my list:

      1) How can you completely disable the context menu. I don't care how, be it software, actionscript, javascript, html or anything.

      2) How can i make it so that there is function like "onClickOutside" (i know that isn't a function) where something happens when a user clicks outside the menu (it disappears as well)

      Cheers experts,
      Flash Cus
        • 1. Context Menu
          Greg Dove Level 4
          You can't disable the context menu in a browser based flash player. Period. You can reduce what it displays to the minimum mandatory items, but that's it.

          If you're creating standalone projectors you can use something that edits the resources in a windows exe to remove the context menus in a regular flash projector (I don't know about Mac)- although I've done this sucessfully in the past its been a long time and I can't remember exactly what I did. Or if you use a 3rd party tool like Zinc or SWF Studio or Jugglor or (probably lots of others) I'm sure you could do it with some of their options in a much easier way.

          I assume your 'orange menu' is a type of movieclip. You could watch for an onRollout event... then use a Mouse listener for the onMouseDown event.
          onRollover would need to cancel your Mouse listener.


          • 2. Re: Context Menu
            Flash Cus Level 1
            Ok i've been experimenting but no luck. Thanks for the post btw. Can u give me a pointer on the AS?

            Cheers
            • 3. Re: Context Menu
              Greg Dove Level 4
              Well for the 'onClickOutside' I thought about it some more... you're probably already using the onRollOver and onRollOut inside the menu, and unless it has a border it might be tricky to code the onRollout for the mouseDown listener.

              If your menu is totally contained within a clip called myMenu then you could do something like:

              onClickOutsideListener = {}
              onClickOutsideListener.onMouseDown = function() {
              if (myMenu.hitTest(_root._xmouse,_root._ymouse,true) == false) { //click outside
              trace("onClickOutSide call a function to hide the menu")
              }
              }


              Mouse.addListener(onClickOutsideListener)
              • 4. Context Menu
                Flash Cus Level 1
                Cheers!!!!! Works great...except...

                This is my context menu problem. The initial click after the right click to bring up the menu, makes the menu disappear because of the listner. I put contextMenu._visible = false; instead of the trace. So the initial click seems to hide the menu and i don't know why? Is it to do with the flash context menu?

                Any help?

                Cheers 4 all the work,
                Flash Cus
                • 5. Re: Context Menu
                  Greg Dove Level 4
                  Try putting the line

                  Mouse.addListener(onClickOutsideListener)

                  After the line of code that makes your menu visible in the first place
                  • 6. Re: Context Menu
                    Greg Dove Level 4
                    Oh, and put

                    Mouse.removeListener(this);

                    afer your new line
                    contextMenu._visible = false
                    • 7. Re: Context Menu
                      Flash Cus Level 1
                      Ok further problem...the click outside thing only works the first time now the we've added the

                      Mouse.removeListener(this);

                      Line. Any thoughts?

                      Cheers,
                      Flash Cus
                      • 8. Re: Context Menu
                        Greg Dove Level 4
                        Every time you make the menu visible you have to add the listener back again...like the first time:

                        Mouse.addListener(onClickOutsideListener)
                        • 9. Re: Context Menu
                          Flash Cus Level 1
                          Unfortunately now, whereever i click, the menu disappears. I'll post my AS:

                          onEnterFrame = function() {
                          if(Key.isDown(2)){
                          contextMenu._x = _xmouse;
                          contextMenu._y = _ymouse;
                          contextMenu._visible = true;
                          Mouse.addListener(onClickOutsideListener)
                          }

                          }

                          onClickOutsideListener = {}
                          onClickOutsideListener.onMouseDown = function() {
                          if (contextMenu.hitTest(_root._xmouse,_root._ymouse,true) == false) { //click outside
                          contextMenu._visible = false;
                          Mouse.removeListener(this);
                          }
                          }


                          Mouse.addListener(onClickOutsideListener)

                          //end of AS

                          Can u help even more?

                          Cheers again,
                          Flash Cus
                          • 10. Re: Context Menu
                            Flash Cus Level 1
                            Actually i think that might be an adobe context menu thing because when i right click and choose "settings" then "close" i can click the items on my menu, but not when i just right click and then click on the menu...

                            Any thoughts?

                            Cheers,
                            Flash Cus
                            • 11. Re: Context Menu
                              Greg Dove Level 4
                              I'm not sure, sorry, others may know more. I've only ever added items to the regular context menu itself and not tried to do exactly what I think you're doing.
                              • 12. Re: Context Menu
                                Flash Cus Level 1
                                Ok, i'll have a play with the exe thing and remove the regular menu that way. It doesn't have to be in a browser so i think it'll be ok. Thanks for all your help.

                                Cheers,
                                Flash Cus
                                • 13. Re: Context Menu
                                  Greg Dove Level 4
                                  No probs... its possible in a regular flash windows projector exe to remove the right click menu by editing the 'resources' inside the exe and deleting the menu. I did it a few years back with a program called resource Hacker. I can't remember exactly what I did.
                                  • 14. Re: Context Menu
                                    Flash Cus Level 1
                                    Thought i'd give the latest update. Yes i used SWF Studio to make it an EXE and disabled right click (it was an option). I opened the EXE and it works like a charm.

                                    Cheers for everything,
                                    Flash Cus