I am trying to find an easy way of shaking an image randomly can anyone give me some tips or anything?
I am trying to find an easy way of shaking an image randomly can anyone give me some tips or anything?
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.
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
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:
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.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; } }
Bookmarks