How to remove the object from the stage

Hello

I am currently implementing an AS3 code that generates a snow effect on the scene.  I am using the code from this site, but has difficulty:

http://www.Kirupa.com/developer/flashcs4/falling_snow_as3_cs4_pg5.htm

I have no difficulty in implementing of the snow, but I can't understand how get rid of it once it's there!  Here's the code, I have:

(main.as)

main/public class extends MovieClip

{

var snowamount = 50;

public void main()

{

scene9. SnowPlus.addEventListener (MouseEvent.MOUSE_DOWN, moresnow);

}

function makeItSnow()

{

for (var i: int = 0; i < snowamount; i ++)

{

var newSnowFlake:Snowflake = new Snowflake();

this.addChild (newSnowFlake);

newSnowFlake.SetInitialProperties ();

triggerSnowAnimation();

}

}

function moresnow (MouseEvent): void

{

snowamount += 20;

makeItSnow();

}

function triggerSnowAnimation()

{

If (snowamount > = 160)

{

scene9.gotoAndPlay (3);

scene9. SnowPlus.Visible = false;

}

}

(Snowflake.as)

SerializableAttribute public class extends MovieClip Snowflake

{

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 void Snowflake()

{

}

public void SetInitialProperties()

{

xSpeed is.05 + Math.random () *.1;.

ySpeed =.1 + Math.random () * 3;

RADIUS =.1 + Math.random () * 2;

Scale =.01 + Math.Random ();

alphaValue =.1 + Math.Random ();

var stageObject:Stage = this.stage in the stadium;

maxWidth = stageObject.stageWidth;

maxHeight = stageObject.stageHeight;

This.x = Math.random () * maxWidth;

This.y = Math.random () * maxHeight;

PosX = 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;

}

}

}

The code is not so difficult to understand, in fact.  I have a button that adds "snowamount" to the variable, so more snow is done on the scene when the button is clicked.  However, once the "snowamount" gets above 160 bee, I trigger an animation.  Once the animation is completed, I want the snow to disappear from the scene.  But I can't understand the correct way to do everything.  Any help would be appreciated!  Thank you very much in advance.

create an array and store your references to Snowflake in this table.  When you are ready to remove the snow flakes, loop in the table.

main/public class extends MovieClip

{

var snowamount = 50;

var snowFlakeA:Array = [];

public void main()

{

scene9. SnowPlus.addEventListener (MouseEvent.MOUSE_DOWN, moresnow);

}

function makeItSnow()

{

for (var i: int = 0; i< snowamount;="">

{

var newSnowFlake:Snowflake = new Snowflake();

snowFlakeA.push (newSnowFlake);

this.addChild (newSnowFlake);

newSnowFlake.SetInitialProperties ();

triggerSnowAnimation();

}

}

function moresnow (MouseEvent): void

{

snowamount += 20;

makeItSnow();

}

function triggerSnowAnimation()

{

If (snowamount > = 160)

{

scene9.gotoAndPlay (3);

scene9. SnowPlus.Visible = false;

}

}

(Snowflake.as)

SerializableAttribute public class extends MovieClip Snowflake

{

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 void Snowflake()

{

}

public void SetInitialProperties()

{

xSpeed is.05 + Math.random () *.1;.

ySpeed =.1 + Math.random () * 3;

RADIUS =.1 + Math.random () * 2;

Scale =.01 + Math.Random ();

alphaValue =.1 + Math.Random ();

var stageObject:Stage = this.stage in the stadium;

maxWidth = stageObject.stageWidth;

maxHeight = stageObject.stageHeight;

This.x = Math.random () * maxWidth;

This.y = Math.random () * maxHeight;

PosX = 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;

}

}

function removeSnowF (): void {}

for (var i: int = snowFlakeA.length - 1; i > = 0; i--) {}

this.removeChild (snowFlakeA [i]);

snowFlakeA.splice (i, 1);

}

}

}

Tags: Adobe Animate

