Announcement

Collapse
No announcement yet.

AS3 problem with unrealScript

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

    AS3 problem with unrealScript

    Code:
    function USCallAS()
    {
        local array<ASValue> args;
        args.Length = 2;
    
        args[0].Type=AS_String;
        args[0].s="Hello,AS3";
        args[1].Type=AS_Number;
        args[1].n=2012;
    
        Invoke("MyASFunction",Args);
    }
    The code above works fine with actionScript 2.
    But no matter I use Invoke or packing unrealscript functions, It does not work with AS3.

    #2
    It's seems right... I think the problem is actionscript side. Can you show the MyASFunction definition ?

    Comment


      #3
      Try

      Invoke("MyASFunction",Args,2);

      Comment


        #4
        Use args.Add(2); instead args.Length = 2;

        Comment


          #5
          A compilation error has occurred. "Error, call to 'Invoke':Function only takes 2 parameter(s)"

          Originally posted by cheesewhisk View Post
          Try

          Invoke("MyASFunction",Args,2);

          Comment


            #6
            My actionscript is

            Code:
            import flash.external.ExternalInterface;
            import scaleform.gfx.*;
            
            scaleform.gfx.Extensions.enabled=true;
            
            //event
            myBtn.addEventListener(MouseEvent.CLICK,onBtnClicked);
            
            function onBtnClicked(e:MouseEvent){
            	ExternalInterface.call("USCallAS");
            }
            
            //be called
            function MyASFunction($params1:String,$params2:Number){
            	myTestText.text=$params1+$params2;
            }

            Comment


              #7
              Why do you use $ ? It's not a php code. Try :
              Code:
              function MyASFunction(params1:String,params2:Number){
              	myTestText.text=params1+params2;
              }

              Comment


                #8
                Confirmed working in Feb 2012 UDK - UnrealScript for use with AS3:

                Code:
                local array<ASValue> args;
                local ASValue asval;
                
                asval.Type = AS_String;
                asval.s = "Matthew";
                args[0] = asval;
                
                asval.Type = AS_Number;
                asval.n = 38;
                args[1] = asval;
                
                GetVariableObject("root").Invoke("MyTestFunction", args);
                AS3:

                Code:
                function MyTestFunction(MyString:String, MyNumber:Number):void
                {
                    //Do Something...
                }
                HOWEVER, the preferred, more efficient method of doing this from UnrealScript would be:

                Code:
                CallASFunction("Matthew", 38);
                
                function CallASFunction(string MyString, int MyNumber)
                {
                    ActionScriptVoid("MyTestFunction");
                }
                This method uses less memory, and can pass GFxObjects, while Invoke cannot.

                Comment


                  #9
                  Really helps, TKS.

                  Comment


                    #10
                    Thanks for posting this Matthew.

                    Where is this code put in UnrealScript? For instance if I want to call this on a GfxMovie I have reference to in a SequenceAction can I use it there?

                    Comment


                      #11
                      Good Tip!

                      Some questions, Is ActionScriptVoid() cast parameters automatically?


                      Code:
                      function CallASFunction(string MyString, int MyNumber)
                      {
                          ActionScriptVoid("MyTestFunction");
                      }
                      
                      function MyTestFunction(MyString:String, MyNumber:Number):void
                      {
                          //Do Something...
                      }
                      
                      example, from Unreal string MyString to AS string MyString.

                      Comment


                        #12
                        This link will explain it to you:

                        http://udn.epicgames.com/Three/Scale...0_UnrealScript

                        Comment


                          #13
                          Is ActionScriptVoid native to scaleform 4.x or is this just the UDK implementation?

                          Comment


                            #14
                            ActionScriptVoid is a UDK Scaleform integration specific function.

                            Comment


                              #15
                              Hmm, that's pretty nice.

                              Two quick things, how does unrealscript know which movie it's calling 'ActionScriptVoid' on? And how do I get a return value?

                              Comment

                              Working...
                              X