質問

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