Similar Questions

  • How to remove unused objects from the webcatalogs?

    Hi friends,

    How to remove unused objects from the webcatalogs?
    is there a utility like the removal of unused objects of the physical layer in RPD?

    Thank you

    Hello

    Click link responses to the left of the answers click on the catalog button manage manage catalog, you can delete the unused objects

    Concerning

    NGO

  • How to remove an object from a photo...

    I tried the Magic Eraser... no results... The object is deleted bu t that appears a large number of small squares...

    It depends on what you want to do with the subject. I guess you are trying to cut out a portion of a photo to use in another image? You can just copy paste the object isolated in the new photo.

    On the other hand, if you mean you want to fill the empty space, the gum was not the best choice of tool for the job. Usually in PSE you clone from objects you don't want (like traffic signs, for example) to hide rather than delete it, because you still have to put something to cover the hole that you did. If you don't mind not changing the shape of the picture, the tool recompose can also be used for things like the deletion of the average person in a group of three and the other two get closer.

  • How to remove an object from a turned movement?

    So my dumb butt left a cellphone on the counter in this shot, as you can see here: Streamable - simple video sharing

    I never got to try it, but what is (in your opinion) the best way to deal with this?  My first thought was I could export it as an image sequence and remove manually in photoshop in every shot, but I shot it at 60 fps and close-up has about 100 images so obviously I don't want to do it 100 times.

    Any recommendations?  I'm fine with lifting the tutorials but I don't know what methods I need to find a tutorial on

    So if someone could point me in the right direction, I would appreciate it.

    AE has a tool, clone stamp, as well, and in your case, that would be super simple to use, since you have a lot of sources of clone with barely any discernible texture. Track the phone and apply the clone stamp. As an alternative, you can simply duplicate the layer and use a bit of masking and repositioning to cover the phone on the layer below.

    Mylenium

  • How to remove a Word from the default dictionary of firefox?

    How to remove a Word from the default dictionary of firefox?
    If I wanted to remove the word 'dog' or 'and' for example

    There may be a range of reasons for wanting to do this, including the deletion of the words you use rarely as similar to other common spellings used words for example. "minute" and "Minuet", delete the words that you find personally offensive, or removing words that, because of linguistic or cultural background, you would not consider words at all.

    Note that I'm not asking how to remove my 'dictionary' words, words that I added myself.

    Hello

    I talked to a few people and I think I'm able to help you with this.

    There are two dictionary files, the default that comes with your version of Firefox and personal 'custom' that you create yourself with phrases and words.

    If you want to change the personal;

    1. Copy Subject: support and paste into the address bar.
    2. Next to the profile folder, click the marked File Show
    3. Find the file persdict.dat. Rename a text file, open, modify, re save it as persdict.dat and replace.

    If you want to change the default dictionary, it could be more of a problem and a lot more technique to do. I would recommend that you look at the problem differently and consider filtering of pages based on inappropriate content using Add-ons such as ProCon Latte Content Filter.

    I hope this helps, but if not, please come back here and we can look at another solution for you.

  • How to remove "Skype available" from the top of the notification page?

    How to remove "Skype available" from the top of the notification page - useless promotion!

    Hello!

    Disable the Skype status under Notification settings in Skype.

    All best
    Siim

  • How to remove a city from the weather app in IOS 9.2.1?

    I have an IPhone6S that I bought recently and am running IOS 9.2.1. I can't understand how to remove a city from the weather app. I tried to go to settings, where there is a list of all the applications on my phone except the weather app, so no help there. Any body can help me with this?

    You must tap on the small set of lines in the lower right to get list view. Then you can find the city that you want to delete, drag to the left to see the button Delete.

    See you soon,.

    GB

  • How to remove the effect - brightness, from there?

    How to remove the effect - brightness, from there.  First of all I thought to increase the sound volume using the BRIGHTNESS of the effect, but now improved Audio, I use the volume, which is enough.

    So I would remove the block of brightness from there.

    Thank you.

    The brightness setting should not have any effect as you turned it off.  .  .  the blue square is not lit.

    However, if you don't like the look of it sitting there, highlight as I did it and press the DELETE (backspace) key to make them disappear.

  • Win Update has 35 'language' listed on my update package. How can I get these updates ON my machine. I NEVER want to add to my computer. I want this great list of languages removed from the update list. How to remove the.

    Win Update has 35 'language' listed on my update package.  How can I get these updates ON my machine.  I NEVER want to add to my computer.  I want this great list of languages removed from the update list.   How to remove the.

    Hello

    If they are not installed then right click on them and HIDE

    If they are installed - Control Panel - Windows Updates - down left - installed updated - uninstall

    I hope this helps.

    Rob - bicycle - Mark Twain said it is good.

  • How to remove the watermark from desktop vista boot

    How to remove the watermark of ' Wndows Vista Starter from the desktop? I changed the same wallpaper theme and also reviewed the "Bcdedit" cmd.exe... "but in vain.

    Unfortunately it is one of the many limitations of vista boot,

  • How to remove the virus from 2012 security Win7

    How to remove the virus from 2012 security Win7?

    Hello jlybn1,

    Take a look at this link to see if it helps: http://www.bleepingcomputer.com/virus-removal/remove-win-7-security-2012

    This forum post is my own opinion and does not necessarily reflect the opinion or the opinion of Microsoft, its employees or other MVPS.

    John Barnett MVP: Windows XP Expert associated with: Windows Expert - consumer: www.winuser.co.uk | vistasupport.mvps.org | xphelpandsupport.mvps.org | www.silversurfer-Guide.com

  • I would like to know how to remove the box/cursor information dialog box that appears whenever I have stop my mouse on an object.

    I would like to know how to remove the box/cursor information dialog box that appears whenever I have stop my mouse on an object.

    Have you tried to uncheck both options via Control Panel / folder Options / View?

    "Displays the size of file in folder tips".

    "Display descriptions pop - up for folder and desktop items"

  • How to remove all information from the computer so I can sell it?

    How to remove all information from the computer so I can sell it?

    Hello

    You will want to format the hard disk:

    1. you can use DBAN - http://www.dban.org/

    or

    2. you can follow this tutorial to clean install up to the step where you format the disk, in which you would then STOP (because you just want to get rid of the files on the hard drive, do not install Windows) - http://www.sevenforums.com/tutorials/1649-clean-install-windows-7-a.html

    Kind regards

    Patrick

  • How TO REMOVE the ICON FROM the FAVORITES bar?

    How to remove an icon from the Favorites bar?

    Right-click on it and select delete, if I understand you correctly

  • How to remove the logo from the Oracle of tableFirstTemplate?

    How to remove the logo from the Oracle of tableFirstTemplate?

    Dear aJohny!

    My worm jdeveloper is 12.1.3.0.0.

    For Jdeveloper code would be

    
    

    and the screen would be like this

    I think it's the correct process and the best answer to my question

    Concerning

  • How to remove the trial version of Acrobat DC 30 days that I have somehow on my MacBook Pro?  I don't want the dang thing, and it prevents me from using my Acrobat Pro 11 software.  Trying to access using the tree without end of support for Adobe is reall

    How to remove the trial version of Acrobat DC 30 days that I have somehow on my MacBook Pro?  I don't want the dang thing, and it prevents me from using my Acrobat Pro 11 software.  Trying to access using the tree without end of support for Adobe of really making me cranky.

    Hi thomh65004143,

    You simply drag the Acrobat DC application from the applications folder to the trash to uninstall.

    Then restart your system & install Acrobat XI Download Adobe Acrobat products. Standard, Pro | DC, XI, X.

    Let me know if you are still having a problem.

    Kind regards

    Nicos

Maybe you are looking for

  • People can't read my docs Pages and they lack of fonts

    People with Windows can not read My Documents Pages, so I want to get Microsoft Office for Mac. (Sorry!) Should I expect 2013 or 2016?

  • HP 2540: Range of printers HP 2540

    How to scan a document I want to then send it as an attachment? because I see nothing in my instruction book that comes with the new printer. Best regards, John Tel: (deleted content)

  • Windows 7 blue screen, sleep mode monitor.

    Hello, I have a hp series p6000 desktop product # BT503AA #ABA. And I get a blue screen crash dump and keep saying my monitor goes into sleep mode. Help, please. I swiched monitors and the same results. computer is used for family only, no company. I

  • Update error unknown error 643

    For some reason my computer will not download the .NET framework, version 1.1 Service pack 1 (KB929729)... I tried to install several times. I don't know what was going on. Help, please! Thank you

  • Watch the HD DVD on iPad?

    I have a lot of HD DVD on my pc, I have Widonws XP running, and I want to enjoy it on my iPad, is that possible? It seems that iPad cannot support DVD movies so I ask my question here and really need hlp, thank you.