Learning Flash: Tab Key

Home Food Mates • Members Tutorials Forum Buy Templates Contact Us 

 


Flash Tutorials

   

Flash Tutorial - User Name and Password - Advanced Features

 

Free Tutorial


Step 3    <<   Previous      Intro   1   2   3   4   5   6     Next   >>       >>   Webwasp Mates

 

Step Three: Setting up the Tab Key

  1. Now add a new button called: Tab
  2. Move the Button: Off Stage
  3. Note: You can add any standard Button from the Common Library: Window > Other Panels > Common Libraries > Buttons

    In my example I have left the Tab button on the stage for demonstration purposes. Normally the Tab button is moved off the stage. It is better that it is invisible.


    My Tab button is visible - but there is no need for this.

  4. Now add the following ActionScript to the Tab button:

    /*  Important Note: This Button should be moved off the stage. I have left it on the stage so that you can see it. Normally it should be off the stage and out of sight. When the user presses the tab button this code is run.  */
    on (keyPress "<Tab>") {

    /*  Checks the value of variable 'a', if it's equal to 0 then it will set the focus on the User Name and change the variable value to 1. Remember that in the layer ActionScript on the first frame, we set the variable 'a' as 1 by default. So when the Tab button is first pressed, the Movie knows that the user name input box already has the cursor/focus in it. */
    if (_root.a == 0) {
    Selection.setFocus("_root.UserName");
    Selection.setSelection(length(/:UserName), length(/:UserName));
    _root.a = 1;
    } else {

    /*  If the User Name has focus, then the code sets the cursor on the Password input box and sets the variable 'a' to 0. So next time it will be picked up by the first if statement above. */
    Selection.setFocus("_root.Password");
    Selection.setSelection(length(/:Password), length(/:Password));
    _root.a = 0;
    }
    }

         

Step 3    <<   Previous      Intro   1   2   3   4   5   6     Next   >>       >>   Webwasp Mates


Webwasp Community: Webwasp Mates & Dates

Why not try out webwasp's new community. Meet new people, find friends in your area: Webwasp Mates & Dates

 Top of Page Home Food Mates Members Tutorials Forum Buy Templates Contact Us 
 All material on this site is protected under international copyright © law. DO NOT reproduce any material from this site without written permission. Please ask as permission is often granted.