-
Hey. Iam trying to get a scrathy, old movie effect on my site. I want lots of the buttons, text etc to shake every now and again and move randomly (maybe even random, slight changes in the alpha value aswell). Doing this manually is really annoying, can look to organised and creates a HUGE file size if done to look good. Can anyone provide me with an actionscript to apply to my MCs which will make them do this? I have random movement ones but I dont want the MCs to move all around the screen, just jerk a bit and look old and effective. I am quite poor at any hard actionscript so Please help me. Thanks everyone...
-
Okay, I created a small demo file that you can check out.
Some variables are set in the first frame of the main timeline -- the amount the text will move (jitter_amount), the likelihood that it will move (jitter_probability, a larger number means it will move less often) and the amount the alpha will change (alpha_amount).
However, the rest of the code is in the Object Actions of the text movie clip (either select the clip, right click and choose Actions, or click on the blue arrow in the Instance panel).
First off, when the clip first starts up (onClipEvent(Load)), it sets two variables -- original_x and original_y with the starting position of the movie clip.
In the next section of code, first of all it creates a new random number -- jitter -- which will decide whether or not the text will move on that frame. If jitter is equal to 1, it executes the movement actions (we'll come to those in a minute), otherwise it sets the mc's position back to its original co-ordinates.
If jitter is equal to 1, then the text will move. The code looks like this:
Code:
jitter_x = math.floor(math.random()*_root.jitter_amount);
jitter_y = math.floor(math.random()*_root.jitter_amount);
_x = original_x - (_root.jitter_amount / 2) + jitter_x;
_y = original_y - (_root.jitter_amount / 2) + jitter_y;
alpha_change = math.floor(math.random()*_root.alpha_amount);
_alpha = 100 - alpha_change;
First off, we create two random numbers -- jitter_x and jitter_y. Don't let the code worry you -- it's just the new Flash 5 way of making random numbers. Basically, it creates a floating point number between 0 and 1, then multiplies it by our jitter_amount variable, then gets an integer.
We do this for the x and y amounts. Now we add these variables to the original position of the mc, minus half the jitter_amount. Why? Because by doing this, it can move up or down, left or right -- if we just added the variable to the original x or y, it would only be ever move down or to the right.
Finally, we create another random number based on our alpha_amount variable, and subtract it from 100, to change the alpha of the mc slightly.
I hope this makes sense. Just ask if you have any problems.
-
surely your name's meant to be 'roofrack'?
-
Surely you name is meant to be 'The Twat'?
-
How do you get it to stop playing so it can go to the next scene instead of getting it looped