logo
g Text Version
Beauty & Self
Books & Music
Career
Computers
Education
Family
Food & Wine
Health & Fitness
Hobbies & Crafts
Home & Garden
Money
News & Politics
Relationships
Religion & Spirituality
Sports
Travel & Culture
TV & Movies

dailyclick
Bored? Games!
Nutrition
Postcards
Take a Quiz
Rate My Photo

new
European Travel
Action Movies
Bible Basics
Houseplants
Romance Movies
Creativity
Family Travel


dailyclick
All times in EST

Clairvoyance: 08:00 PM

Full Schedule
g
g Flash and Animation Site

BellaOnline's Flash and Animation Editor

g

Alpha and Scale Particle Properties - Flash CS3


Now that we have our FlashR CS3 particle system snow scene animation polished a bit, we can concentrate on adding more interest and realism to our animation. In the last tutorial, we added some randomness to our snowflakes by using Math.random() to vary the amount of wind effect that is applied to each individual snowflake. Let's add even more interest by varying the size and transparency of the snowflake particle. After all, in real life, not all snowflakes are the same size. Also, by varying the transparency of some flakes, it will give the illusion that some of the snowflakes are farther away in the snow scene. So let's get busy.

First, we need to decide where we will put this new code. If we put it inside the snowfall function code, the size and transparency of the snowflake graphic will change every time Flash enters a new frame. This is because the snowfall function is the event handler for the ENTER_FRAME event listener. This will not give us the effect that we are looking for. We do not want the snowflake to change its appearance after it is drawn to the stage.

Our second option is to add the new code to the section that creates the snowflakes and sets the X and Y positions. Because this section of code only happens once for each snowflake, this is the place for our new code. We want the transparency (or alpha) and the size (or scale) for our snowflake to be determined only once at the time of its "creation".

The first line of new code that we will add will tell Flash to resize the snowflake to a random size between 0 and 1. The value of 0 will scale the snowflake down to nothing and the value of 1 will keep it at 100%. We will use the scaleX and scaleY properties to control the size. Why do we need to set both the X and Y scale? Imagine that we only set the X scale to 50%. Our snowflake would be half the width of the original size and still as tall as it was originally. It would no longer be a nice round snowflake. So we need to resize both the X and Y scale values.

_Snowflake.scaleX = Math.random();
_Snowflake.scaleY = Math.random();

But we still need to be sure that Flash resizes the snowflake evenly for both X and Y values. As we have the code written now, the X and Y values could possibly be two different random numbers. We want them to be the same random number. We can be sure of that by changing the code so that it sets the X and Y scale to the same random number.

_Snowflake.scaleX =_Snowflake.scaleY = Math.random();

Our second task is to change the transparency of our snowflake graphic. We will do this be setting a random value for the alpha property.

_Snowflake.alpha = Math.random();

Now let's add this code into our program and test our movie a few times. Each time, the snowflake should be a different size and opacity.

Save your snow scene as SnowScene7.fla.





Add Alpha+and+Scale+Particle+Properties+%2D+Flash+CS3 to Twitter Add Alpha+and+Scale+Particle+Properties+%2D+Flash+CS3 to Facebook Add Alpha+and+Scale+Particle+Properties+%2D+Flash+CS3 to MySpace Add Alpha+and+Scale+Particle+Properties+%2D+Flash+CS3 to Del.icio.us Digg Alpha+and+Scale+Particle+Properties+%2D+Flash+CS3 Add Alpha+and+Scale+Particle+Properties+%2D+Flash+CS3 to Yahoo My Web Add Alpha+and+Scale+Particle+Properties+%2D+Flash+CS3 to Google Bookmarks Add Alpha+and+Scale+Particle+Properties+%2D+Flash+CS3 to Stumbleupon Add Alpha+and+Scale+Particle+Properties+%2D+Flash+CS3 to Reddit



 



RSS | Related Articles | Editor's Picks Articles | Top Ten Articles | Previous Features | Site Map


For FREE email updates, subscribe to the Flash and Animation Newsletter


Past Issues


print
Printer Friendly
bookmark
Bookmark
tell friend
Tell a Friend
forum
Forum
email
Email Editor


Content copyright © 2014 by Diane Cipollo. All rights reserved.
This content was written by Diane Cipollo. If you wish to use this content in any manner, you need written permission. Contact Diane Cipollo for details.

g


g features
Animating Color of Text in Motion 5

Animating Color of Shapes in Motion 5

Motion Workspace - Checkbox, Dials and More

Archives | Site Map

forum
Forum
email
Contact

Past Issues
memberscenter


vote
Poetry
Daily
Weekly
Monthly
Less than Monthly



BellaOnline on Facebook
g


| About BellaOnline | Privacy Policy | Advertising | Become an Editor |
Website copyright © 2014 Minerva WebWorks LLC. All rights reserved.


BellaOnline Editor