I have action
MC1.addEventListener (MouseEvent.MOUSE_OVER, MC1_over);
can a use other MC instead of Mouse? In other words, when MC2 will be over MC1, my action will start. How do that? Thanks for help
I have action
MC1.addEventListener (MouseEvent.MOUSE_OVER, MC1_over);
can a use other MC instead of Mouse? In other words, when MC2 will be over MC1, my action will start. How do that? Thanks for help
On
Thank you. Everything works great when I do this on new as3 file. But i need to use this in class document When i use
addEventListener(Event.ENTER_FRAME, onEnterFrame);
function onEnterFrame(e:Event):void
{
if(MC1.getRect(this).intersects(MC2.getRect(this)))
{
trace("intersects")
}
}
Erron#1034: cannot convert type global@23b3a0d1 on flash.display.DisplayObject.
Perhaps You known where is problem?
You'll have to check for intersection. It's called HitTesting and there are several ways to approach this. But first - it won't be an Event anymore, you'll have to check for an intersection in every frame. So first of all, we need to create a new Event.ENTER_FRAME listener.
Second, we check our objects for an intersection of their boudary rectangles. It's ok if you have sqare or rectangular movieclips, if your MCs are more complex (two circles for example) you'll have to use other ways of getting this intersection.
Third, as long as this condition will be true as long as your MCs are intersecting, we need to define a flag that will tell us if we've already done something we wanted to do.
If you want to do something continiously, when your movieclips are intersecting, just ignore that helping flag thing.
And by the way, I suggest you to start names your variables with a lowercase letter. In AS3 only Classes and Interfaces have names that start with a capital letter.