Hi all.
I’ve only been working in AS for about two months, and I’ve really appreciated the help I’ve received from the kirupa tutorials and people in these forums. So, I thought I’d ask you all about this little issue I’m facing now.
I’m doing this project right now where I want to simulate fluid flowing through pipes. The pipes have 90* corners and sometimes there are forks in the pipes (splitting it into two pipes). Attempting this with tweened animations seemed to be too complex, so I’m using setInterval and duplicateMovieClip to do it.
I had this idea to use “redirectors,” movieClips would redirect any movieClip that hit them. For instance, if I have a ball_mc moving horizontally and it hits a redirectUp_mc movieClip, the ball_mc’s direction changes to “up”. Of course, there will be many ball_mc clips… and as I start to get more complicated paths, the number of corners increases, too. That causes the number of hitTests (to check if the ball_mc clips are hitting the redirectors) to skyrocket… unless I can find a more efficient way to do it, that is.
Is there a way to check if I’ve hit any instance of the “redirectUp” movieClip? That would cut the number of hitTests down to 4M, which is way better than M*N (where M is the number of ball_mc clips on the stage, and N is the number of redirector_mc clips). Or, is there a better event model to use than hitTest?
I’ve attached my .fla for you to see what I’m doing in the code. It works, but there are a lot of hitTests… I need to cut that down. Any thoughts would be most appreciated. Thanks!