A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Button changing color on state (on|off)?

  1. #1
    Confounded Flash User
    Join Date
    Apr 2001
    Location
    Chicago
    Posts
    39

    Button changing color on state (on|off)?

    Hi everyone,

    It has been a long time since I did anything in flash - v4 to be exact , so I'm pretty lost again. At any rate, I am working on a touchscreen kiosk project and this is what I need.

    User has a list of buttons, they can select and de-select them (they are choices of services). Essentially I need a button with an ON/OFF state (no hover state). When it is on, it has a certain color and an additional piece of graphic (Like an "ok" checkmark), and when it is off, and it has another color, more subdued.

    This button has to be part of a form, and send its value of on or off on submission (I realize these are 2 separate issues).

    I have been playing with default buttons and looked at a few button tutorials, but nothing seems to help me or point me in the right direction. I think I just want to basically turn a different background for it on and off depending on whether the button is on or off.

    Any help is greatly appreciated!

    Thanks

    Tom

  2. #2
    Grandfather to the stars bigginge's Avatar
    Join Date
    Oct 2003
    Location
    UK
    Posts
    735
    Have a look at this thread
    To dance beneath the diamond sky with one hand waving free
    Love Light Romania Romania Blog

  3. #3
    Confounded Flash User
    Join Date
    Apr 2001
    Location
    Chicago
    Posts
    39
    (EDIT) Ok, I found the other AS panel, so now I see where the buttons call the function using the press event. This is close to what I want, but I want the buttons to hold their state (on or off). So I want the function to be a toggle.

    In JavaScript, I would test the state of the button, and flip its state. I'm assuming I can do that in AS. What I am wondering is if I can do this (psuedocode):

    Code:
    function selectButton(oButton) // send the object instance as argument
    {
        currFrame = oButton.frameNumberCurrently;
        if(currFrame == "2")  // normally for this whole block i'd use a ternary op
       {
           currFrame = 1
       }
       else
       {
           currFrame = 2
       }
       oButton.gotoAndStop(currFrame)
    
      oButton.state = 0 (or 1) // can I do a custom property?
    }
    Is the above doable? That is how I would do it in JS most likely. Then I have to have these buttons communicate with my form...maybe this goes in the AS forum then?

    Tom
    Last edited by tdellaringa; 01-10-2006 at 12:21 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center