# Apply specified Function to multiple of movie clips

**URL:** <https://forum.kirupa.com/t/apply-specified-function-to-multiple-of-movie-clips/286227>\
**Category:** flash\
**Created:** [April 12, 2009, 9:33am UTC](https://forum.kirupa.com/t/apply-specified-function-to-multiple-of-movie-clips/286227 "2009-04-12T09:33:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![music\_fuel](https://avatars.discourse-cdn.com/v4/letter/m/58f4c7/32.png) [@music\_fuel](https://forum.kirupa.com/u/music_fuel)\
**Post date:** [April 12, 2009, 9:33am UTC](https://forum.kirupa.com/t/apply-specified-function-to-multiple-of-movie-clips/286227/1 "2009-04-12T09:33:28Z")

</div>

[FONT=Verdana]How would I apply my existing function that involves calculating the x and y position of a specified movie clip, to multiples of movieclips. [/FONT]  
[FONT=Verdana] [/FONT]  
[FONT=Verdana] [/FONT]  
[FONT=Verdana]MY MOVIECLIPS on stage are[/FONT]  
[FONT=Verdana] [/FONT][FONT=Verdana]

```auto
 
[FONT=Verdana] Ball_mc [/FONT]
[FONT=Verdana] Ball_mc2[/FONT]
[FONT=Verdana] Ball_mc3 [/FONT]

```

[/FONT]  
[FONT=Verdana] [/FONT]  
[FONT=Verdana] [/FONT]  
[FONT=Verdana]MY FUNCTION is [/FONT]  
[FONT=Verdana]

```auto
 
[FONT=Verdana]function hitDetect(event):void {[/FONT]
[FONT=Verdana] [/FONT]
[FONT=Verdana]var ballX:Number = (ball_mc.x-videoX)/sizeDif[/FONT]
[FONT=Verdana]var ballY:Number = (ball_mc.y-videoY)/sizeDif[/FONT]
[FONT=Verdana] [/FONT]
[FONT=Verdana]var valNow:Number = (now.getPixel(ballX, ballY) >> 16 & 0xFF);[/FONT]
[FONT=Verdana]var valBefore:Number = (before.getPixel(ballX, ballY) >> 16 & 0xFF);[/FONT]
[FONT=Verdana] [/FONT]
[FONT=Verdana]}[/FONT]

```

[/FONT][FONT=Verdana] [/FONT]  
[FONT=Verdana][/FONT]  
[FONT=Verdana]Should I use Arrays? Loop? Or Any other suggestions? Examples in code would be appreciated. Thanks[/FONT]
