Hi every body
I've been looking around without great success to solve this little problem of mine and it goes like this;
By clicking two button on stage I create two MovieClips called EVE and BLOCK... That's because the buttons display objects with addChild.
function newMcEvent():void
{
var eve:MovieClip = new event_graphic();
eve.x = 50;
eve.y = 350;
eveNum++;
eve.name = "eve " + eveNum;
addChild(eve);
eventArray.push(eve);
for (var i:int = 0; i<eventArray.length; i++)
{
eventArray[i].addEventListener(MouseEvent.MOUSE_UP, touch);
eventArray[i].addEventListener(MouseEvent.MOUSE_DOWN, drag);
eventArray[i].addEventListener(MouseEvent.MOUSE_UP, noDrag);
eventArray[i].addEventListener(MouseEvent.MOUSE_DOWN, snap);
}
}
function newMcBlock():void
{
var blc:MovieClip = new block();
blc.x = 50;
blc.y = 350;
blcNum++;
blc.name = "blc " + eveNum;
addChild(blc);
blockArray.push(blc);
for (var i:int = 0; i<blockArray.length; i++)
{
blockArray[i].addEventListener(MouseEvent.MOUSE_UP, touch);
blockArray[i].addEventListener(MouseEvent.MOUSE_DOWN, drag);
blockArray[i].addEventListener(MouseEvent.MOUSE_UP, noDrag);
}
}
BLOCK has the same code as EVE and has also a small invisible area that I want to use for snapping objects (called SNAP, it's a nested movie clip!)...
What I want to do is to add to EVE an EventListener.MOUSE_DOWN that triggers a function called snap... this way I can check if EVE is actually HitTesting the movie clip BLOCK....
I manage to write down this code
function snap(e:MouseEvent):void
{
if (e.currentTarget.hitTestObject(Object(root).blc))
{
trace("ok");
}
}
It returns Error #2007: Parameter hitTestObject must be non-null. which I take as the fact it can't find BLOCK or some reason, but it's there I swear!
Any idea?
North America
Europe, Middle East and Africa
Asia Pacific