-
So confused! (Flash n00b)
Hi Everyone!
I am trying to figure something out for work and don't know anything about actionscripting
I found some code for falling snow which I have inserted into a keyframe. It works wonderfully but I need it to stop partway through my timeline.
I have tried making it into it's own movie and adding the movie to the keyframe instead of the code but it doesn't work.
Is there an action I can insert along my timeline that will stop the previous action but continue playing my timeline?
Thanks so much for any advice!
This is the code I used:
/**
* Snow Flakes Effect
*
* Version: 1.0
* Author: Philip Radvan
* URL: http://www.freeactionscript.com
*/
//settings
var speed:Number = 3;
var wind:Number = 2;
var movieWidth:Number = 728;
var movieHeight:Number = 90;
createSnow(_root, 600);
function createSnow(container:MovieClip, numberOfFlakes:Number):Void
{
//run a for loop based on numberOfFlakes
for (var i = 0; i < numberOfFlakes; i++)
{
//set temporary variable and attach snowflake to it from the library
var tempFlake:MovieClip = container.attachMovie("snow_mc", "snow"+container.getNextHighestDepth(), container.getNextHighestDepth());
//variables that will modify the falling snow
tempFlake.r = 1+Math.random()*speed;
tempFlake.k = -Math.PI+Math.random()*Math.PI;
tempFlake.rad = 0;
//giving each snowflake unique characteristics
var randomScale:Number = random(50)+50;
tempFlake._xscale = randomScale;
tempFlake._yscale = randomScale
tempFlake._alpha = random(100)+50;
tempFlake._x = random(movieWidth);
tempFlake._y = random(movieHeight);
//give the flake an onEnterFrame function to constantly update its properties
tempFlake.onEnterFrame = function()
{
//update flake position
this.rad += (this.k / 180) * Math.PI;
this._x -= Math.cos(this.rad)+wind;
this._y += speed;
//if flake out of bounds, move to other side of screen
if (this._y >= movieHeight) {
this._y = -5;
}
if (this._x >= movieWidth)
{
this._x = 1
}
if (this._x <= 0)
{
this._x = movieWidth - 1;
}
}
}
}
-
Senior Member
you need to change createSnow(_root, 600); to createSnow(yourMovieClip, 600); so that you could remove yourMovieClip later.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|