# Drop, Bounce, Collide, Bounce?

**URL:** <https://forum.kirupa.com/t/drop-bounce-collide-bounce/260345>\
**Category:** flash\
**Created:** [May 14, 2008, 4:26pm UTC](https://forum.kirupa.com/t/drop-bounce-collide-bounce/260345 "2008-05-14T16:26:48Z")\
**Posts on this page:** 9\
**Page:** 2

<div class="post-metadata">

**Author:** ![hondo311](https://avatars.discourse-cdn.com/v4/letter/h/6a8cbe/32.png) [@hondo311](https://forum.kirupa.com/u/hondo311)\
**Post date:** [May 21, 2008, 12:39pm UTC](https://forum.kirupa.com/t/drop-bounce-collide-bounce/260345/21 "2008-05-21T12:39:46Z")

</div>

Hey Cody,  
That works like a champ! soooo cool!

I muscled out some code for a double click function . . . so when you double click the ball, a new browser window opens.

I added this code to the bottom of the actionscript for the ball:

```php

on (release) {
if(getTimer()-lastClick < 500){
getURL('http://www.google.com');
}
lastClick=getTimer();
}

```

If I have any other questions I’ll be sure to ask!!

Thanks,

Hondo311

---

<div class="post-metadata">

**Author:** ![hondo311](https://avatars.discourse-cdn.com/v4/letter/h/6a8cbe/32.png) [@hondo311](https://forum.kirupa.com/u/hondo311)\
**Post date:** [May 21, 2008, 3:38pm UTC](https://forum.kirupa.com/t/drop-bounce-collide-bounce/260345/22 "2008-05-21T15:38:34Z")

</div>

Hey again Cody . . .

I understand what you said about objects bouncing based n a BOX that’s around them . . . is there a way to tweak the code so that irregular shapes (that aren’t perfectly square, like rectangles or triangles) will work too?

Thanks!

Hondo311

---

<div class="post-metadata">

**Author:** ![ShadowViper](https://avatars.discourse-cdn.com/v4/letter/s/54ee81/32.png) [@ShadowViper](https://forum.kirupa.com/u/ShadowViper)\
**Post date:** [May 21, 2008, 5:03pm UTC](https://forum.kirupa.com/t/drop-bounce-collide-bounce/260345/23 "2008-05-21T17:03:01Z")

</div>

Well… I know that it is possible, but that is beyond my current abilities. I tried several methods of doing it, and none of them worked very well. You _might_ be able to rig something up for a circle using it’s radius, but I’m not sure how to go about it for the other ones.

~Cody

---

<div class="post-metadata">

**Author:** ![hondo311](https://avatars.discourse-cdn.com/v4/letter/h/6a8cbe/32.png) [@hondo311](https://forum.kirupa.com/u/hondo311)\
**Post date:** [May 21, 2008, 5:15pm UTC](https://forum.kirupa.com/t/drop-bounce-collide-bounce/260345/24 "2008-05-21T17:15:51Z")

</div>

Thanks for trying Cody . . .

. . . anyone else have any suggestions?

Hondo311

---

<div class="post-metadata">

**Author:** ![ShadowViper](https://avatars.discourse-cdn.com/v4/letter/s/54ee81/32.png) [@ShadowViper](https://forum.kirupa.com/u/ShadowViper)\
**Post date:** [May 21, 2008, 5:52pm UTC](https://forum.kirupa.com/t/drop-bounce-collide-bounce/260345/25 "2008-05-21T17:52:36Z")

</div>

No problem. Good luck in the future. PM when you finish whatever your using this for. I’d like to see it. 🙂

~Cody

---

<div class="post-metadata">

**Author:** ![Hurley](https://avatars.discourse-cdn.com/v4/letter/h/cab0a1/32.png) [@Hurley](https://forum.kirupa.com/u/Hurley)\
**Post date:** [June 26, 2008, 8:42pm UTC](https://forum.kirupa.com/t/drop-bounce-collide-bounce/260345/26 "2008-06-26T20:42:31Z")

</div>

Hi Guys,

any chance of posting an fla???

Im working on a similar project and am stumped on the collide part. ![](https://forum.kirupa.com/uploads/kirupa/6998/fd1ebddb77855921.gif) ![](https://forum.kirupa.com/uploads/kirupa/6998/fd1ebddb77855921.gif) ![](https://forum.kirupa.com/uploads/kirupa/6998/fd1ebddb77855921.gif) ![](https://forum.kirupa.com/uploads/kirupa/6998/fd1ebddb77855921.gif)

Hope you can help.

thanks

---

<div class="post-metadata">

**Author:** ![ShadowViper](https://avatars.discourse-cdn.com/v4/letter/s/54ee81/32.png) [@ShadowViper](https://forum.kirupa.com/u/ShadowViper)\
**Post date:** [June 26, 2008, 9:00pm UTC](https://forum.kirupa.com/t/drop-bounce-collide-bounce/260345/27 "2008-06-26T21:00:53Z")

</div>

[quote=Hurley;2349852]Hi Guys,

any chance of posting an fla???

Im working on a similar project and am stumped on the collide part. ![](http://forum.kirupa.com/uploads/kirupa/6999/72c5dc36d3944a07.gif) ![](http://forum.kirupa.com/uploads/kirupa/6999/72c5dc36d3944a07.gif) ![](http://forum.kirupa.com/uploads/kirupa/6999/72c5dc36d3944a07.gif) ![](http://forum.kirupa.com/uploads/kirupa/6999/72c5dc36d3944a07.gif)

Hope you can help.

thanks[/quote]

Look at my above posts. I have the commented source file from before up there in zip format already.

~Cody

---

<div class="post-metadata">

**Author:** ![thesean](https://avatars.discourse-cdn.com/v4/letter/t/9f8e36/32.png) [@thesean](https://forum.kirupa.com/u/thesean)\
**Post date:** [June 26, 2008, 9:49pm UTC](https://forum.kirupa.com/t/drop-bounce-collide-bounce/260345/28 "2008-06-26T21:49:27Z")

</div>

> I understand what you said about objects bouncing based n a BOX that’s around them . . . is there a way to tweak the code so that irregular shapes (that aren’t perfectly square, like rectangles or triangles) will work too?

Unless I’m mistaken, using this bounding box method is just a hitTest that you’ve coded yourself, so I don’t know why ShadowViper advocated not using hitTest on each side of the object. HitTest has the advantage of being able to evaluate a shape or a bounding box by enabling or disabling the shapeFlag (for more info see: [http://www.adobe.com/support/flash/action\_scripts/actionscript\_dictionary/actionscript\_dictionary534.html](http://www.adobe.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary534.html))

So, I’m fairly certain that using hitTest with a shapeflag on, say, each side of a triangle, would have the effect you desire.

Then again I could be wrong =P

---

<div class="post-metadata">

**Author:** ![ShadowViper](https://avatars.discourse-cdn.com/v4/letter/s/54ee81/32.png) [@ShadowViper](https://forum.kirupa.com/u/ShadowViper)\
**Post date:** [July 6, 2008, 12:38am UTC](https://forum.kirupa.com/t/drop-bounce-collide-bounce/260345/29 "2008-07-06T00:38:41Z")

</div>

[quote=thesean;2349885]Unless I’m mistaken, using this bounding box method is just a hitTest that you’ve coded yourself, so I don’t know why ShadowViper advocated not using hitTest on each side of the object. HitTest has the advantage of being able to evaluate a shape or a bounding box by enabling or disabling the shapeFlag (for more info see: [http://www.adobe.com/support/flash/action\_scripts/actionscript\_dictionary/actionscript\_dictionary534.html](http://www.adobe.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary534.html))

So, I’m fairly certain that using hitTest with a shapeflag on, say, each side of a triangle, would have the effect you desire.

Then again I could be wrong =P[/quote]

Well, I’m not sure if you are correct or not. For me, using a bounding box has a few advantages.

-It gets you used to detecting collisions in the event that you were to ever use a language without a hittest-type function.  
-it makes it easier for me to determine what side something is being hit on so that I can then react to that and make the object do something (i.e. bounce, move, etc) based on which side it was hit on. I have tried using hittest for this type of thing and it has just never worked very well for me.  
-it seems like it might be more efficient (but I can’t say that this claim has any supporting evidence or truth to it). Just a guess I have really. I’m not sure how a hittest is calculated so this may be wrong entirely.

~Cody

[Previous page](https://forum.kirupa.com/t/drop-bounce-collide-bounce/260345.md?page=1)
