Announcement

Collapse
No announcement yet.

Right Click in Scaleform?

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

    Right Click in Scaleform?

    So what I want is to be able to detect when the player has shot their weapon (any of them). I'm currently doing this by having flash detect a click, and then shoot an fsCommand back into Unreal which triggers what I want.

    The problem is that Scaleform won't detect right clicks! It catches all of the Primary firing just fine, but none of the secondary firing. I even found code that makes Flash detect right clicks same as left ones, but Scaleform still doesn't detect it.

    Is it possible to have Scaleform detect right clicks? Is there an easier way to detect player input than using Scaleform? I'm willing to work in Unrealscript if that has a better solution, I'm just not very adept at it and thought I would start with this method.

    Here's my code in AS2:

    Code:
    #include "InputHelper.as"
    
    import gfx.managers.FocusHandler;
    
    function onMouseDown()
    {
    	fscommand("Command");
    }
    
    //this MUST be set for input to get setup properly
    InputWrapper.focused = true;
    Stage.showMenu = false;
    
    
    //Right click detection that works in Flash only
    
    _root.onEnterFrame = function()
    {
    	if (Key.isDown(2))
    	{
    		if (!this.wasDown)
    		{
    			this.wasDown = true;
    			rightClick();
    		}
    		rightClickDown();
    	}
    else if (this.wasDown)
    	{
    		this.wasDown = false;
    		rightClickUp();
    	}
    }
    function rightClickDown()
    	{
    		fscommand("Command");
    		
    	}
    
    stop();

    #2
    Yeah its probably a better idea to do this in UnrealScript. You should look at overriding the StartAltFire and StopAltFire methods and getting them to call an actionscript function.

    Comment


      #3
      Alright, I found the functions in PlayerController, but I have no idea how to begin writing a function that calls to actionscript. Any suggestions or tutorials?

      Comment


        #4
        Right click is possible with the use of scaleform extensions.

        Actsionscript code:

        Code:
        var mouseListener:Object = new Object; 
        
        mouseListener.onMouseDown = function(button, target) 
        {
                // button 1 equals left click
        	if ( button == 1  )
        	{
                       // do awesom stuff here
                }
        
                // and then of course button two is right click
                else if ( button == 2  )
        	{
                       // do even moar awesom stuff here!!!!!
                }
        }
        
        Mouse.addListener(mouseListener);

        But if you want to to it the other way that you discussed ( calling actionscript function from unreal) you can do that also, you can check the scaleform part in the documentation area for how to do that, it's quite simple actually, but if you need help with that to then let me know.

        Comment


          #5
          I'll give it a try when I have time. I'm swamped with work for other classes at the moment, so I won't be able to test it out for at least few days. Please don't forget about me in the meantime!

          Comment


            #6
            I just tried your code and it worked perfectly! The only modification is that I added a stop(); command at the end to prevent it from triggering in a loop. Thanks a ton!

            Comment


              #7
              Sorry to bother you but with the sidstyler's code, button always return undefined... In the Flash doc, "onMouseDown" take no parameters.
              Right click is possible with the use of scaleform extensions.
              So I think I need to import some GFx extension but I don't know wich one ^^
              I allready have :
              Code:
              _global.gfxExtension = true;
              import flash.external.ExternalInterface;
              What have I missed ?

              Edit : In fact, press the left button returns undefined, pressing the right click don't trigger the mouseListener at all...

              Comment


                #8
                (I have never used this but)

                I would guess it is 0 for left and 1 for right??

                Comment


                  #9
                  You can send any parameter. But in this case, as button in AS accepts pressed mouse button ID, it is necessary to send 1 or 2 (can be 3 for a mouse wheel, but I didn't try)

                  edit: has checked up it, the mouse wheel is defined as the button 3 (1/2 is for left/right mouse button)

                  Comment


                    #10
                    As an aside, the doc for how to call AS from US and US from AS is ..

                    http://udn.epicgames.com/Three/Scale...icalGuide.html

                    Comment


                      #11
                      Originally posted by Bozor View Post
                      Sorry to bother you but with the sidstyler's code, button always return undefined... In the Flash doc, "onMouseDown" take no parameters.
                      So I think I need to import some GFx extension but I don't know wich one ^^
                      I allready have :
                      Code:
                      _global.gfxExtension = true;
                      import flash.external.ExternalInterface;
                      What have I missed ?

                      Edit : In fact, press the left button returns undefined, pressing the right click don't trigger the mouseListener at all...
                      As long as you have all your paths set up and have the _gfxExtension set to true ( like you said you have ) then it should work.

                      Have you gotten anything else to work using scaleform? Maybe you haven't included the paths correctly.

                      Comment


                        #12
                        My AS successfully calls UC script and UC can call some AS function in my project. Everything works perfectly.
                        I just can't retrieve the ID of my button when I press the mouse... It may be a pure AS problem.

                        I'll recheck my AS code immediately.

                        Edit : I simplified my AS code and here it is :

                        Code:
                        _global.gfxExtension = true;
                        import flash.external.ExternalInterface;
                        
                        var mouseListener:Object = new Object(); 
                        
                        mouseListener.onMouseMove = function () {
                            mouseClip._x = _root._xmouse;
                            mouseClip._y = _root._ymouse;
                            _root.consoleTXT.text = "mouseMove";
                        }
                        mouseListener.onMouseDown = function (buttonID){
                            _root.consoleTXT.text = "mouseDown : " + buttonID;
                        }
                        
                        mouseListener.onMouseUp = function(){
                               _root.consoleTXT.text = "mouseUp";
                        }
                        Mouse.addListener(mouseListener);
                        _root.consoleTXT is just a dynamic text field I use to have some return of my AS (or UC with AScalls ^^). Alas, when I press the left button, buttonID is undefined and if I press the the RMB, nothing happens. But, I can read mouseMove, mouseDown : undefined or mouseUp in the other cases.
                        I tested it directly in swf, with FxmediaPlayer and in my UDK level. Everything's perfect (I know, perfection is not of our world but it works ^^) but this.

                        Comment


                          #13
                          your function must be like this:
                          Code:
                          function onMouseDown(buttonID):Void {};
                          and it's not a listener, function calls from u-script manually
                          also, too most and for 'onMouseUp' function - you need call mouseDown and mouseUp functions from u-script and set mouse button id for those functions and you'll get the id in action script

                          Comment


                            #14
                            And I detect the mousePress in UC, then calls my mousePress function in AS with the parameter buttonID given by UC !
                            Ok, I see how I can do this but the sidstyler's code IS in an AS listener and seems to work with Tanoran...

                            Comment


                              #15
                              Just copy/paste following code into a new as 2.0 project or into your own and it should work, I even tested it on a new project myself. And if you want to do stuff on mouseUp then just add that to the mouseListener to and let the function parameters be the same.

                              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();

                              EDIT: I checked your code and it looked correct, the only problem was that the variable buttonID that you sent to the function had the wrong name. It must be called "button" and not "buttonID".

                              Comment

                              Working...
                              X