views:

1680

answers:

3

Hello,

Anyone know if it is possible via AS3 to change a button to its rollover state when it is not, in reality, rolled over?

Client decided way late in process to ask for some other elements to affect button states. If I had known I would have used movie clips instead of buttons.

Thanks for any advice,

JG

+1  A: 

Dispatch the rollover event manually? Apart from that, I don't see any other way. I am curious though, what sort of requirement(s) would mandate such an oddity.

dirkgently
So we have a primary navigation made up of buttons. When rolled over each cause an MC in another part of the display to pulse.Client has now decided that when a pulsar is rolled over it should pulse and set the button to its over state.If all of this were MCs it could easily be done and most likely the right answer is to make them all MCs or add the pulsars positon to the hit frame of the button though that is an upkeep nightmare if the pulsars get moved.
jerrygarciuh
A: 

Have you tried manually calling gotoAndStop(2) ?

If none of the above solutions work, you'll either have to subclass SimpleButton and link it to your symbols or rebuild in MovieClips

Thanks for the reply. goToAndStop won't work on a button. You'll get1061: Call to a possibly undefined method goToAndStop through a reference with static type flash.display:SimpleButton.May just have to rebuild.
jerrygarciuh
A: 

You can open the properties of any library display object and change it to a button, graphic, or movieclip type. this should allow you to then change the instance type to button and retain rollover abilities while allowing "gotoAndStop" actions on the instance. I'm not totally sure this works, and this thread is old, but if anyone has this same issue it would be worth a shot. This is assuming you aren't creating SimpleButtons dynamically.

Jesse
Hi Jesse,When you change the type it loses button behaviors. Eg a button re-typed to MC will flicker through its rollover states and a two frame MC re-typed to button will suddenly have a rollover state.
jerrygarciuh
That is, if you don't change the properties in the library, and only change them on the stage. I suppose though if you need both, I would either a) configure the event listeners and just set buttonname.buttonMode=true; on the mc, or b)put a hit area above the button, and add the same listeners. I recently had this issue, but ended finding that SimpleButtons are pretty useless unless you're just building simple quick UIs. I suppose the best way to deal with your specific issue would be to re-type them, add some stop();s, and write a few more lines of code. (buttonMode=true, gotoAndStop())
Jesse