Reputation: 1889
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.
Upvotes: 0
Views: 11142
Reputation: 2829
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
Upvotes: 0
Reputation: 2103
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.
Upvotes: 0
Reputation: 2829
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.
Upvotes: 6