Tab Ordering Forms
       by Sharif aka the Reefster : 11 July 2004

If you're viewing this tutorial, it's probably because you're one of those flashers that are trying to use the tab key to only focus on a certain type of object in flash.



[ Click Name and use the tab key as you type ]


In this case, we're going to make the tab focus on textboxes. The problem here is that when the tab key is pressed to scroll through the form inputs, it can sometimes scroll through other objects like buttons too, which can be annoying.

Note

When you press tab the 4th time, notice it won't go back to the name input box. That's because tab also works for HTML, so it will scroll through the navigation bar on the left of this tutorial. But when you make your swf and publish it as a website with no HTML elements, it will work perfectly.


Here Is How:
  1. Open up a new flash document and use the text tool to create 3 input textboxes. Give the first one the instance name of name, the second location and the third age for the example.
     
    Textbox Settings


     
  2. Now you can make some text next to the inputs saying name, location, etc.
  3. In a new layer, open up the actions panel (f9) and insert this into it:
     
    name.tabIndex = 1;
    location.tabIndex = 2;
    age.tabIndex = 3;

    Explanation
    This states that name is the textboxes instance name. tabIndex = 1; states that it is the first one it will focus into when the tab key is pressed. You can now control which one goes after which.
  4. Test the movie.
That's it! All you did was create the boxes, name them and add the script. Now when you create a form with lots of objects such as buttons and whatnot, you can have the tab key work specifically for your text boxes.

If you have any questions, feel free to post on the forums.

Sharif
the Reefster



SUPPORTERS:

kirupa.com's fast and reliable hosting provided by Media Temple.