views:

22

answers:

2

I have skin a button with up, down, over, and disable states. I hope to know if there a code enable a button to keep press (down state) when the user press and hold a specific key link to that button. Something like down_button state.

A: 

I would suggest you inherit from Button and override the KeyUp handler to maintain the "down" state if the Ctrl button is pressed.

Assaf Lavie
how do I inherit?
JohnMax
I suggest you read the user manual: http://help.adobe.com/en_US/flex/using/index.html
Assaf Lavie
A: 
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
    <![CDATA[
        private function rotate():void
        {
            can.rotation +=5; 
        }
    ]]>
</mx:Script>
    <mx:Button autoRepeat="true" buttonDown="rotate()" label="Rotate"/>
    <mx:Canvas id="can" backgroundColor="#CA3859" width="200" height="200" horizontalCenter="0" verticalCenter="0"/>    
</mx:Application>

set autoRepeat=true and use buttonDown event, insated of mouseDown. u'll get it

i hope this was ur need, k, use this example and i have flex3 ryt now, so it's in flex3

hav a gr8 time tc

Ankur sharma

Ankur Sharma
No, the button should keep showing down state, not repeat.
JohnMax
k, you shd use toggleButton, if u want to keep showing th down state, and in that as u have set all four common staets, ryt thats ok, now for a toggle btn, set selected-up-skin, selected-down-skin, selected-over-skin and selected-disabled-skin,
Ankur Sharma
these four which i have mentioned will work for btns like toggle btns, where they'll be left in down state and set the selected-down-skin to down-skin , so you'get wht u might be luking
Ankur Sharma
for btns i dont think that will work, coz as u mouseUp from a btn, the state changes to upstate, so is the upskin, so for selected skins in css
Ankur Sharma