Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Test collision in ActionScript of multiple objects

Posted on 2009-05-02
3
Medium Priority
?
317 Views
Last Modified: 2013-11-11
If I have the movie clips: ball0_mc, ball1_mc, ball2_mc &&.. ball50_mc    and I will like to test if any ball hits a movie clip named target_mc then do I have to type:?

if (ball0_mc.hitTestObject(target_mc) || ball1_mc.hitTestObject(target_mc) || ball2_mc.hitTestObject(target_mc) .......  ball50_mc.hitTestObject(target_mc)  ) {
trace("hit");
}

Is there a way of testing a collision if the movie clip contains the word ball for example? In other words to test the collision of all the movie clips that contains the word ball with the movie clip target_mc?
0
Comment
Question by:TonoNam
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
ID: 24288948
Use hitTest method...


0
 

Author Comment

by:TonoNam
ID: 24290244
I am not familiar with that method. should I write something like hitTest(target_mc)? Moreover I am new to ActionScript 3.0
0
 
LVL 1

Accepted Solution

by:
davidwestfall earned 500 total points
ID: 24291002
You need to setup an array to hold all of the balls.  Once you have the array setup, you can check for the collision like this.
for(var i:int = 0; i < balls.length; i ++) {
     var ball = balls[i];
     trace(ball.hitTestObject(target_mc));
}

Open in new window

0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question