# Providing submit buttons in Flash

ID: FLASH4

Technology: flash

Type: Technique

## When to Use

- Adobe Flash Professional version MX and higher
- Adobe Flex

## Description

The objective of this technique is to use submit buttons to allow users to take actions that cause changes of context rather than allowing changes in context to occur when the value or state of a non-submit button control is modified. The intended use of a submit button in this technique is to generate an HTTP request that submits data entered in a form or to perform an action that triggers a change in context, so it is an appropriate control to use to initiate this change.

## Examples

### ActionScript 3 combobox with submit button

This is a basic ActionScript 3 example of a combobox component with a submit button to redirect the user to a different resource.

    import fl.accessibility.ComboBoxAccImpl;
    import flash.net.navigateToURL;
    import flash.net.URLRequest;
    ComboBoxAccImpl.enableAccessibility();
    state_submit.addEventListener(MouseEvent.CLICK, submitHandler);
    function submitHandler(e) {
      var url: URLRequest = new URLRequest("http://www.wikipedia.org/wiki/" +
        state_combo.selectedLabel);
      navigateToURL(url, "_self");
    }

### ActionScript 2 combobox with submit button

This is a basic ActionScript 2 example of a combobox component with a submit button to redirect the user to a different resource - the same example as in example 1 except in ActionScript 2:

    import fl.accessibility.ComboBoxAccImpl;
    ComboBoxAccImpl.enableAccessibility();
    state_submit.addEventListener("click", submitHandler);
    function submitHandler(e) {
      getURL("http://www.wikipedia.org/wiki/" + state_combo.selectedLabel, "_self");
    }

## Tests

### Procedure

1. Find all interactive control instances (that are not submit buttons) in the flash movie that can initiate a change of context, e.g. a combobox, radio button or checkbox.
2. For each instance, confirm that the event handler(s) responsible for the change of context are not associated with the controls themselves, but with a separate button instead.

### Expected Results

#2 is true

## Related Techniques

- G80