all groups > flash (macromedia) > december 2006 >
You're in the

flash (macromedia)

group:

Can someone check this code?


Can someone check this code? pecktron2000
12/4/2006 9:17:24 PM
flash (macromedia):
What I am trying to achieve is an "active" button state. I have six buttons.
When one is clicked, i need it to change to a color which denotes that it is
the active button.

someone provided me with this code, but I can't seem to get it to work. I
followed the directions precisely.
The directions were as follows:


One thing I think you could do is create another invisible layer of buttons
above all your other buttons. You could make them all invisible, unless a
button is clicked.

Let's say your original layer of buttons is called a_but, b_but, and c_but.

Then you could have another invisible layer of buttons called invA_but,
invB_but, and invC_but. This layer of buttons would each be the color you want
displayed while the button is selected. The code would look something like-

invA_but._visible=false;
invB_but._visible=false;
invC_but._visible=false;

a_but.onRelease=function(){
invA_but._visible=true;
invB_but._visible=false;
invB_but._visible=false;
}

b_but.onRelease=function(){
invA_but._visible=false;
invB_but._visible=true;
invC_but._visible=false;
}

c_but.onRelease=function(){
invA_but._visible=false;
invB_but._visible=false;
invC_but._visible=true
}

Re: Can someone check this code? Nickels55
12/4/2006 9:40:01 PM
invA_but, invB_but, and invC_but refer to instance names for your buttons, not
layer names as suggested in the description. It should work if you have the
instance names for the buttons right. I would probably add code to make the
nomal state invisible instead of just having the active button covering the
inactive one. EX:

a_but.onRelease=function(){
invA_but._visible=true; //show the buttons active state
a_but._visible = false; //hide the off state of the button
invB_but._visible=false; //hides the active state of button b
invC_but._visible=false; //hides the active state of button c
}

Re: Can someone check this code? pecktron2000
12/4/2006 9:53:43 PM
Should I attach this code to the button or put it in my actions layer?
I keep getting this error message:
**Error** Scene=Scene 3, layer=BTN Logo Active, frame=76:Line 1: Statement
must appear within on handler
a_but.onRelease=function(){

Total ActionScript Errors: 1 Reported Errors: 1

Re: Can someone check this code? Nickels55
12/4/2006 11:18:47 PM
Re: Can someone check this code? pecktron2000
12/5/2006 12:25:17 AM
What does that error message mean? I keep getting it each time.

Re: Can someone check this code? pecktron2000
12/5/2006 12:34:05 AM
ok now im not getting the message
but my button states won't change
i guess i will have to rethink this one
im pretty new at actionscripting

flash should have an active state option when creating buttons (also a visited
state!)
thanks though!


(and why is adobe's site so damn slow?????)
AddThis Social Bookmark Button