To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here


A Flash Developer Resource Site

Go Back   Flash Kit Community Forums > Flash Help > Flash ActionScript

Reply
 
Thread Tools Display Modes
Old 04-12-2001, 09:58 AM   #1
rooprack
Junior Member
 
Join Date: Nov 2000
Posts: 22
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...
rooprack is offline   Reply With Quote
Old 04-12-2001, 10:35 AM   #2
Stickman
Senior Member
 
Join Date: Jul 2000
Location: Not on the dole any more
Posts: 1,040
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.
Stickman is offline   Reply With Quote
Old 04-23-2001, 09:09 AM   #3
the switch
Junior Member
 
Join Date: Apr 2001
Posts: 1
surely your name's meant to be 'roofrack'?
the switch is offline   Reply With Quote
Old 07-31-2001, 07:21 AM   #4
rooprack
Junior Member
 
Join Date: Nov 2000
Posts: 22
Surely you name is meant to be 'The Twat'?
rooprack is offline   Reply With Quote
Old 03-27-2002, 10:14 PM   #5
juicykorn333
Junior Member
 
Join Date: Mar 2002
Posts: 11
How do you get it to stop playing so it can go to the next scene instead of getting it looped
juicykorn333 is offline   Reply With Quote
Reply

Go Back   Flash Kit Community Forums > Flash Help > Flash ActionScript

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 08:28 PM.


internet.commerce
Be a Commerce Partner
 »  »  »  »  »  »  »
 »  »  »  »  »  »
 

    

Acceptable Use Policy

Internet.com
The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.