2 Replies Latest reply on Jan 9, 2009 8:41 AM by Marlene

    Understanding Effect Triggers

    Marlene Level 1
      As I have been learning Flex, I stumbled upon a concept I just don't get and hoping someone can help me. The Flex help describes a trigger as an action such as a moue click on a component or a component becoming visible and an effect is defined as a visible change to the target component. Yet in other documentation I have read that changing the visibility causes the trigger hideEffect to play the effect which says to me that hideEffect is the trigger (so is the trigger the hideEffect or the component becoming visible.) Apparently I am confused about the relationship of the following terms: Trigger, Behavior and effect and need more clarification.
        • 1. Re: Understanding Effect Triggers
          rtalton Level 4
          Say my big brother hits me in the arm, and so I get mad and punch him in the face and he cries. Well, several things happened here:
          1) Big brother hits me (event).
          2) I get mad (trigger).
          3) I punch him in the face (by calling a custom effect):
          <mx:Sequence id="myPunchEffect">
          a) My arm performs a "Move" effect.
          b) Brother's crying causes vision to "Blur" effect.
          </mx:sequence>
          So I just did a multiple effect ! But I didn't have to define a trigger. The event could have happened with no response from me. At least, that's what my anger management counselor says. I just have a trigger, I guess. And defining a Sequence effect is sooo easy to do in Flex!

          but more to the point...
          Changing the visible property causes the showEffect or HideEffect trigger to fire. The trigger is "listening" to the visible property and can initiate an effect which you define. Together, they are called a behavior. Behavior is just a way to describe what Flex will do in reaction to a trigger "firing".

          A trigger is actually called by an event, like a click or mouse over. It is not that event itself.

          You can do it all in MXML, and Flex handles the plumbing, like adding a listener.
          This allows you to, for example, add an effect to a trigger all within the component's MXML tag, like: hideEffect="{WipeLeft}". Or armHit="{myPunchEffect}"

          At its simplest, this is just a way to create effects without writing ActionScript, although you can still call an effect defined in AS. Doing it in AS allows more control over the effect if you need more complex animations. But then you could call the AS function with a component's click event just as easily instead of using an effect trigger.
          • 2. Re: Understanding Effect Triggers
            Marlene Level 1
            Thank you so much. I love your analogy! This helps puts thing in perspective.