Skip to main content
Radiant_teacher154A
Participant
May 28, 2010
Question

hitTest in As3.0

  • May 28, 2010
  • 1 reply
  • 1593 views

Hi All,

I have a square object in the middle of circle.

and i  can move square object using up, down, left, riht arrow keys. I need script for when square object touches circle, then it goes to back, I have use for this below code :

var myobjdim:Array=new Array;
    myobjdim.rit=obj.x+(obj.width/2);
    myobjdim.let=obj.x-(obj.width/2);
    myobjdim.tp=obj.y-(obj.height/2);
    myobjdim.bot=obj.y+(obj.height/2);
    if(bg1.hitTestPoint(myobjdim.tp,obj.y, true))
    {
        trace("it's detection");
    }

In above code "myobjdim" is square object and "bg1" is circle object..

Please any body know script for this in AS3 plese tell me.

Thanks,

K Swamy Vishnubhatla,

webdeginer.blogspot.com.

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
May 28, 2010

use:



    if(bg1.hitTestObject(myobjdim))
    {
     var ct:ColorTransform=myobjdim.transform.colorTransform;

ct.color=0x000000;

myobjdim.transform.colorTransform=ct;

    }