|
|
In
this tutorial, you will learn how to work with rulers
and guides, use oval tool to create effects for different
parts of the image, adjust vector curves, use shape
tween with radial gradient fills, create motion tween
in combination with advanced color style for movie clips,
use instance name and arrays to randomize the animation.
You'll be amazed how fast you learn Flash MX!
|
32. Return to
Scene 1. Insert new Layer, open the Library
and find Symbol "star_shape"
Movie Clip. Drag the symbol from the
library to the stage. Repeat the operation
and move instances where you want the small stars would
be placed. Tip: for better view the
content of the instance check "View layer
as outlines" in the Layer Properties. |
 |
| |
| Select all instances
of the "star_shape" Movie Clip (click on the
first keyframe). Choose "Modify > Distribute
to Layers" (or press Ctrl+Shift+D). |
 |
| |
| 33. Select first instance
and set Instance Name to "st1". |
 |
Repeat with all
other instances by giving them each an
instance name of "st" but make sure
you add the next number at the end like
we did with "st1". |
| Tip: to be
sure all instances have been named correctly open Movie
Explorer (Alt+F3) and expand Scene 1 branch. |
 |
Choose
"Insert > New Symbol". In the
Create New Symbol dialog give it a
name "scheduler", Behavior: Movie Clip. Return
to Scene 1 and insert new Layer. Find the Symbol
we' ve just created in the Library
window and drag it to the stage. Set
Instance Name to "scheduler".
34. Insert new Layer, select first
keyframe and copy and paste the following code
into the Actions window. |
function
stars()
{
b=1; _root.scheduler.onEnterFrame=function()
{ if(b<36)
{
b++; if(b%5==0)
{ _root["st"+b/5].gotoAndPlay(2);
}
}
}
} setInterval(stars,2000);
stars(); |
| |
| Test
your movie. You should see the small stars fade in and
out continuously. |
| Code:
a brief explanation: |
| function
stars() |
declare a function |
| b=1; |
asign value 1 to variable
"b" each time function stars() is called |
| _root.scheduler |
target path
of movieClipObject |
| onEnterFrame=function() |
event handler;
invoked continually at the frame rate of the movie |
| if(b<36) |
perform actions while the
condition is true |
| b++; |
post-increment unary
operator that adds 1 to variable "b" |
| b%5 |
%(modulo)-operator
(arithmetic); calculates the remainder
of "b" divided by 5 |
| == |
operator (equality);
tests if the remainder is equal to 0 |
| _root["st"+b/5] |
target path of movieClipObject |
| gotoAndPlay(2) |
method; starts
playing the movie at the specified frame |
| setInterval(stars,2000);
|
action; calls
a function at periodic intervals (2000
ms in our movie) while a movie plays |
| stars(); |
invoke function
stars() one time |
| |
| It's time to randomize
the stars animation. |
| Replace the old
code with the new one in the Actions
window. |
array0 = new
Array(1,2,3,4,5,6,7);
array1 = new Array(7,6,5,4,3,2,1);
array2 = new Array(1,3,5,7,2,4,6);
array3 = new Array(6,2,4,7,1,3,5);
array4 = new Array(1,7,2,6,3,5,4);
array5 = new Array(1,5,2,4,3,7,6);
function stars()
{
st=random(6);
my_array = new Array();
my_array=_root["array"+st];
b=1;
_root.scheduler.onEnterFrame=function()
{
if(b<36)
{
b++;
if(b%5==0)
{
ct=Number(my_array[b/5-1]);
_root["st"+ct].gotoAndPlay(2);
}
}
}
}
setInterval(stars,2000);
stars(); |
| Test
your movie. The small stars fade in and out in a random
order. |
| Code:
a brief explanation: |
array0 = new
Array(1,2,3,4,5,6,7);
array1 = new Array(7,6,5,4,3,2,1);
array2 = new Array(1,3,5,7,2,4,6);
array3 = new Array(6,2,4,7,1,3,5);
array4 = new Array(1,7,2,6,3,5,4);
array5 = new Array(1,5,2,4,3,7,6);
|
create several Array
objects |
| st=random(6); |
function;
returns a random integer between 0 and
one less than the integer specified in the value
parameter (in our case 6) |
| my_array = new
Array(); |
create a Array
objects |
| my_array=_root["array"+st]; |
assign the value to "my_array" |
| ct=Number(my_array[b/5-1]); |
return the value
of the element in the array |
Save
.fla file
DOWNLOAD .fla (planet_finished.fla) |
Best of luck ! :)
© 2004 Eugène Poitiers. BestCatalog.net
|