2 Replies Latest reply on Aug 9, 2007 12:30 PM by ntsiii

    Binding problem

      I´m trying to build a form with validation and i´ve been following this great example: http://www.adobe.com/devnet/flex/quickstart/validating_data/src/ValidationUsable/index.htm l

      My only problem is how to move this buttons enabled- part to ActionScript? //

      I´m trying to keep my mxml code free.
        • 1. Re: Binding problem
          Karl_Sigiscar_1971 Level 3

          You can use the BindingUtils classes in order to bind the enabled property to whatever you like.

          // Define data binding
          BindingUtils.bindProperty(model, "formIsValid", submitButton, "enabled");

          Why would you want to keep your MXML "code free".

          Using curly braces for binding is a perfectly right way of doing things.

          As our lead developer says here: if you can do it in MXML, don't do it in ActionScript.

          • 2. Re: Binding problem
            ntsiii Level 3
            "As our lead developer says here: if you can do it in MXML, don't do it in ActionScript" I don't get into religious arguments. ;)

            You can, if you wish, set the enabled property on the button in AS like this:
            submitButton.enabled = formIsValid;

            I personally like to bind in situations like this. With binding, you can add or remove buttons, without having to remember modify some function that sets the button states.