Results 1 to 5 of 5

Thread: Shaking Effect

  1. #1
    Join Date
    Mar 2009
    Location
    UK
    Posts
    33
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Shaking Effect

    I am trying to find an easy way of shaking an image randomly can anyone give me some tips or anything?

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

  3. #3
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    If you're doing this in Flash, do the following:

    User an onEnterFrame event to randomly adjust the x (and possibly) y value rapidly within certain constraints. Make sure to save the original position of the movieclip in some variables. In your onEnterFrame function run some logic to see what the position of the MC is. If it's at its original point, adjust it to a reasonable range. If it's outside the original point, return it to the original position.

    If you need a timed function, use setInterval or a separate counter function.

    Using a tweening engine with an elastic tween would help the effect too.

  4. #4
    Join Date
    Mar 2009
    Location
    UK
    Posts
    33
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Thanks but the first response isn't what im looking for im creating a flash banner and just need some action script or to know how to shake the image randomly while it appears. Im pretty basic with flash so I didn't get most of that I understand what you are saying but Im not good with coding. If anyone knows of somewhere to use some from? Cheers

  5. #5
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    Ok, some very simple code. I'm assuming you're using AS2 here because most people starting out do (not sure why, AS3 has been out for a while).

    Anyway, what I mean is do something like this:

    Code:
    var X = box._x
    var Y = box._y
    
    this.onEnterFrame = function() {
    	if (box._x == X) {
    		box._x -= 2;
    		box._y -= 2;
    	}
    	else {
    		box._x = X;
    		box._y = Y;
    	}
    }
    Open Flash. Draw a square, make it into a movieclip and give it an instance name of 'box'. Then, paste the above code on the 1st frame. Test - and you have your shaking effect. Adjust your framerate to get faster/slower shaking.

Bookmarks

Posting Permissions

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