3 Replies Latest reply on Jan 25, 2011 8:23 AM by FTQuest

    skinned ToggleButton

    alexandre.roitman Level 1

      Hello, I have two toggle buttons and I have two mxml files that are their skins.

      In each mxml skin there are 8 states ("up", "down",...)

      When I change state, I would like my toggle buttons to return to the up state, but if I call

       

      togglebutton1.currentState = "up";

      togglebutton2.currentState = "up";

      or

      togglebutton1.currentState = 'up';

      togglebutton2.currentState = 'up';

       

      I receive an error and the application breaks

      (ArgumentError: Undefined state 'up'.

      at mx.core::UIComponent/getState()[E:\dev\hero_private_beta\frameworks\p rojects\framework\src\mx\core\UIComponent.as:10457]

      at  mx.core::UIComponent/findCommonBaseState()[E:\dev\hero_private_beta\f  rameworks\projects\framework\src\mx\core\UIComponent.as:10477]

      at  mx.core::UIComponent/commitCurrentState()[E:\dev\hero_private_beta\fr  ameworks\projects\framework\src\mx\core\UIComponent.as:10252]

      at  mx.core::UIComponent/setCurrentState()[E:\dev\hero_private_beta\frame  works\projects\framework\src\mx\core\UIComponent.as:10199]

      at  mx.core::UIComponent/set  currentState()[E:\dev\hero_private_beta\frameworks\projects\framework  \src\mx\core\UIComponent.as:6340]

      at Main/button_clickHandler()[...src\Main.mxml:111]

      at Main/__button1_click()[...src\Main.mxml:1638])

       

       

      I've also tried to call:

       

      togglebutton1.currentState = "";

      togglebutton2.currentState = "";

      and

      togglebutton1.currentState = null;

      togglebutton2.currentState = null;

       

      but it doesn't work, the buttons don't change their state.


      Can anyone help?

      Thanks a lot

        • 1. Re: skinned ToggleButton
          FTQuest Level 3

          I'm using custom skin for s:ToggleButton and either works for me, i.e. restores the default state:

          toggleButton.selected = false;

          or

          toggleButton.currentState = "";

           

          FTQuest

          • 2. Re: skinned ToggleButton
            alexandre.roitman Level 1

            Yes, i've also tried to change the 'selected' property to false and did not work.


            I've noticed that in my code, all components I change them the 'currentState' have their states declared inside the component mxml and the only case the states are declared inside the skin class is this case of the toggleButton.

             

            Do you think that means something?

            • 3. Re: skinned ToggleButton
              FTQuest Level 3

              Hello there,

               

              It looks like something is not quite right in your code.

              You may get certain hint from looking at the specific line(s) of code in UIComponent that are referenced in the error message.

              The other way to find the culprit is to isolate the element and/or to simplify application's logic.

              Once you come to the point where it works as it's supposed to, start adding your custom functionality one step at a time until it breaks again. And that would be the object to inspect.

              Specifically, in this case I'd temporarily use default skin for your toggle button. If that eliminates the problem, the culprit would be your custom skin. If the problem persists, then something is not right in your application logic; so, simplify it until the toggle button behaves as it should, and then start adding your features ONE AT A TIME.

               

              HTH,

              FTQuest