A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Create a vibrate/wiggle effect with AS2?

  1. #1
    Junior Member
    Join Date
    Nov 2008
    Posts
    24

    Create a vibrate/wiggle effect with AS2?

    I'm kind of an AS noob. I'm an after effects guy, and looking for something similar to the wiggle effect in that if anyone here is familiar with both.

    Basically I just want my moveiclip (called 'bgContainer_mc') to vibrate, and then I want to be able to control it to "lessen" the intensity of the vibration at a couple of points (over like 10 frames if possible so it's not abrupt) if that makes any sense.

    I have some animation going on within that movie clip but I want the whole thing to "wiggle" if that matters.

    Thanks in advance!

  2. #2
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    Hi, yup I am familiar with both,

    use this code on your Frame:

    Actionscript Code:
    ///// SETTINGS /////
    vibration = 20;
    decreaseSpeed = 0.2;
    ///////////////////

    normalX = bgContainer_mc._x;
    normalY = bgContainer_mc._y;

    bgContainer_mc.onEnterFrame = function(){
        this._x = normalX + Math.floor((Math.random()*(vibration+1))-(vibration/2));
        this._y = normalY + Math.floor((Math.random()*(vibration+1))-(vibration/2));
        if(vibration > 0){
            vibration -= decreaseSpeed;
        } else {
            vibration = 0;
            delete this.onEnterFrame;
        }
    }

    Adjust the 2 variables at the top, one for the vibration intensity and the other for the amount it should decrease. This is not a real wiggle effect like After Effects, and you cannot control it with timeline in the workspace (like After Effects), hence you've only gotta have 1 Frame and the code above on that Frame (select it, press F9 to open Actions Panel and copy and paste the code in there), and it will automatically end once the vibration has reached 0, so it's not dependent on Frames, but rather on the decrease amount and the framerate.

    Flash and After Effects are 2 completely different softwares, so doing things in Flash is bound to be different, but I hope this helps
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center