tags:

views:

317

answers:

2

Hi all

I am using Flex3.0. in this i am craeting a custom component for an Alert.and for that alert i am applying styles. but when i opening the alert through the application i want to set focus on Alert button.means when i press enter button there are two buttons in alert YES and NO.i need to focus on YES button. any one help me if any reffer url also please provide me

Thanks, Praveen

+1  A: 

From the APIDocs:

show(text:String = "", title:String = "", flags:uint = 0x4, parent:Sprite = null, closeHandler:Function = null, iconClass:Class = null, defaultButtonFlag:uint = 0x4):Alert [static] Static method that pops up the Alert control.

In a regular Alert.show call this means you can specify the last argument as Alert.YES to make it the default selection. With a custom component, you can call setFocus() on the particular element within your custom Alert component that you want to select (i.e.: in call setFocus() within the custom Alert component's creationComplete event).

So a sample implementation of a YES/NO Alert box would be (split code over two lines to avoid scroll bars):

Alert.show("sample text","sample title",
            Alert.YES|Alert.NO,null,null,null,Alert.YES);

Hope this helps.

raptors
Thanks for Your Answer
praveen
No problem. Some reference links which you also asked about (and you probably might know of already) are http://livedocs.adobe.com/flex/3/langref/ (Flex 3 Language Reference) and http://learn.adobe.com/wiki/display/Flex/Getting+Started (Lots of tutorials and examples).
raptors
A: 

you need to set the defaultButtonFlag: (its the last parameter)

Alert.show('alert', 'alert', Alert.NO|Alert.YES, this, null, null, Alert.NO);
Shua