views:

1165

answers:

3

I have a .fla file created by our designer and he has created a set of SimpleButtons that I have wired to a video player. Now I need to set the status of a button to "over" if the video that it is associated with is playing.

The button is somewhat sophisticated graphically so its not something that I want to recreate with AS.

Is there some way to just set the myButton.upstate = myButton.overstate while the video is playing? I saw the question here which seems to lead me to believe that SimpleButton is not so amenable to manipulation. I have looked at the example of creating it from scratch with AS3 here but it's going to be a formidable task to recreate these buttons.

I can do that, but I don't want to go off on a tangent unless there is no other way to do it since it's one of those things that "seems" like it ought to be simple.

+1  A: 

If you check out the Flash API, upState and overState (note the camel case here) ARE read/writable. So you may have answered your own question here:

myButton.upstate = myButton.overstate

Give it a test and see if it works. Just make sure you save the actual upState in a temporary variable so you can change it back when the video is not playing.

Whenever I run into the case where I have to programmatically change the state of a Button, I just use the Flash IDE and make a MovieClip with a frame for each state of the button. I know this isn't your ideal solution, but it works.

Jeremy White
This code may not work if the SimpleButton was created in the IDE. Flash is typically a little hard to predict what will happen with code mixed with IDE stuff.
Jeremy White
Yes, I should have been clearer that setting the upState to the overState was the first thing I tried. However I get an "Access of undefined property" error when I do this.
zenWeasel
The issue had to do with at what layer the button was. It was an Instance of a symbol of symbol of a movie of a button. (there were good reasons for that, but still). Once I "flattened" out the structure setting upState to overState did the trick. - Thanks.
zenWeasel
A: 

According to me you should just give linkage to that class and make one generic class which jump on different frames based on frame names [gotoAndStop(frameName)]. This would be far more easier and class can be used with N number of buttons. you just have to give frame names to proper frames.

Bhavesh.Bagadiya
A: 

The upState and overState method does work with the IDE-created SimpleButton.

var defaultUpState:DisplayObject = test_btn.upState;
var overUpState:DisplayObject = test_btn.overState;

test_btn.upState = overUpState;

Download this FLA to see -- http://www.box.net/shared/ll0ho12iqb

Jeremy White