11.16. Making a Multipage Form


You want to create a form that spans multiple “pages” rather than being all on one screen.


Create a custom MultiPageForm class.


You can create multipage forms in Flash without having to create a custom class. However, there are several drawbacks to this approach:

  • The most convenient way to do it is to create a form that spans multiple frames. Flash does not automatically remember the values the user selected for form elements across frames. Therefore, you have to programmatically store and repopulate the user’s selections for the form pages when they click back and forth.

  • The process requires a lot of custom coding each time you want to create a new multipage form rather than relying on an existing infrastructure. Basically, it means a lot of duplicated effort and code.

  • It is possible, but not very easy, to leverage the functionality of the Form class.

For these reasons, it is far superior to create a class that handles all the details of working with a multipage form. By creating a MultiPageForm class, you can use and reuse the functionality easily.

The MultiPageForm class has the following characteristics:

  • The class has an array property that contains Form objects. A multipage form is composed, therefore, of multiple forms that are stored in an array property.

  • The class has methods that set the current visible page of the form by making the other pages invisible. All forms are created on the same frame.

Here is the next enhancement ...

Get Actionscript Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.