Flex Shake Effect

This fancy Flex effect will shake a target side-to-side, up-and-down or some combination of both.  The effect extends Effect and provides settings to control the number of shakes, shake distance and direction.

Check out the demo.

Download the demo.

Download the library

Read the docs.

16 Comments

  1. alice says:

    Why don’t you share your code ??

  2. Sean says:

    @alice

    Two reasons. First, I would hope I’ve done a good enough job with the demos and docs that you should be able to download the provided SWC and effectively make use of the effect.

    The second is that I simply forgot to post the source.

    Get it here: http://seanmonahan.org/projects/flex-library/

  3. Oliv says:

    Hi and thanks for your component.
    I got a HUGE problem by using it.
    I set up a quick example with a button and a textfield. If I click many times on the button while the shake effect isn’t ended, the text input changes his position and disapears sometimes …

    Any ideas?

    Thanks

  4. Sean says:

    Is there any chance I can get a link to a demo of this issue?

    Without looking at a demo it seems you could probably get around this issue by disabling the button for the duration of the shake.

  5. Anusheel Verma says:

    I loved it :)

  6. Daniel Gianni says:

    That’s fantastic! But I can not do work with ViewStack ….

  7. Sean says:

    There are so many things that could be preventing this from working with ViewStack. Could you post a demo with source view so I can take a look?

  8. Tammam says:

    Hi Sean,

    First of all, thanks for your work it’s been very helpful

    I’m having the same issue as Oliv it’s hard for me to give you a link as my project isn’t online yet. But practically if I click on the button while it’s in motion it triggers another shake event and my button disappeared from screen. You suggested disabling the button while playing the effect. Do you mean something like:
    myButton.enabled = false;
    buttonShaker.play();
    myButton.enabled = true; ??

    For some reason that didn’t work for me.

    Thanks,

    Tam

  9. Sean says:

    Yeah, something like the code snippet you posted. I don’t remember, but does the shake effect dispatch an event when it’s done? You’d probably want to listen for that and only re-enable the button once the shake effect has completed.

  10. Tammam says:

    Hmmmm…for some reason it didn’t kick off the events. I tried the following:

    but the effectStart and effectEnd event didn’t start for some reason. Am I doing it wrong? inside those methods I enable/disable the button

  11. Tammam says:

    I think it didn’t display the code in my comment because it was a tag. Here it is
    effect:Shake
    id=”shaker_next”
    numShakes=”12″
    distX=”8″
    distY=”5″
    duration=”600″
    resetOnEnd=”true”
    shakeDirectionX=”right”
    shakeDirectionY=”up”
    effectStart=”shaker_next_effectStartHandler(event)”
    effectEnd=”shaker_next_effectEndHandler(event)”
    target=”{getNextButton}”

  12. Sean says:

    Hmmm…well I’m not sure off hand. I’ll check it later this evening and get back to you with a more definitive answer.

  13. Sean says:

    If you download the source (found here: http://seanmonahan.org/projects/flex-library/seanmonahanlibrary-latest/) you’ll see that the component dispatches an EffectEvent.EFFECT_END when the effect completes. Looks like it’s on line 227.

    There are two things I’d do. First, put a trace or something in your “effect end” handler and make sure the event is being handled. If it is, then your problem is not with the shake effect.

    If the event handler is not executing I’m not really sure what your problem is. You do, however, have access to the source code (see download link above) and are more than welcome to modify it to suit your needs. All I ask is that you give credit where it’s due.

  14. Tammam says:

    Thanks Sean. Good suggestion….

    I put a break point in my “effect end” and “effect start” events and noticed that the “effect end” gets called but not the “effect start”! Any ideas?

  15. Sean says:

    Yeah, “effect start” is not dispatched. If you need that event you’ll need to add it. In writing the effect my assumption was that is would typically be activated by a button or some other user interaction, so you’d have some inherent way of knowing the effect started without needed a “start” event.

  16. Tammam says:

    Thanks Sean…I did that it works now.

    Great work and nice Blog design :)

Leave a Reply