1 person found this helpful
Nope. That is the point of not being able to control the state of a button with code: there isn't a code that lets you control its state.
What it seems you are after is what I would call a toggle button--like a light switch it looks different when it has been "flipped."
You will need to either use a movieclip and add code to change its appearance or two different simple buttons and toggle the visibility of the two different buttons. I reccomend the movieclip approach.
ah.. .but why dont they want us to access the button with code? would make things easier.
Thanks though Im gonna use the adding another thing and playing with visibility since I already have the buttons made.
Buttons in Flash go back a long long ways. In early versions you couldn't even access buttons by name and they were really twitch and odd. Most serious Flash users dropped them and developed buttons based on movieclips.
I'm not really sure why they didn't fix them when they updated the to AS3, but there you go! I'm guessing it has something to do with the idea of keeping them simple.
As for the visibility, be sure that you are setting the visible property and not the alpha. A button with zero alpha will sill be rolloverable, clickable, etc.
Thanks for the answer, good to know.
Yeah the buttons are done, used the visible property in the code, TY!
1 person found this helpful
You can control the states of SimpleButton objects with AS3. If you look at the properties you will see that the button has four states that you can assign... upState, overState, downState, and hitTestState. Each of these states are DisplayObjects. You can reassign a state to assume another DisplayObject using code. So if you wished to have a button retain the downState when it is clicked and moved away from, you can assign its upState to be its downState...
btn.upState = btn.downState;
and it will happen. But if you want to restore the upState to what it originally was, then you need to store that somewhere so that it can be re-assigned. If it's only the one state, the hitTestState can come in handy for that. But when you start wanting to have a variety of controls, it can get a little juggly.
I did see those properties in the docs but since it said it takes a displayObject I didnt really pay attention to them.
Nice way of making them work though, I didnt think of passing one state to another like that, I might have used that method and just have a temp button to store the original up state of the button thats pressed.
Thanks for the tip
Thanks for pointing that out Ned. I didn't know you could do that.
It is similar to how some of the Components worked in AS2. I haven't tried to use it with SimpleButton, but I did muck with it a bit in AS2 and it did get pretty complex and confusing if I was trying to do very much.
I'll have to give it a whirl and see if it is any better than I remember.