4 Replies Latest reply on Oct 26, 2007 1:00 AM by Jimboberelli79

    Multi-state rich symbols

    Jimboberelli79
      I am trying my best to create a library of commonly used buttons that we use for producing UI mockups etc. similar to the included library of Windows and Mac buttons that ship with FIreworks CS3.

      So far I have been able to create a button that scales properly using 9 slice (well, 3 slice in this case), and that changes state depending on what I select in the Symbol Properties inspector and I can edit the label, just like the included buttons. Actually, due to my lack of knowledge on this subject I actually had to bastardize the included XP button. So far, so good.

      However, now I'd like to be able to do 1 final thing. If the 'down' state is selected for the button, I'd like the label to move down by 1px. I have no clue about javascript. Actually, scripting in general. Had a brief chat to a friend who mumbled something about needing to take the x and y values into separate variables and then subtract 1 in y for the down state. That seemed to make sense in my head. The only problem is, I have no clue how to do this.

      If anyone could lend a helping hand, I promise to provide them with a few cool beers if they're ever in Brighton or Tallinn when I am. In the case of Tallinn, it will probably be a very cold beer.

      TIA

      Jim.
        • 1. Re: Multi-state rich symbols
          abeall Level 3
          Unfortunately I don't think you can move things inside a Rich Symbol like that. If that did work, you would "top" property to literally change where the top of the element is.

          But I think what you'll have to do is create two textfields, one which is 1px lower than the other, and toggle their visibilty based on the current state. Something like:
          ...getElementByName("up_txt").visible = state != 'down';
          ...getElementByName("down_txt").visible = state == 'down';
          • 2. Re: Multi-state rich symbols
            Jimboberelli79 Level 1
            Ahh okay.

            Thank you for that. I owe you a drink!

            I've managed to get that working now. Well almost. :D

            I managed to get the over and down states working fine. The text appears to 'move' down by 1px. Strange thing is, in the normal state, the label vanishes.

            Here's the script. Not sure what I've done to break it.

            =======================================
            • 3. Re: Multi-state rich symbols
              abeall Level 3
              The reason it disapears when the state is normal is because right now you are setting the "label" to be visible only if the state is "Over" otherwise it is set to invisible, using this line:
              Widget.GetObjectByName("label").visible = ( enabled && (state=="Over" ));

              And you are setting the "labeldown" to be visible only if the state is "Press" otherwise it is set to invisible, using this line:
              Widget.GetObjectByName("labeldown").visible = ( enabled && (state=="Press" ));

              So, when the state is "Normal" it sets them both to invisible. Basically, you have:
              "Set the 'label' to visible only if the state is Over"
              "Set the 'labeldown' to visible only if the state is Press"

              When what you want is more like:
              "Set the 'label' to visible only if the state is NOT Press"
              "Set the 'labeldown' to visible only if the state is Press"

              So, you can modify the label visible line to this:
              Widget.GetObjectByName("label").visible = ( enabled && (state!="Press"));

              And that way the normal label will always appear if the state is not Press (and it the enabled state is on, too).
              • 4. Re: Multi-state rich symbols
                Jimboberelli79 Level 1
                Seriously,

                I can't tell you how grateful I am. That worked a treat. Thank you for taking the time to explain it all as well instead of just fixing it. It actually makes sense in my head now.

                You rock.

                There's still the offer of a beer or two if ever you're near.