| home | about | time | appearance | space | other | tips & tricks |
Natural Moving EyesThis example takes the Mumbling Effect one step further, because now the character's eyes open and close. We are going to discuss some new issues like: calculating the chances of an event happening in a simple way, working inside a Movie Clip and some trick for drawing over pictures. When we opened and closed the mouth there were similar chances for the mouth to open and close, but now the eyes need to stay opened for most of the time so we will make a small change in the script. But first we have to prepare the effect and as we mentioned, this effect will be nested inside a Movie Clip. The main advantage of including everything in Movie Clips is "portability" (you can copy/paste Movie Clips inside Flash, between different files). ![]() Let's start. First thing we need is a new Layer to work on. Because the default state of the eyes is already in the images, we just need to create the closed eyes. Lock all the other layers, click on the Brush Tool form the Side Panel (Windows Shortcut is "B" key) and chose the color yellow, similar to the face, in the Color Mixer Panel or color Box in the Side Panel. Now draw over the eyes like you see in the next images, and don't worry about being an artist, because this will appear only for 0.08 seconds so nobody will notice. Select everything you painted with the brush and convert it to a Movie Clip (Right Click on the shape and chose "Convert to Symbol"). Double click the Movie Clip to open it for edit. Now on the first frame you have the yellow shape. Click this first frame and drag it in the third frame (the first two frames will be converted into blank frames). You will also need a second layer for the Action Script code. Your stage will look something like this:
The next part is similar to what we did in Mumbling Effect so read carefully the previous chapter. On the first frame we add the following code:
var ok, Value, desiredValue:Number;
Value = 7;
desiredValue = 1;
ok = random( Value );
if( ok == desiredValue ) {
gotoAndPlay(3);
}
The only difference is the variable Value, now assigned with the value "7". This means that we generate a number between zero and six (not zero and one as in the first example) and we see if that value is the desired one. The chances for the condition to be satisfied are a lot smaller because the eyes must be opened most of the time (the probability is somewhere near 15%). On the second frame we have to add "gotoAndPlay(1)" to complete the loop, and the effect is ready to publish. Conclusion: working inside the Movie Clip is better if we need to reuse the effect in another file and estimating the probability for the occurrence of an event is the key for a realistic random effect (you only have to change the variable "Value"). In the next chapter we will discuss another looping way that gives equal chances to all the states of the object (if we want that, of course). |
| 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. |