getBounds xMax, xMin as3?

Hello !

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

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.


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 :frowning:





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 :frowning:

Do you have any idea ?

Thanks in advance !
Julien.