11.16. Making a Multipage Form

Problem

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

Solution

Create a custom MultiPageForm class.

Discussion

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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.