FocusEvent.MOUSE_FOCUS_CHANGE : Focus Event « Development « Flash / Flex / ActionScript

Flash / Flex / ActionScript
1. Animation
2. Array
3. Class
4. Data Type
5. Development
6. Function
7. Graphics
8. Language
9. Network
10. Regular Expressions
11. Statement
12. String
13. TextField
14. XML
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Flash / Flex / ActionScript » Development » Focus Event 
FocusEvent.MOUSE_FOCUS_CHANGE
 

package
{
    import flash.display.Sprite;
    import flash.text.TextField;
    import flash.events.FocusEvent;

    public class Main extends Sprite
    {
        public function Main()
        {
            var tf1:TextField = new TextField();
            tf1.type = "input";
            tf1.height = 20;
            tf1.width = 100;
            tf1.border = true;

            addChild(tf1);
            tf1.addEventListener(FocusEvent.MOUSE_FOCUS_CHANGE, checkFocus);

            var tf2:TextField = new TextField();
            tf2.type = "input";
            tf2.height = 20;
            tf2.width = 100;
            tf2.border = true;
            addChild(tf2);
            tf2.x = 200;
        }

        private function checkFocus(focusEvent:FocusEvent):void
        {
            if ((focusEvent.target as TextField).text == "")
            {
                focusEvent.preventDefault();
            }
        }
    }
}

        
Related examples in the same category
1. FocusEvent.KEY_FOCUS_CHANGE
2. Handling focus events globally
3. Handling focus events for a particular object
4. Focus and Tab Events
5. focusIn and focusOut Events
w_w__w___.___ja___v__a___2___s__.__c___o_m | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.