2 Replies Latest reply on Feb 8, 2010 7:45 AM by vivoices

    How to change state values from Script

    vivoices Level 1

      I did not find the information I need in the Doc available here:

      http://blogs.adobe.com/flexdoc/states/

      so . . .

       

      Example:

      How do I change the value for x.video in action script?
      this["btn1"].x["video"] = 30;
      threw an error: #1056: "Cannot create property video on Number."

       

      <s:states>

        <mx:State name="home" />

        <mx:State name="video" />

        <mx:State name="profile" />

        <mx:State name="contact" />

      </s:states>

      <s:Button id="btn1"
        . . .
        x="0" y="5"
        x.video="0"
        x.profile="81.15"
        x.contact="232" />
      Thanks,
      David
        • 1. Re: How to change state values from Script
          CoreyRLucier Adobe Employee

          The dot notation (e.g. x.video) is an MXML only XML syntax which the compiler turns into a SetProperty "override" for state 'video'. There is no equivalent Actionscript syntax, because for AS only classes you'd generally just override the currentState setter and manage the properties and style values you wish from AS based on the currentState.

           

          For your particular use case may I ask why you need to mix Actionscript with MXML stateful document logic?

           

          -C

          1 person found this helpful
          • 2. Re: How to change state values from Script
            vivoices Level 1

            I am building a dynamic menu setup that has to be recalculated when switching locales.

             

            I checked the relation between states and valuse in debug mode.

            I just push appropriate SetProperty objects into the overrides array of the given state and everything works as expected.

            When recalculating the object positions, I just "reset" the overrides array before repopulating it.

             

            Works fine.

             

            David