A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Can someone explain to me why this simple hitTest wont work.

  1. #1
    Amiga freak Ironclaw's Avatar
    Join Date
    Jan 2001
    Location
    Sweden
    Posts
    1,650

    Can someone explain to me why this simple hitTest wont work.

    They only hit when both red mcs are placed in the root, but not when they are in another mc. Why is that?

  2. #2
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    I think hitTest uses coordinates based on the global coordinate space, not the coordinates within a movie clip.

    so to make the hitTest work you could use localToGlobal to find the global coordinates of the clip,

    Code:
    onClipEvent (enterFrame) {
    	this._y += 2;
    	var pt = {x: this._x, y: this._y};
    	_parent.localToGlobal(pt);
    	if (_parent.area.hitTest(pt.x, pt.y, true)) {
    		trace("hit");
    	}
    }

  3. #3
    Amiga freak Ironclaw's Avatar
    Join Date
    Jan 2001
    Location
    Sweden
    Posts
    1,650
    Oh, does it have to be so complicated?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center