Skip to content

Flash Player

Matheus Dias de Souza edited this page Jul 23, 2024 · 1 revision

ActionScript 3, together with Apache Flex-specific languages, MXML and CSS3, has been used in the AIR runtime for developing interactive applications.

Events

AIR applications are built around class inheritance and dynamic dispatches.

The Event meta-data is crucial for Flex components, as they allow to handle events in MXML files.

AS3:

package foo.bar {
    import mx.core.*;

    /**
     * Optional ASDoc comment.
     * @eventType foo.bar.BarEvent.QUX
     */
    [Event(name="qux", type="foo.bar.BarEvent")]
    /**
     * Optional ASDoc comment.
     */
    public class Bar extends UIComponent {
    }
}

Somewhere in a MXML file:

<fb:Bar xmlns:fb="foo.bar.*" qux="trace('Qux')"></fb:Bar>

Event types (the type property of the Event object or subtype) take the convention of using static constants such as XEvent.EVENT_CONSTANT = "eventConstant", rather than directly using a string literal, as opposed to the type inference model in TypeScript.

Data binding

The [Bindable] meta-data is used either at a class definition, at a setter definition, or at a variable definition, to auto dispatch a PropertyChangeEvent event after direct assignment to specific properties.

It takes the forms:

[Bindable]
[Bindable("eventName")]
[Bindable(event="eventName")]

When applied to class, all variables or virtual slots are marked with a Bindable semantic using the event name propertyChange.

When applied to a setter definition or variable definition, the slot is marked with a Bindable semantic using either the default event name propertyChange or the specified event name.

Clone this wiki locally