I'm working on a flash project with actionscript 2.0 and i need to check if there's a movie clip on a specific position of stage. Is there a function for that? Thanks :)

有帮助吗?

解决方案

MovieClips have the hitTest() method, which can test against containing the point in it's rectangle hitbox. (if your movieclips are circle shaped, it can instead be accurately done by checking if the center distance to the point exceeds the MovieClip's radius). Now you just need a list of all your movieclips. If you added them all to _root (not reccomened), do like this:

for(var i:int = 0; i < _root.numChildren; i++) {
    if(_root.getChildAt(i).hitTest(x,y)) //x and y of your point
    return true; //or return the MovieClip/whatever you want
}

Otherwise create your won list of MovieClips to check.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top