Announcement

Collapse
No announcement yet.

Right Click in Scaleform?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #16
    I will not understand, what for to you listeners if function is called from u-script directly?

    Comment


      #17
      You certainly are right srv. Furthermore a listener is a good resources eater (works as an "enterFrame"...) but it drive me crazy to not have this simple thing working.
      And this reveals a problem in my code : I copy paste the sidstyler's chubk in a new project and it works in GFxmediaPlayer but the very same code doesn't with my FLA file...

      Comment


        #18
        show your uc code, there can be a problem in it

        Comment


          #19
          I restart Flash, redo the copy paste and now, it's working... I compare yours and mine code and can't find the difference... There's something really odd here.

          Nevermind... I will do the srv trick (calling AS from UC when mouseDown), it will be more light for the resources.
          Thanks to you all.

          Comment


            #20
            No Key.isDown(2) state change in UDK on right mouse click

            I am writing a game that wants to handle all input in flash/scaleform, but with some functions (notably right-mouse clicks) to be handled in uscript. I've got most of it working via the usual suspects for onMouseMove() and bCaptureInput = true.

            In the Actionscript side I have a keyListener with a switch(Key.getCode()) statement to handle keystrokes, and have a mouseListener to pick up the left click via onMouseUp and Down. However there seems to be no way of tracking the right mouse click EXCEPT via a method that passes it from UDK to Flash, which can't be done in this case because bCaptureInput is true. Monitoring Key.isDown(2) within an onClipEvent works in Flash but not in UDK for some reason (is always false regardless of button states). Is there something I need to include to get this to work (other than the already included _global.gfxExtensions = true?

            The primary reason for not wanting the information to go from UDK to Scaleform is that I'd rather not mess around with DefaultInput.ini, and I want all keyboard input to be configurable by the user from within the game itself (rather than from something part of the original UDK menu system).

            Help?

            EDIT: The other reason I went with keytrapping in actionscript was to allow me to trap for the alt key by itself, rather than some combination with other keys.

            Comment


              #21
              Thank you sidstyler for the code. It works great for me

              Comment


                #22
                Hey guys, sorry for bringing up old thread, but I feel I should post here. I'm pretty new at Unreal Script and Action Script, but I'm slowly getting where I want to be. Here is my problem: I want to use the right-click functionality from this code (thanks alot, sidstyler!) :
                Code:
                import flash.external.ExternalInterface;
                _global.gfxExtensions = true;
                
                
                var mouseListener:Object = new Object; 
                
                mouseListener.onMouseDown = function(button, target) 
                {
                        // button 1 equals left click
                	if ( button == 1  )
                	{
                		trace( "mb1" ); 
                         }
                
                        // and then of course button two is right click
                        else if ( button == 2  )
                	{
                                trace( "mb2" ); 
                        }
                }
                
                Mouse.addListener(mouseListener);
                
                stop();
                But when I put it in the first frame of the Actions layer, the function is always active. The thing is, I want every button on my menu to react on right-clicks, but with this code, I can assign only one action to the right-click. My question is: Is it possible to make this code valid only for my buttons, and not for the whole stage?

                I mean, when I right click on my stage, the actions

                Code:
                // button 1 equals left click
                	if ( button == 1  )
                	{
                		trace( "mb1" ); 
                         }
                
                        // and then of course button two is right click
                        else if ( button == 2  )
                	{
                                trace( "mb2" ); 
                        }
                to be executed only when I am pressing a button?

                I really hope I managed to explain myself, as I said I'm fairly new regarding UScript and AS. I'll happily read any link you give me, because at the moment I can't find anything suitable in the explanations about ActionScript in the Help file for Flash CS5. Thanks for your answers in advance.

                Comment


                  #23
                  Hello Spellweaverbg.
                  I think that your problem is an AS problem.
                  In Flash, you can easily set a test in your "if ( button == 2 )" statement wich verify where your mouse is. You can use a movieClip.hitTest () eg.

                  Comment


                    #24
                    Originally posted by Bozor View Post
                    Hello Spellweaverbg.
                    I think that your problem is an AS problem.
                    In Flash, you can easily set a test in your "if ( button == 2 )" statement wich verify where your mouse is. You can use a movieClip.hitTest () eg.
                    A thousand thanks Bozor Yesterday night I lost maybe 3 or 4 hours in vain trying to implement the MovieClip.HitTest() into the code of my cursor, since I thought that the clash of the cursor with the buttons should trigger the events. This morning when I woke up and read again your post it struck me that I completely misread it. After only couple of minutes I had flawlessly working recognition of the right clicks. Here is the code, in case somebody wonders in which way it was achieved.

                    I had two buttons: one called "Start" (with instance name "Start_btn") and other called "Restore Game" (with instance name "Restore_btn"). "Cursor_mc" is the instance name of my custom cursor movieclip.
                    Code:
                    import flash.external.ExternalInterface;
                    _global.gfxExtensions = true;
                    
                    var mouseListener:Object = new Object();
                    mouseListener.onMouseUp = function(button, target)
                    {
                    	if (button == 2)
                    	{
                    		if (_root.Cursor_mc.hitTest(_root.Start_btn))
                    		{
                    			trace("Start Right Button");
                    		}
                    		if (_root.Cursor_mc.hitTest(_root.Restore_btn))
                    		{
                    			trace("Restore Right Button");
                    		}
                    	}
                    };
                    Mouse.addListener(mouseListener);
                    The conclusion is - never write code when it's late at night, you can make absolutely obvious mistakes.

                    Anyway, thanks alot again, you have been tremendous help in my project. I lost 4 or 5 days trying to get around this road block.

                    Comment


                      #25
                      Originally posted by Spellweaverbg View Post
                      This morning when I woke up and read again your post it struck me that I completely misread it.
                      My English Spoken May also be a bit guilty...
                      Happy to help you ^^.

                      Comment


                        #26
                        As another aside, you should probably try to keep your scaleform side thin, that seems to be a primary benefit to frame rates and responsiveness. You can use the FilterButtonInput event to handle triggering of your right click menu.

                        Code:
                        event bool FilterButtonInput(int ControllerId,
                        	name ButtonName,
                        	EInputEvent InputEvent)
                        {
                            if (ButtonName == 'RightMouseButton')
                            { ... }
                        }

                        Comment


                          #27
                          Originally posted by Bob_Gneu View Post
                          As another aside, you should probably try to keep your scaleform side thin, that seems to be a primary benefit to frame rates and responsiveness. You can use the FilterButtonInput event to handle triggering of your right click menu.

                          Code:
                          event bool FilterButtonInput(int ControllerId,
                          	name ButtonName,
                          	EInputEvent InputEvent)
                          {
                              if (ButtonName == 'RightMouseButton')
                              { ... }
                          }
                          Thanks for your answer, Bob, It is certainly good to have options when trying to tackle certain problem, cheers

                          Comment


                            #28
                            Any way to do this in Actionscript3, because the posted code does not work in Actionscript3 and there is no analog way to register "button" on an actionscript3 eventlistener.

                            Comment


                              #29
                              Bump on getting the right mouse button to register on AS3.

                              Comment


                                #30
                                Well we gave up on actionscript getting left or right mouse, so we now ask Unreal if it was left or right click this frame:

                                Code:
                                this.addEventListener(MouseEvent.MOUSE_DOWN, mouseIsDown);
                                
                                private function mouseIsDown(e:Event) // could be left and could be right
                                {
                                  if(ExternalInterface.call("IsRightMouseDown")) 
                                  {
                                     // do right mouse code
                                  } 
                                  else
                                  {
                                    // do left mouse code 
                                  }
                                }

                                Comment

                                Working...
                                X