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
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.
code:
kNbrLeaves = 30;
kLeafLayer = 100;
SW = Stage.width; // keep track of width and height of stage
SH = Stage.height;
Something else you might want to try is varying the speed in the moveLeaf function. For example:
code:
moveLeaf = function()
{
// tweak the numbers .001 and 2 for different effects,
// the first number affects rate of change,
// and the second number affects amplitude of change
this.speed += Math.sin(getTimer()*.001)*2;
this._x -= this.speed;
if (this._x < -10)
this._x = SW+10;
}
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.
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.
code:
// move leaves to the right
moveLeaf = function()
{
this._x += this.speed;
if (this._x > SW+10)
this._x = -10;
}
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.
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...
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.