Announcement

Collapse
No announcement yet.

AS>US errors

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

    AS>US errors

    Hey all,

    I'm receiving the following errors from my custom GFxMoviePlayer scripts:

    Code:
    (67) Missing '>' in 'switch expression'
    (37) 'OnResolutionChange' mismatches delegate 'Event Listener'
    (14) 'MyOptions' : Bad command or expression
    Heres the areas its referring to:

    Code:
    (67)
    
    function OnResolutionChange()
    {
    	switch(MyOptions.GetFloat("selectedResolution")) 
    	{
    		case(0):
    			ConsoleCommand("setres 640x480");
    			break;
    		case(1): 
    			ConsoleCommand("setres 800x600");
    			break;
    		case(2): 
    			ConsoleCommand("setres 1024x760");
    			break;
    		case(3): 
    			ConsoleCommand("setres 1152x864");
    			break;
    		case(4):
    			ConsoleCommand("setres 1280x768");
    			break;
    		case(5): 
    			ConsoleCommand("setres 1280x800");
    			break;
    		case(6): 
    			ConsoleCommand("setres 1280x960");
    			break;
    		case(7):
    			ConsoleCommand("setres 1280x1024");
    			break;
    		case(8):
    			ConsoleCommand("setres 1360x768");
    			break;
    		case(9):
    			ConsoleCommand("setres 1366x768");
    			break;
    		case(10):
    			ConsoleCommand("setres 1440x900");
    			break;
    		case(11):
    			ConsoleCommand("setres 1600x900");
    			break;
    		case(12):
    			ConsoleCommand("setres 1600x1200");
    			break;
    		case(13):
    			ConsoleCommand("setres 1680x1050");
    			break;
    		case(14):
    			ConsoleCommand("setres 1920x1080");
    			break;
    		case(15):
    			ConsoleCommand("setres 1920x1200");
    			break;
    		default:
    			break;
    	}
    }
    Code:
    (37)
    
    event bool WidgetInitialized(name WidgetName, name WidgetPath, GFxObject Widget)
    {
          switch(WidgetName)
     {
          case ('bloomBtn'):  // Bloom Widget
                bloomBtn = GFxClikWidget(Widget);
                bloomBtn.AddEventListener('CLIK_select', OnBLOOMBtnChange);
          break;
          
          case ('dofBtn'):  // Depth of Field Widget
                dofBtn = GFxClikWidget(Widget);
                dofBtn.AddEventListener('CLIK_select', OnDOFBtnChange);
          break;
    
          case ('okBtn'):  // OK Button
    	    OKButton = GFxClikWidget(Widget);
    	    OKButton.AddEventListener('ClIK_click', OnResolutionChange);
          break;
     }
     return true;
    }

    Code:
    (14)
    
    var GFxClikWidget StartButton;
    var GFxClikWidget bloomBtn;
    var GFxClikWidget dofBtn;
    var GFxClikWidget OKButton;
    var bool MyOption;
    
    
    function bool Start(optional bool StartPaused = false)
    {
             super.Start();
             Advance(0);
             MyOptions = GetVariableObject("_root.options");
             return true;
    }
    I'm also having trouble with the WidgetInitialized event, in some cases it states that 'case' cannot be used here when I have one case under another as I have shown here.

    Heres the full script:

    Code:
    var GFxClikWidget StartButton;
    var GFxClikWidget bloomBtn;
    var GFxClikWidget dofBtn;
    var GFxClikWidget OKButton;
    var bool MyOption;
    
    
    function bool Start(optional bool StartPaused = false)
    {
             super.Start();
             Advance(0);
             MyOptions = GetVariableObject("_root.options");
             return true;
    }
    
    
    // **  ------- Time for some Widgets!! ------- ** \\
    
    event bool WidgetInitialized(name WidgetName, name WidgetPath, GFxObject Widget)
    {
          switch(WidgetName)
     {
          case ('bloomBtn'):  // Bloom Widget
                bloomBtn = GFxClikWidget(Widget);
                bloomBtn.AddEventListener('CLIK_select', OnBLOOMBtnChange);
          break;
          
          case ('dofBtn'):  // Depth of Field Widget
                dofBtn = GFxClikWidget(Widget);
                dofBtn.AddEventListener('CLIK_select', OnDOFBtnChange);
          break;
    
          case ('okBtn'):  // OK Button
    	    OKButton = GFxClikWidget(Widget);
    	    OKButton.AddEventListener('ClIK_click', OnResolutionChange);
          break;
     }
     return true;
    }
    
    // **  ------- END Time for some Widgets!! END ------- ** \\
    
    
    
    
    // **  ------- Widget Functions ------- ** \\
    
    function OnBLOOMBtnChange(GFxClikWidget.EventData ev) // BLOOM
    {
        MyOption = bloomBtn.GetBool("_selected");
        ConsoleCommand("scale toggle Bloom");
        `log("bloomBtn has been set to: "@MyOption);
    }
    
    function OnDOFBtnChange(GFxClikWidget.EventData ev) // DOF
    {
        MyOption = dofBtn.GetBool("_selected");
        ConsoleCommand("scale toggle DepthOfField");
        `log("dofBtn has been set to: "@MyOption);
    }
    
    
    function OnResolutionChange()
    {
    	switch(MyOptions.GetFloat("selectedResolution")) 
    	{
    		case(0):
    			ConsoleCommand("setres 640x480");
    			break;
    		case(1): 
    			ConsoleCommand("setres 800x600");
    			break;
    		case(2): 
    			ConsoleCommand("setres 1024x760");
    			break;
    		case(3): 
    			ConsoleCommand("setres 1152x864");
    			break;
    		case(4):
    			ConsoleCommand("setres 1280x768");
    			break;
    		case(5): 
    			ConsoleCommand("setres 1280x800");
    			break;
    		case(6): 
    			ConsoleCommand("setres 1280x960");
    			break;
    		case(7):
    			ConsoleCommand("setres 1280x1024");
    			break;
    		case(8):
    			ConsoleCommand("setres 1360x768");
    			break;
    		case(9):
    			ConsoleCommand("setres 1366x768");
    			break;
    		case(10):
    			ConsoleCommand("setres 1440x900");
    			break;
    		case(11):
    			ConsoleCommand("setres 1600x900");
    			break;
    		case(12):
    			ConsoleCommand("setres 1600x1200");
    			break;
    		case(13):
    			ConsoleCommand("setres 1680x1050");
    			break;
    		case(14):
    			ConsoleCommand("setres 1920x1080");
    			break;
    		case(15):
    			ConsoleCommand("setres 1920x1200");
    			break;
    		default:
    			break;
    	}
    }
    
    // **  ------- END Widget Functions END ------- ** \\
    
    
    
    
    
    // ** ------ Switch to dark and light menus ------ ** \\
    
    
    //function to receive External Interface call
    function optionsScreenAnim()
    {
        `log("###### ExternalInterface Call Received #####");
        TriggerRemoteKismetEventoptionsScreen('optionsScreenAnim');
    }
    
    //function to trigger a remote kismet event
    function TriggerRemoteKismetEventoptionsScreen( name EventName )
    {
        local array<SequenceObject> AllSeqEvents;
        local Sequence GameSeq;
        local int i;
    
        GameSeq = GetPC().WorldInfo.GetGameSequence();
        if (GameSeq != None)
        {
            // find any Level Reset events that exist
            GameSeq.FindSeqObjectsByClass(class'SeqEvent_RemoteEvent', true, AllSeqEvents);
    
            // activate them
            for (i = 0; i < AllSeqEvents.Length; i++)
            {
    	    if(SeqEvent_RemoteEvent(AllSeqEvents[i]).EventName == EventName)
    	    SeqEvent_RemoteEvent(AllSeqEvents[i]).CheckActivate(GetPC().WorldInfo, None);
    	}
        }
    }
    
    //function to receive External Interface call
    function mainMenuAnim()
    {
        `log("###### ExternalInterface Call Received #####");
        TriggerRemoteKismetEventmainMenu('mainMenuAnim');
    }
    
    //function to trigger a remote kismet event
    function TriggerRemoteKismetEventmainMenu( name EventName )
    {
        local array<SequenceObject> AllSeqEvents;
        local Sequence GameSeq;
        local int i;
    
        GameSeq = GetPC().WorldInfo.GetGameSequence();
        if (GameSeq != None)
        {
            // find any Level Reset events that exist
            GameSeq.FindSeqObjectsByClass(class'SeqEvent_RemoteEvent', true, AllSeqEvents);
    
            // activate them
            for (i = 0; i < AllSeqEvents.Length; i++)
            {
    	    if(SeqEvent_RemoteEvent(AllSeqEvents[i]).EventName == EventName)
    	    SeqEvent_RemoteEvent(AllSeqEvents[i]).CheckActivate(GetPC().WorldInfo, None);
    	}
        }
    }
    
    
    // ** ------ END Switch to dark and light menus END ------ ** \\
    
    
    
    
    defaultproperties
    {
      WidgetBindings.Add((WidgetName="bloomBtn",WidgetClass=class'GFxClikWidget'))
      WidgetBindings.Add((WidgetName="dofBtn",WidgetClass=class'GFxClikWidget'))
      WidgetBindings.Add((WidgetName="okBtn",WidgetClass=class'GFxClikWidget'))
    }

    Any help would be great!
    Thanks

    #2
    I can tell you right off the bat what's wrong with 2 of them:

    (37) 'OnResolutionChange' mismatches delegate 'Event Listener'

    Code:
    function OnResolutionChange()
    should instead be:

    Code:
    function OnResolutionChange(GFxClikWidget.EventData ev)
    (14) 'MyOptions' : Bad command or expression

    Code:
    var GFxObject MyOptions;
    ... was never declared anywhere as far as I can tell.

    Comment


      #3
      As for the switch statement error:

      Instead of:

      Code:
      switch(MyOptions.GetFloat("selectedResolution")) 
          {
      try:
      Code:
      local int selectedRes;
      selectedRes = MyOptions.GetFloat("selectedResolution");
      
      switch (selectedRes)
          {
      ...

      And you should also include a default case in WidgetInitialized():

      Code:
      default:
          break;

      Comment


        #4
        Ah Matt Doyle! You are the king!
        Thanks a lot man, that worked a treat.

        Ok, so it works now right, but now when I change the resolution to anything it defaults to 640x480 and my mouse cursor disappears. Any idea why this is?

        AS Code:
        Code:
        /* -----------Video & Audio Settings------------------ */
        resolutionOption.dataProvider = ["640x460", "800x600", "1024x768", "1152x864", "1280x768", "1280x800", "1280x960", "1280x1024", "1360x768", "1366x768", "1440x900", "1600x900", "1600x1200", "1680x1050", "1920x1080", "1920x1200"];
        resolutionOption.selectedIndex = (options.selectedResolution) ? options.selectedResolution : 0

        Code:
        /* -----------OK & Cancel Buttons------------------ */
        function ReturnToMainMenu() {
        	options.selectedResolution = resolutionOption.selectedIndex;
        	gotoAndPlay("mainMenu");
        }

        Comment


          #5
          Not sure about that one. The code you listed looks ok. So you select a resolution (say 1280x720) then hit the ok button to go back to the main menu, and when you return to options, it does not have 1280x720 selected?

          Could mean your options object doesn't exist. How is your options object setup? Where does it live?

          Comment


            #6
            When I goto options and select for example 1280x720 and hit OK, the resolution changes to 640x480. But when I go back to options, the option stepper states that i'm still on 1280x720.

            Heres my US:

            Code:
            var GFxClikWidget StartButton;
            var GFxClikWidget bloomBtn;
            var GFxClikWidget dofBtn;
            var GFxClikWidget OKButton;
            var GFxClikWidget vsyncBtn;
            var GFxClikWidget shadowsBtn;
            var GFxClikWidget lightsBtn;
            var GFxClikWidget occBtn;
            var GFxClikWidget envBtn;
            var GFxClikWidget decalsBtn;
            var GFxObject MyOptions;
            var GFxObject MyAdvanced;
            var bool MyOption;
            
            
            
            function bool Start(optional bool StartPaused = false)
            {
                     super.Start();
                     Advance(0);
                     MyOptions = GetVariableObject("_root.options");
                     MyAdvanced = GetVariableObject("_root.advanced");
                     return true;
            }

            Code:
            function OnResolutionChange(GFxClikWidget.EventData ev)
            {
            	local int selectedRes;
            	selectedRes = MyOptions.GetFloat("selectedResolution");
                    switch (selectedRes)
            	{
            		case(0):
            			ConsoleCommand("setres 640x480");
            			break;
            		case(1): 
            			ConsoleCommand("setres 800x600");
            			break;
            		case(2): 
            			ConsoleCommand("setres 1024x760");
            			break;
            		case(3): 
            			ConsoleCommand("setres 1152x864");
            			break;
            		case(4):
            			ConsoleCommand("setres 1280x768");
            			break;
            		case(5): 
            			ConsoleCommand("setres 1280x800");
            			break;
            		case(6): 
            			ConsoleCommand("setres 1280x960");
            			break;
            		case(7):
            			ConsoleCommand("setres 1280x1024");
            			break;
            		case(8):
            			ConsoleCommand("setres 1360x768");
            			break;
            		case(9):
            			ConsoleCommand("setres 1366x768");
            			break;
            		case(10):
            			ConsoleCommand("setres 1440x900");
            			break;
            		case(11):
            			ConsoleCommand("setres 1600x900");
            			break;
            		case(12):
            			ConsoleCommand("setres 1600x1200");
            			break;
            		case(13):
            			ConsoleCommand("setres 1680x1050");
            			break;
            		case(14):
            			ConsoleCommand("setres 1920x1080");
            			break;
            		case(15):
            			ConsoleCommand("setres 1920x1200");
            			break;
            		default:
            			break;
            	}
            }
            Code:
            defaultproperties
            {
              WidgetBindings.Add((WidgetName="bloomBtn",WidgetClass=class'GFxClikWidget'))
              WidgetBindings.Add((WidgetName="dofBtn",WidgetClass=class'GFxClikWidget'))
              WidgetBindings.Add((WidgetName="okBtn",WidgetClass=class'GFxClikWidget'))
              WidgetBindings.Add((WidgetName="vsyncBtn",WidgetClass=class'GFxClikWidget'))
              WidgetBindings.Add((WidgetName="shadowsBtn",WidgetClass=class'GFxClikWidget'))
              WidgetBindings.Add((WidgetName="lightsBtn",WidgetClass=class'GFxClikWidget'))
              WidgetBindings.Add((WidgetName="occBtn",WidgetClass=class'GFxClikWidget'))
              WidgetBindings.Add((WidgetName="envBtn",WidgetClass=class'GFxClikWidget'))
              WidgetBindings.Add((WidgetName="decalsBtn",WidgetClass=class'GFxClikWidget'))
              MovieInfo = SwfMovie'MainMenuQube.MainMenuQube'
            }

            Heres my options objects in a separate Vars layer:

            Code:
            if (!options) {
            	var options:Object = {};
            }
            Thanks

            Comment


              #7
              Ok, I see a potential conflict. The UnrealScript has priority over your ActionScript events:

              1. You change the resolution to 1280x768 (index 4)

              2. You hit the OK button...

              3. UnrealScript immediately fires OnResolutionChange which looks into MyOptions to find the current value of selectedResolution, and set the resolution with setres. As the selectedIndex does not yet exist, it defaults to 0 (640x480).

              4. ActionScript then sets options.selectedResolution to the selectedIndex of resolutionOption. In this case, you chose 1280x768 (index 4).

              5. You return to the options menu, and the resolution is in fact listed as 1280x768, but the actual game resolution is 640x480.

              6. If you change the resolution again to something else, then hit OK, I suspect the game will setres to 1280x768, but list the new resolution when you return to options.

              So, the index is being set AFTER your UnrealScript does its thing.

              One solution would be to move all the ActionScript into UnrealScript, and order it so that the index is set before the setres stuff happens.

              Comment


                #8
                Wow, that's intense.

                How do I solve this issue?

                Comment


                  #9
                  Maybe try something like this:

                  Code:
                  var GFxClikWidget MyResolutionOption;
                  
                  function OnResolutionChange(GFxClikWidget.EventData ev)
                  {
                  	local int selectedRes;
                          MyOptions.SetFloat("selectedResolution", MyResolutionOption.GetFloat("selectedIndex"));
                  	selectedRes = MyOptions.GetFloat("selectedResolution");
                          switch (selectedRes)
                  	{
                  		case(0):
                                  // etc....
                  
                  event bool WidgetInitialized(name WidgetName, name WidgetPath, GFxObject Widget)
                  {
                        switch(WidgetName)
                   {
                        case ('resolutionOption'): 
                              MyResolutionOption = GFxClikWidget(Widget);
                              break;
                        // etc...
                  
                  defaultproperties
                  {
                    WidgetBindings.Add((WidgetName="resolutionOption",WidgetClass=class'GFxClikWidget'))
                  // etc...
                  And thus remove this (red) stuff from your AS:

                  Code:
                  /* -----------OK & Cancel Buttons------------------ */
                  function ReturnToMainMenu() {
                  	options.selectedResolution = resolutionOption.selectedIndex;
                  	gotoAndPlay("mainMenu");
                  }

                  Comment


                    #10
                    Ok, I've tried this and unfortunately its had no affect. The same thing is still happening.

                    I'm really confused about this, any ideas?

                    Comment


                      #11
                      Bump.
                      Anyones help on this would be much appreciated

                      Comment


                        #12
                        Thanks Matt,

                        Your suggestion did work after I tested it in a new scene but will not work in my original menu scene so that must be the problem.

                        Thanks for your solution man, it's much appreciated!

                        Jon

                        Comment


                          #13
                          I found the overall problem.
                          When I put the option stepper on frame 1 it will work correctly and change the resolution as it should.
                          But when I put the option stepper on frame 2 onwards it won't work. Does anyone have any ideas why this could be?

                          Comment


                            #14
                            Could be in how your code/Flash is set up. I'd need to see it all to know for sure. If you want to put your Flash file somewhere that I can get it, I'll give it a look.

                            Comment


                              #15
                              Ok, thanks Matt, I'll send it to you in a private message if that's ok.

                              Comment

                              Working...
                              X