# Vertically moving objects stopping on "impact"?

**URL:** <https://forum.kirupa.com/t/vertically-moving-objects-stopping-on-impact/6721>\
**Category:** flash\
**Created:** [October 15, 2002, 1:37am UTC](https://forum.kirupa.com/t/vertically-moving-objects-stopping-on-impact/6721 "2002-10-15T01:37:41Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Scottie](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/scottie/32/72_2.png) [@Scottie](https://forum.kirupa.com/u/Scottie)\
**Post date:** [October 15, 2002, 1:37am UTC](https://forum.kirupa.com/t/vertically-moving-objects-stopping-on-impact/6721/1 "2002-10-15T01:37:41Z")

</div>

Hey everyone. I’d like to create a movie where many different objects that start offscreen at top fall onto the stage and stop at a line (horizontal) and “stick” there. Then, when the line holding all the objects gets too “overburdened” I want it to sink down, say 100 pixels or so, and continue receiving more vertically moving objects until it sinks more. All the while I want the objects to pile up on top of each other, stacking up like a mountain of objects. Would the code go on each object or the timeline? Has anybody tried something like this where moving objects pile up? If you’d be so kind, please see the attached .gif as an illustration.

Thanks,  
\*\<:D Scottie

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 15, 2002, 11:40am UTC](https://forum.kirupa.com/t/vertically-moving-objects-stopping-on-impact/6721/2 "2002-10-15T11:40:34Z")

</div>

Hi,

Use hitTest to get to know if an object hits (what else!) something  
in an array.

OK,

declare an array where the only entry is the horizon line make the falling object(s) testHit any entries in the array (with a for loop) if true stop it(them) and push it into the array. if the array length is bigger than the number of objects the horizon can support make every object’s (including the horizon) \_y sink 100 pixels.

SHO

Hope this is usefull for you.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 15, 2002, 5:13pm UTC](https://forum.kirupa.com/t/vertically-moving-objects-stopping-on-impact/6721/3 "2002-10-15T17:13:23Z")

</div>

Hi eki, thanks for responding. I’m very new at Flash & AS so I don’t quite understand your answer. How do I set up an array, where do I actually attach the code, how do I set up the timeline, etc… Could you possibly throw some code at me and tell me how to use it and where?

Thanks!  
\*\<:D Scottie

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 15, 2002, 5:22pm UTC](https://forum.kirupa.com/t/vertically-moving-objects-stopping-on-impact/6721/4 "2002-10-15T17:22:44Z")

</div>

Hi,

I’m leaving work now(it’s 18:20 here), I’ll try to knock something out tonite at home and I’ll post it tomorrow if that’s all right with u.

cheers

SHO

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 16, 2002, 11:03am UTC](https://forum.kirupa.com/t/vertically-moving-objects-stopping-on-impact/6721/5 "2002-10-16T11:03:55Z")

</div>

Hi,

I’m posting a fla that does what u want.  
I’ve done quickly so it’s a bit rough but it’s a starting point  
for u to study and refine.

Cheers

SHO

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 16, 2002, 3:25pm UTC](https://forum.kirupa.com/t/vertically-moving-objects-stopping-on-impact/6721/6 "2002-10-16T15:25:35Z")

</div>

SHO, thank you so much! So nice of you to whip up a .fla. It’s just like I described. How would I alter the code to allow many objects to “fall” into the screen at the same time in a random manner, and also how would I speed up the motion? I want it to look very fast with many objects flying in.

So many Flash geniuses out there like yourself. I’m a Print Graphic Designer just learning all this stuff.

Cheers,  
\*\<:D Scottie

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 17, 2002, 9:51am UTC](https://forum.kirupa.com/t/vertically-moving-objects-stopping-on-impact/6721/7 "2002-10-17T09:51:53Z")

</div>

Hi,

I’m posting a new fla where u can chenge the speed by changing a variable (commented) called… yes you guessed it…speed.  
You can also change the number of pixels that the stack falls.

Regarding many objects falling at the same time, it needs a bit of rethinking but I’ll find some time to do it (I like the idea too).

I’ll post any updates.

Cheers

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 17, 2002, 6:54pm UTC](https://forum.kirupa.com/t/vertically-moving-objects-stopping-on-impact/6721/8 "2002-10-17T18:54:56Z")

</div>

How do you know where to begin!? The code is much more complex than I thought it would be. Some questions if you don’t mind:

numberOfObjects = 16;  
//Do you have to declare the number of objects? I would like to start with hundreds, or perhaps an indefinite unknown amount.

count = 6;  
// What exactly is the count… of what?

objectsToFall = new Array();  
//Is this “Total” or “Number of objects to fall at the same time”?

weight = [horizon];  
//I understand this one! But I only want the horizon to fall when a certain number of objects gets stacked up (say 80), and then the horizon should fall.

numberToFall = 1;  
//Perhaps this can be changed to something called “random”? I’d like a random number of objects to fall at random intervals (2 randoms)

speed = 10;  
// I tried changing only the speed value but it made everything in the movie change, including where the objects fell, how long, etc… SO confusing!

You are very kind to pursue this project with me. Hugs to London!

\*\<:D Scottie
