|
|
|
#1 |
|
Senior Member
Join Date: Nov 2002
Location: Nettuno
Posts: 197
|
flying leaf, random,horizontal???
Hello
I have a countryside pic as part of the header with just the one tree in a corner from where I would like some leaves blowing away across the full width of the stage randomly. I could create lots of mc with one leaf each and stick them around the stage but it would look to repetitive to me. I am sure there must be a way to do it with actionscript, just need to know how. I posted this message in general help and got no answer. Looked for tutorial which i didn't find and downloaded fla which was like chinese to me. So I hope someone can explain it to me nice and simple. Using flash mx by the way...not 2004 version. thanks a lot
__________________
Onsitus |
|
|
|
|
|
#2 |
|
Senior Member
Join Date: Feb 2004
Location: Los Angeles
Posts: 2,920
|
The following code is modified from my shooter game which has stars that move randomly horizontally.
See the original to see the effect applied to stars. Jim's Shooter Game The basic idea is that you have a movieclip called 'leaves' in the library. Each frame of the movieclip contains an image (or animation) of a different leaf. You might want to animate the individual leaves to tumble. This script moves them across the screen at different rates.
Something else you might want to try is varying the speed in the moveLeaf function. For example:
Last edited by jbum; 10-13-2004 at 03:37 PM. |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Nov 2002
Location: Nettuno
Posts: 197
|
Thanks a lot for the answer and happy to know it can be done. Also I had a look at ur bestiary. Will try to understand the basic ones in my spare time.
Still have a problem though... So I imported the pic of the leaf in the library and converted it into a movie clip called "leaves" made of 5 frames (just rotated the leaf a bit). Then placed the mc on the main stage on layer1 first frame, on layer2 first frame I placed the actionscript u gave me and...nothing. I tried to place the actionscript inside the mc "leaves", also on the same frame, gave the instance name of the mc "leaves"... Only see the one leaf moving on itself. Where did i go wrong? Also I do not want the leaves flying all around the stage but just in the top pic (if possible just in the sky). Shall I made a mc consisting of just the top pic and the leaves and load it into the main movie? I joined the fla to see what i mean. Thanks a lot again. |
|
|
|
|
|
#4 |
|
Senior Member
Join Date: Feb 2004
Location: Los Angeles
Posts: 2,920
|
1)
In order for attachmovie to work, you have to use the linkage dialog and export the movie. Ctrl-click (or right-click in Windows) the 'leaves' movie in the library and select Linkage... from the menu. Click the box that says "export for actionscript". This makes the name "leaves" available to the attachmovie command in actionscript. 2) You left a leaf on the stage. Remove it - the script takes care of placing them on the stage for you. 3) I changed your leaf setup as follows. I took out the scaling (used to make my stars tiny), and fixed the _y placement to put the leaves in the sky.
4. If you want to move the leaves from left to right, use this version of the move function instead. The one you are using moves the leaves from right to left.
5. If your individual frames are only rotating the leaves, you don't really need them, because the script already gives you random rotation. I would suggest using different leaf graphics for each frame. |
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Nov 2002
Location: Nettuno
Posts: 197
|
Just perfect
|
|
|
|
|
|
#6 |
|
Senior Member
Join Date: Nov 2002
Location: Nettuno
Posts: 197
|
one more problem...
the pic at the back, when the leaves pass above the tree, it distorts itself (is that the right word!) Anything to do about it? |
|
|
|
|
|
#7 |
|
Senior Member
Join Date: Feb 2004
Location: Los Angeles
Posts: 2,920
|
I'm not seeing any distortion here... Enclose your latest version...
|
|
|
|
|
|
#8 |
|
Super Moderator
Join Date: Aug 2000
Location: Montréal
Posts: 13,239
|
Flash handles vector graphics better than raster ones. Draw the 'leaf' instead of using a picture.
gparis
__________________
![]() AS 2.0 Forum Guidelines || Use PHP tags for code samples || Flash9 LiveDocs || AS 2.0 Language reference (CS4) |
|
|
|
|
|
#9 |
|
Senior Member
Join Date: Nov 2002
Location: Nettuno
Posts: 197
|
I'll try later on to draw leaf...lucky that it is small and noone can see it
I'm joining the fla anyway. Thank you all for ur help, u've been great. |
|
|
|
|
|
#10 |
|
Senior Member
Join Date: Nov 2002
Location: Nettuno
Posts: 197
|
ok, did draw a leaf (called "leaf1") and i have the same result as with the pic leaf (called "leaf" in the library).
![]() Join u the file which is the same one as before but using "leaf1" instead of "leaf". Hoping u can help... |
|
|
|
|
|
#11 |
|
Senior Member
Join Date: Nov 2002
Location: Nettuno
Posts: 197
|
ops forgot the file
|
|
|
|
|
|
#12 |
|
Super Moderator
Join Date: Aug 2000
Location: Montréal
Posts: 13,239
|
Hi,
I saw no distortion, but i guess in your player it distorts because ther is movement over the image. It happens sometimes that raster images get 'shifted' or 'distorted'. One workaround is to embed the rater image into a graphic and set its _alpha to 99%. It's just one workaround.. also having all images symbols on round integers is always a good idea. yours is at 0,0 so that was not the problem. I attached the .fla . Tell me if better. gparis
__________________
![]() AS 2.0 Forum Guidelines || Use PHP tags for code samples || Flash9 LiveDocs || AS 2.0 Language reference (CS4) |
|
|
|
![]() |
|
||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|