# Can someone show me howto(collision)

**URL:** <https://forum.kirupa.com/t/can-someone-show-me-howto-collision/185735>\
**Category:** flash\
**Created:** [April 15, 2006, 11:55pm UTC](https://forum.kirupa.com/t/can-someone-show-me-howto-collision/185735 "2006-04-15T23:55:24Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![joran420](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/joran420/32/2329_2.png) [@joran420](https://forum.kirupa.com/u/joran420)\
**Post date:** [April 15, 2006, 11:55pm UTC](https://forum.kirupa.com/t/can-someone-show-me-howto-collision/185735/1 "2006-04-15T23:55:24Z")

</div>

Using only actionscript

create 2 balls next to each other (same \_y) (this part is easy)  
have a 3rd ball come from below (easy again)  
and hit somewhere in the middle of the two balls  
and have the 2 balls get pushed aside to make room for the new ball(the 3rd ball kinda wedges its self into the middle without overlapping either ball)

I imagine its something that will take a lil time to do…I been trying to get it

but i have a really hard time getting objects to act like solid objects

(edit) the ball gfx are in the library(as a MC) linkage = “Ball”

---

<div class="post-metadata">

**Author:** ![joran420](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/joran420/32/2329_2.png) [@joran420](https://forum.kirupa.com/u/joran420)\
**Post date:** [April 17, 2006, 7:31pm UTC](https://forum.kirupa.com/t/can-someone-show-me-howto-collision/185735/2 "2006-04-17T19:31:14Z")

</div>

no ones up for this? I can post what i have done(basically to movie clips next to each other)

when you click anywhere on the screen it creates a ball that moves toward a random point between the two target MC’s

but I want the two target clips to ease apart and the shot MC to be placed in between them

and for all 3 objects behave like they are solid

---

<div class="post-metadata">

**Author:** ![joran420](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/joran420/32/2329_2.png) [@joran420](https://forum.kirupa.com/u/joran420)\
**Post date:** [April 18, 2006, 2:25am UTC](https://forum.kirupa.com/t/can-someone-show-me-howto-collision/185735/3 "2006-04-18T02:25:04Z")

</div>

heres my FLA  
can someone please take a look at it and make it so the balls behave like theyre being hit(but the stage has like 100% friction)

at the end after all motion is completed i want a line of 3 balls

if the shot ball hits the target ball set on the left side push both balls left and have  
target target shot

if it hits right push both balls to the right  
so you have shot target target

and if you hit somewhere in the middle push both target balls apart to allow space for the shot  
target shot target

---

<div class="post-metadata">

**Author:** ![joran420](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/joran420/32/2329_2.png) [@joran420](https://forum.kirupa.com/u/joran420)\
**Post date:** [April 19, 2006, 2:19am UTC](https://forum.kirupa.com/t/can-someone-show-me-howto-collision/185735/4 "2006-04-19T02:19:59Z")

</div>

surely some kind soul will take pity on me and at least help me think about what i need to think about and collaborate with me to make the ball physics work

just get me started in the right direction 🙂

---

<div class="post-metadata">

**Author:** ![B\_L\_U\_E](https://avatars.discourse-cdn.com/v4/letter/b/ba8739/32.png) [@B\_L\_U\_E](https://forum.kirupa.com/u/B_L_U_E)\
**Post date:** [April 19, 2006, 3:23am UTC](https://forum.kirupa.com/t/can-someone-show-me-howto-collision/185735/5 "2006-04-19T03:23:16Z")

</div>

Heres a rather simple way, but it works. :cowboy:  
[AS]var targetPoint:Object = {x:77+(Math.random()\*61), y:\_root[“target1”].\_y};  
onEnterFrame = function () {  
};  
\_root.onMouseUp = function() {  
var noo:MovieClip = \_root.attachMovie(“player”, “plyr1”, 20);  
noo.\_x = \_xmouse;  
noo.\_y = \_ymouse;  
new mx.transitions.Tween(noo, “\_x”, mx.transitions.easing.Back.easeOut, noo.\_x, targetPoint.x, 20);  
new mx.transitions.Tween(noo, “\_y”, mx.transitions.easing.Back.easeOut, noo.\_y, targetPoint.y, 20);  
noo.onEnterFrame = function() {  
if (this.hitTest(\_root.target1) || this.hitTest(\_root.target2)) {  
new mx.transitions.Tween(\_root.target1, “\_x”, mx.transitions.easing.Back.easeOut, \_root.target1.\_x, (\_root.targetPoint.x-\_root.target1.\_width), 10);  
new mx.transitions.Tween(\_root.target2, “\_x”, mx.transitions.easing.Back.easeOut, \_root.target2.\_x, (\_root.targetPoint.x+this.\_width), 10);  
delete this.onEnterFrame;  
}  
};  
};  
[/AS]

---

<div class="post-metadata">

**Author:** ![joran420](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/joran420/32/2329_2.png) [@joran420](https://forum.kirupa.com/u/joran420)\
**Post date:** [April 19, 2006, 5:04am UTC](https://forum.kirupa.com/t/can-someone-show-me-howto-collision/185735/6 "2006-04-19T05:04:37Z")

</div>

awesome thats exactly what i was looking for…  
I think… i need to play with it a lil bit

thanks a ton man 🙂

---

<div class="post-metadata">

**Author:** ![B\_L\_U\_E](https://avatars.discourse-cdn.com/v4/letter/b/ba8739/32.png) [@B\_L\_U\_E](https://forum.kirupa.com/u/B_L_U_E)\
**Post date:** [April 19, 2006, 5:29am UTC](https://forum.kirupa.com/t/can-someone-show-me-howto-collision/185735/7 "2006-04-19T05:29:49Z")

</div>

No prob! :cowboy:
