| home | about | time | appearance | space | other | tips & tricks |
Mumbling GuyAs you can see above, the yellow guy opens and closes his mouth, looking like he is mumbling something. This is a great way to animate logos which include funny characters. The example works because of a simple script that decides randomly if the dude has to open or shut his mouth, so basically this is a Boolean generation. We used two instances of the picture: ![]() Let's get to work: Add the first picture on the first (CTRL-R) and on the second frame (right click on the frame, then press F5 or left click on the frame and chose Insert Frame). Insert the second picture on the third frame so it matches the first (right click on the third frame, then press F6 or left click on the frame and chose Insert New Keyframe, then CTRL+R or Import to Stage from the File dropdown menu). This arrangement represents the three states of the movie: first frame is the default state (mouth shut), second frame means the Script chose to keep the mouth shut and the third means the mouth must open. Here is how the Script must behave:
Now let's do the actual engine. Follow the image above (the advanced developer have already skipped this, but for a novice this part is essential). Create a new Layer and name it "Actions" (this is how most of the developers name the layer where they want to write the code and usually this layer does not hold any visual object). On the first frame insert the next Action Script code right click on the frame in the Main Timeline and open the Actions Panel):
var ok, Value, desiredValue:Number; //variables declaration
Value = 2; //chose the range of values
desiredValue = 1; //chose the value you want to obtain
ok = random( Value ); //generate the number
if( ok == desiredValue ) {
//test if the number obtained is the desired one
gotoAndPlay(3); //if yes go to frame 3
}
If we don't obtain the desired value, the movie will jump to the next frame (there is no code stopping it from doing that) meaning that we want to keep the mouth shut. On the second frame we have to add: gotoAndPlay(1); This will send the movie to the first frame so it can perform another test. If we obtain the desired value for the number, it means the mouth will open, so the movie will jump to frame 3 and then will continue to frame 1 and to another test. After every opening, the movie goes back to Frame 1 (the mouth closes). So the mouth will be in the closed state more times than in opened. This can be eliminated if we use another way of looping so the result would be 50% chances for the movie to reach each frame. Check out the Lightning Effect to see another way of looping. Also see how you can limit the chances of an event happening in this next example where we have animated the eyes of this character. |
| Copyright © 2010 WebArticles.org. All rights reserved. Privacy Policy. |
| FlashRandomEffects.WebArticles.Org is not affiliated with Adobe Systems Incorporated, USA. Adobe Flash is a registered trademark of Adobe Systems, Inc in the United States of America and/or other countries. The purpose of this website is to provide information for mastering Adobe Flash and creating Flash effects. |