Flasher Archive

[Previous] [Next] - [Index] [Thread Index] - [Previous in Thread] [Next in Thread]


Subject: RE: [flasher] Why won't button stay in down state?
From: AndyA
Date: Fri, 16 Mar 2001 23:40:08 -0000

John,

I hardly ever use symbols of the button type. It is far easier to make a
movieclip with 3 frames in which you create your own button. On a separate
layer put an invisible button (the only kind I still use) which is a button
with hit area and no content. You should label the three frames "Up", "Over"
and "Down".

This way you have built a buttonMC which you can also target and control
because it is a movieclip.

Then the options are endless...

In this case:

click on the invisible button and add the code:

on (release) {
buttonMC.gotoAndStop ("Down")
}

and it will stay there.

However, I suspect that what you want to do is to create a state button.
This would be one that you could click on and it would go down. Click on
again and it will come back up etc. In this case, you will need to know what
state it is in at any time. You could do this with a variable state = 0 for
when it is 'off' and state = 1 for when it is 'on'. So you might change the
code to

on (release) {
if (state == 0) {
buttonMC.gotoAndStop ("Down")
buttonMC.state = 1
} else {
buttonMC.gotoAndStop ("Up")
buttonMC.state = 0
}
}

// for the other actions

on (rollover) {
buttonMC.gotoAndStop("Over")
}
on (rollout) {
buttonMC.gotoAndStop("Up")
}

Then click on the buttonMC movieclip and add the action

onClipEvent (load) {
this.state = 0
this.gotoAndStop ("Up")
}

so every time you click the button it looks to see what it's present state
is. If it's up then it goes to down. If it's down then it goes to up. You
can use the buttonMC.state value elsewhere too so that you know which
options are switched on in a series of buttons for example.

I'm doing this off the top of my head, but I think it'll work or at least
give you the idea of how to go about it.

regards

A




[Previous] [Next] - [Index] [Thread Index] - [Next in Thread] [Previous in Thread]