Announcement

Collapse
No announcement yet.

problems updating my checkbox to correct value

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

    problems updating my checkbox to correct value

    Hello,

    I'm implementing a checkbox on a menu, following this tutorial by Matt Doyle: http://forums.epicgames.com/showthread.php?t=745035

    I got everything to work perfectly, the checkbox executes the command I want whenever I click it (I've set it to enable/disable AO, which it does every time I click it).

    I also wrote a function to store a "status" variable inside a file, so whenever I enable AO, that function will store a value of "1" inside the file, and you know the rest.

    Anyway, I get to the part when I want the check box to update the "checked" status based on the AO setting. This is where the stored "status" variable comes in. I've set it so that every time it loads the menu, it will read the "status" variable and use that for the "SetMyCheckbox(true/false)" function described in the tutorial I linked.

    However.... it doesn't do the trick -_-

    I'm using the Scaleform CLIK_tutorial_skinned flash file, nothing modified in the options AS code save for that extra function, and for testing I'm using the "bloomBtn" Bloom checkbox.

    Anything I've missed there?

    Thanks

    #2
    I had some problems with this also, are you sure that you:

    1. Has created the options array in frame 1 of the timeline and that it can be accessed allright in the options menu?
    2. Has checked the spelling of the variable containing the checkbox on/off function.
    3. If you would please post your as2 code from flash, maybe I would be able to spot something more.

    Comment


      #3
      Hello, well since I am using the tutorial file it already had the array on frame 1. I tried it with and without that since I'm testing it by either setting the options and then OK, as well as restarting the game and going directly to the options to see if it retains the set value.

      I also checked the spelling. I do copypaste of variable and button names most of the times to prevent any spelling errors.

      This is my AS code:

      Code:
      // This frame will be the options screen
      
      import gfx.controls.ButtonGroup;
      
      //
      // The following sets up the difficulty option stepper data
      //
      difficultyOption.dataProvider = ["Easy", "Medium", "Hard", "Insane"];
      
      // Assign the RadioButton group via code since this screen exists
      // in timeline. Automatically generated groups (such as those created
      // when the inspectable 'group' property of the RadioButton is set)
      // cannot persist when the timeline frame changes.
      var aaGroup:ButtonGroup = new ButtonGroup();
      edgeaaBtn.group = hwaaBtn.group = aaGroup;
      
      //
      // We will listen to the AA checkbox's click event and enable/disable the AA radio
      // buttons appropriately.
      //
      function EnableAARadioButtons() {
      	edgeaaBtn.disabled = hwaaBtn.disabled = !aaBtn.selected;
      }
      aaBtn.addEventListener("click", this, "EnableAARadioButtons");
      
      //
      // Set initial state of options
      //
      difficultyOption.selectedIndex = (options.selectedDifficulty) ? options.selectedDifficulty : 0;
      bloomBtn.selected = options.bloom;
      aaBtn.selected = options.aa;
      edgeaaBtn.disabled = hwaaBtn.disabled = !aaBtn.selected;
      edgeaaBtn.selected = (options.edgeaa) ? options.edgeaa : true;
      hwaaBtn.selected = (options.hwaa) ? options.hwaa : false;
      soundSlider.value = (options.soundVolume) ? options.soundVolume : 0;
      
      //
      // Go back to the main menu - save option changes
      // Occurrs on OK button press
      //
      function ReturnToMainMenu() {
      //	options.selectedDifficulty = difficultyOption.selectedIndex;
      //	options.bloom = bloomBtn.selected;
      //	options.aa = aaBtn.selected;
      //	options.edgeaa = edgaaaBtn.selected;
      //	options.hwaa = hwaaBtn.selected;
      //	options.soundVolume = soundSlider.value;
      	gotoAndPlay("mainMenu");
      }
      
      //
      // Go back to the main menu - don't save option changes
      // Occurrs on Cancel button press
      //
      function CancelToMainMenu() {
      	gotoAndPlay("mainMenu");
      }
      
      okBtn.addEventListener("click", this, "ReturnToMainMenu");
      cancelBtn.addEventListener("click", this, "CancelToMainMenu");
      
      //
      // Set initial focus
      //
      cancelBtn.focused = true;
      
      
      // ze functions that update everything (these are the ones I used to update according to tutorial
      
      //ze bloom checkbox
      //function SetAoCheckBox(selected:Boolean) 
      //{
      //    bloomBtn.selected = selected;
      //}
      function SetAoCheckBox() 
      {
          bloomBtn.selected = (options.bloom) ? options.bloom : true;
      }
      
      function UnsetAoCheckBox() 
      {
          bloomBtn.selected = (options.bloom) ? options.bloom : false;
      }
      
      
      stop();
      and these are the relevant parts of the main menu code:

      when you press the options button
      Code:
      function OnOptionsButtonPress(GFxClikWidget.EventData ev)
      {
          // functions here meant to update the states of the options menu :)
          LoadAoVariable();
      }
      the loadAOvariable mentioned above:
      Code:
      // Load AO BOOL value
      function LoadAoVariable()
      {
        local string AoVarName;
        local int myloadedao;
      
      
             `log("options menu called...");
      
      
        AoVarName = "MyAo";
        SaveSystem = class'UltimateSaveSystem'.static.GetSaveSystem();
      
        SaveSystem.ULoadBoolList(CurrentSaveName);
        SaveSystem.UExportBool(AoVarName, myloadedao);
      
        if (myloadedao == 0)
           {
      //       SetAoCheckBox(false); // true or false
             UnsetAoCheckBox();
           }
        if (myloadedao == 1)
           {
             SetAoCheckBox();
      //       SetAoCheckBox(true); // true or false
      
      
           }
      
      }
      and the ones that should supposedly update the checkbox...
      Code:
      // update the checkbox status in the menu
      function SetAoCheckBox()
      //function SetAoCheckBox(bool b)
      {
          ActionScriptVoid("SetAoCheckBox"); // passes the boolean value stored in 'b' to the AS function SetMyCheckBox
          `log("box set to selected 1");
      }
      
      function UnsetAoCheckBox()
      {
          ActionScriptVoid("UnsetAoCheckBox"); // passes the boolean value stored in 'b' to the AS function SetMyCheckBox
          `log("box set to unselected 0");
      }
      I'm guessing that *MAYBE* the update function being performed pretty much the same time as the menu is called is causing it not to find what to update? So I tried to delay the setaocheckbox and unsetaocheckbox functions with a SetTimer, but for some reason the SetTimer being called inside the mainmenuclass (extending gfxmovie) causes the functions not to be run at all :-/

      Comment

      Working...
      X