# getBounds xMax, xMin as3?

**URL:** <https://forum.kirupa.com/t/getbounds-xmax-xmin-as3/283497>\
**Category:** Uncategorized\
**Created:** [March 6, 2009, 10:35pm UTC](https://forum.kirupa.com/t/getbounds-xmax-xmin-as3/283497 "2009-03-06T22:35:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dimebagplan](https://avatars.discourse-cdn.com/v4/letter/d/779978/32.png) [@Dimebagplan](https://forum.kirupa.com/u/Dimebagplan)\
**Post date:** [March 6, 2009, 10:35pm UTC](https://forum.kirupa.com/t/getbounds-xmax-xmin-as3/283497/1 "2009-03-06T22:35:17Z")

</div>

Hello !

I am trying to adapt an As2 function to As3.  
It is perfect collision with 2 rectangles. (also works with rotation 😉 )

the code below works very well, but it look like some of the properties doesn’t work in As3 ? (like xMin, xMax etc…).  
Here is what i have in As2.

```auto

function advCollision(mc1:MovieClip, mc2:MovieClip):Boolean {   
   var mc1Bounds:Object = mc1.getBounds(mc1);
   var mc2Bounds:Object = mc2.getBounds(mc1);
   
   return ((mc1Bounds.xMin <= mc2Bounds.xMax)
      && (mc1Bounds.xMax >= mc2Bounds.xMin)
      && (mc1Bounds.yMin <= mc2Bounds.yMax)
      && (mc1Bounds.yMax >= mc2Bounds.yMin));
}

this.onEnterFrame = function () {
    rect1._y+=1;
    rect2._y-=1;
    
    if (advCollision(rect1, rect2)){
        trace ("ok");
    }
}

```

And here is what i have done in As3 with no succes ☹

```auto

function advCollision(mc1:MovieClip, mc2:MovieClip):Boolean {  
   var mc1Bounds:Object = mc1.getBounds(mc1);
   var mc2Bounds:Object = mc2.getBounds(mc1);
   
   return ((mc1Bounds.xMin <= mc2Bounds.xMax)
      && (mc1Bounds.xMax >= mc2Bounds.xMin)
      && (mc1Bounds.yMin <= mc2Bounds.yMax)
      && (mc1Bounds.yMax >= mc2Bounds.yMin));
}

this.addEventListener(Event.ENTER_FRAME, action);

function action(e:Event){
    rect1.y+=1;
    rect2.y-=1;
    
    if (advCollision(rect1, rect2)){
        trace ("hit");
    }   
}

```

I tried to replace xMin bt left ? xMax by width ? yMin by top and yMax by height.

But it doesn’t work ☹

Do you have any idea ?

Thanks in advance !  
Julien.
