Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6856499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:53:38+00:00 2026-05-27T01:53:38+00:00

I got function in Flash (Action Script 3) – that makes snowflakes falling. Now

  • 0

I got function in Flash (Action Script 3) – that makes snowflakes falling. Now i want to make this snowflakes appear on screen only for 3 seconds. So I’m trying to use Timer class but i got problem:

var myTimer:Timer = new Timer(3000, 1); 
myTimer.addEventListener(TimerEvent.TIMER, snowflakes);
myTimer.start();

function snowflakes(event:TimerEvent):void {
 //snowflakes faling function
}

In this case snowflakes appear after 3 seconds and stay on the stage forver…So its kinda opposite what i wanted. I want them to appear from the very beginning then disappear after 3 second. How can I do that ?

…EDIT

Oh yes. I do apologies for that. Here is the code. I got snowFlakes class in separate file called Snowflake.as which contains that code:

package 
{
    import flash.display.*;
    import flash.events.*;

    public class Snowflake extends MovieClip
    {
        private var xPos:Number = 0;
        private var yPos:Number = 0;

        private var xSpeed:Number = 0;
        private var ySpeed:Number = 0;

        private var radius:Number = 0;

        private var scale:Number = 0;
        private var alphaValue:Number = 0;

        private var maxHeight:Number = 0;
        private var maxWidth:Number = 0;

        public function Snowflake()
        {
            //SetInitialProperties();
        }

        public function SetInitialProperties()
        {
            //Setting the various parameters that need tweaking 
            xSpeed = .05 + Math.random()*.1;
            ySpeed = .1 + Math.random()*6;
            radius = .1 + Math.random()*2;
            scale = .01 + Math.random();
            alphaValue = .1 + Math.random();

            var stageObject:Stage = this.stage as Stage;
            maxWidth = stageObject.stageWidth;
            maxHeight = stageObject.stageHeight;

            this.x = Math.random()*maxWidth;
            this.y = Math.random()*maxHeight;

            xPos = this.x;
            yPos = this.y;

            this.scaleX = this.scaleY = scale;
            this.alpha = alphaValue;

            this.addEventListener(Event.ENTER_FRAME, MoveSnowFlake);
        }

        function MoveSnowFlake(e:Event)
        {
            xPos += xSpeed;
            yPos += ySpeed;

            this.x += radius*Math.cos(xPos);
            this.y += ySpeed;

            if (this.y - this.height > maxHeight)
            {
                this.y = -10 - this.height;
                this.x = Math.random()*maxWidth;
            }
        }
    }
} 

and first frame on the timeline on AS layer contains that code:

import flash.utils.Timer;
import flash.events.TimerEvent;

var myTimer:Timer = new Timer(3000, 1);
myTimer.addEventListener(TimerEvent.TIMER, runOnce);
myTimer.start();

function runOnce(event:TimerEvent):void {
 for (var i:int = 0; i < 50; i++)
    {
        var newSnowFlake:Snowflake = new Snowflake();
        this.addChild(newSnowFlake);

        newSnowFlake.SetInitialProperties();
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T01:53:38+00:00Added an answer on May 27, 2026 at 1:53 am

    Your timer is set just fine, the issue you’re having is what you’re doing with it.
    Call snowFlakes right from the start, and bind the timer Event to removeSnowFlakes, where you will removeChild all snow flakes you added on the snowflakes function.

    EDIT:

    Apply the following changes to your code:

    import flash.utils.Timer;
    import flash.events.TimerEvent;
    
    var snowFlakeContainer : MovieClip;
    var myTimer:Timer = new Timer(3000, 1);
    myTimer.addEventListener(TimerEvent.TIMER, removeSnowFlakes);
    myTimer.start();
    
    addSnowFlakes();
    
    function addSnowFlakes():void {
        snowFlakeContainer = new MovieClip();
        for (var i:int = 0; i < 50; i++)
        {
            var newSnowFlake:Snowflake = new Snowflake();
            snowFlakeContainer.addChild(newSnowFlake);
    
            newSnowFlake.SetInitialProperties();
        }
    }
    
    function removeSnowFlakes(event:TimerEvent):void {
        removeChild(snowFlakeContainer);
        snowFlakeContainer = null;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a function inside of a class that returns a string. Inside this
I've got this code, working only in firefox. <script type=text/javascript> function setVideo(url){ url =
I've got this actionscript flash file i'm trying to make work. when a person
Im stuck I got this flash that need's to be configured in a certain
I got a Function that returns a Collection<string> , and that calls itself recursively
I got a function like def f(): ... ... return [list1, list2] this returns
I've got a function that runs a user generated Regex. However, if the user
I've got a function here that is meant to look through a list of
I've got a function that does (in short): my $file = IO::File->new(| some_command >>
I'm new to the whole Action Script / Flash world...but trying to teach myself

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.