Search code examples
flashactionscriptactionscript-2visible

ActionScript 2.0 - Button hover visible false two other buttons


I'm making something on Flash with ActionScript 2.0 script. I have a movie clip named clip. Inside I have another movie clip named starters. In starters I have three different buttons which all have a hover layer in them. What I want those button to do: I want them when I hover on each button to make the other ones be visible = false. Then when I hover out to be back at normal.

the buttons are named btn1, btn2, btn3.

Thank you in advance!


Solution

  • I'm afraid that I am unfamiliar with Actionscript 2. However, with a little research, I was able to decipher that strange language and come up with this.

    Put this into your action panel within the layer that contains clip. We'll not be placing any code on objects today!

    clip.starters.btn1.onRollOver = hideButtons
    clip.starters.btn2.onRollOver = hideButtons
    clip.starters.btn3.onRollOver = hideButtons
    //set the onRollOver function of each button to function hideButtons()
    
    clip.starters.btn1.onRollOut = showButtons
    clip.starters.btn2.onRollOut = showButtons
    clip.starters.btn3.onRollOut = showButtons
    //set the onRollOut function of each button to function showButtons()
    
    function hideButtons() {
        //repeat the action for all items in "starter"
        for (var Item in clip.starters) {
            //make all items invisible
            clip.starters[Item]._visible = false
        }
        //make the caller of  hideButtons() visible
        this._visible = true
    }
    
    function showButtons() {
        //repeat the action for all items in "starter"
        for (var Item in clip.starters) {
            //make everything visible
            clip.starters[Item]._visible = true
        }
    }
    

    Hope that works for ya. If you want my advice, learn Actionscript 3.0! It's more widely used and has much cleaner code.

    Good luck!