Page : 1 2

15. Choose Window > Actions

16. Type the following action in the Object Actions window:

onClipEvent (load) {
_x = Math.random()*750;
_y = Math.random()*200;
}

This action gives us any random value of x and y position of arrow movie clip.

Math.random returns a random number between 0.0 and 1.0

17. Type the following action:

speed = Math.random()*50;

Here we have defined a variable named as 'speed'. This variable collects any random number multiplied by 50. This action helps the arrow to move.

Note:
You can also increase or decrease the numeric value ie. 50 to vary the speed of the arrows.

18. After the onClipEvent(load) action type the following action:

onClipEvent (enterFrame) {
_x += speed;
}

// The _x += speed is equilant to _x =_x + speed. //

// The _x value goes on changing each time movie enters into the frame.Everytime the new _x value is a combination of previous _x value plus speed. //

19. Type the following action below it.

if (_x>=710) {
_x = 0;
}

// This action resets the _x position of arrow movie clip to ' 0 ' after it goes out of the screen area. //

20. Now go back into the main scene.

21. Drag the flow arrow movie clip and keep it at the top left corner.


22. Choose Control > Test Movie.

Now you can see only one arrow moving from one end of the movie to other end.i.e left to right.

We want multiple arrows to cover the whole movie and get the perfect effect. For this we have to duplicate the existing arrow in multiple arrows.


23. Choose Window > Library > flow arrow movie clip.

24. Double click the 'flow arrow movie clip'.

25. Insert one more layer above the existing layer which contains arrow movie clip.


26. Choose Insert > Layer.

27. Select the first frame and choose Window > Actions

28. Type the following action in the Frame Actions Window

number = 7;
counter = 1;
while (counter<=number) {
duplicateMovieClip ("arrow", "arrow" add counter, counter);
counter = counter+1;
}

// The value of the variable number (7) determines the number of arrows that should be present at a time on the stage. //

// The variable counter sets the value of number of arrows to be duplicated. //

// while (counter<=number) sets the condition. i.e when counter value is less than or equal to the number value. //

// duplicateMovieClip is a command which duplicates the original arrow movie clip. //

// ("arrow", "arrow" add counter, counter) In this statement "arrow" is the main movie clip which has to be duplicated. //

// "arrow" add counter is a duplicated arrow movie clip which can be arrow1,arrow2 upto arrow7
(eg. arrow + counter ) //

// counter is the depth. //

// counter = counter+1 works as a counter.Each time counter + 1 will set a new value in the variable counter. //

30. Now go back into the main scene and in a new layer create a white border for the stage.

Choose Control > Test Movie.

Now you can see many arrows flowing from one end to other end.

NOTE:
You can also replace the arrow with any other object.

Regards,

Amol Salgaonkar.
The author is a Project Leader - Flash at Image Online Pvt. Ltd.
Developer of Layout Galaxy website design templates for Photoshop and Flash.

All accompanying logos, brands and product names are trademarks of their respective companies.

Blood for humans comes only from humans : Donate Blood
http://www.donate-blood.org   E-mail - om@donate-blood.org






© Image Online  2001-2003