Adobe Flex 3 Help

Creating a behavior for a component

You use Flex Builder to visually create a behavior for an MXML component.

Note: Though you cannot visually add an effect to an ActionScript component, you can use the editor's Source mode to write the code that adds the effect. For more information, see Applying behaviors in ActionScript in the Adobe Flex 3 Developer Guide.

  1. In the MXML editor's Design mode, click on a component in the design area.
  2. Define a trigger for the effect by selecting a trigger in the Effects category of the Flex Properties view.

    The following naming conventions are used for triggers:

    triggerEffect

    In this convention, trigger is the trigger name. For example, to define a rollover trigger, select the rollOverEffect trigger.

    For a list of triggers you can use, see Available triggers in the Adobe Flex 3 Developer Guide.

  3. Associate an effect with the trigger by entering the name of the effect in the field next to the trigger name.

    For example, for a Label component you could enter WipeRight as the effect for the showEffect property. In a browser, the Label component's text becomes visible as if it were being wiped from left to right.

    Label component property

    For a list of effects you can use, see Available effects in the Adobe Flex 3 Developer Guide.

  4. To customize the effect, you need to specify effect properties in the code.

    For example, you can specify how long a wipe lasts by entering the value in milliseconds in the duration property of the component, as shown in the following example:

    <mx:Button id="myButton" mouseDownEffect="WipeLeft" duration="2000"/>
    
    

    For more information, see Working with effects in the Adobe Flex 3 Developer Guide.

  5. If you want the current component to trigger the effect, you are finished creating the behavior.

    If you want another component to trigger the effect, you must write and insert an ActionScript function that triggers the effect from the other component. For more information, see Applying behaviors in ActionScript in the Adobe Flex 3 Developer Guide.