Thursday, October 14, 2010

Flex Tips, Tricks and Fixes


Focus to TextInput

If you have a login screen, and want to set focus to inputText component, you will find that although it has focus, the cursor is not inside the component and you cannot start typing right away. This is only for Application files, and occurs because the swf does not have focus yet.
A fix to this is using ExternalInterface to set focus to the swf:


ExternalInterface.call('function browserFocus(){document.getElementById(\'main\').focus();

Note: Replace "main" with your application name.

Set the buttonMode of Flex TitleWindow Close button/ Access TitleWindow close button

To set the button mode of a TitleWindow close button, use the following code inside the creationComplete method of the TitleWindow file:

var btn:Button = this.mx_internal::closeButton;
btn.buttonMode = true

Note: If you want to write this code in another file, just replace "this" with the name of the TitleWindow instance.


No comments: