# Actionscript For Duplicated Movieclips

**URL:** <https://forum.kirupa.com/t/actionscript-for-duplicated-movieclips/271698>\
**Category:** flash\
**Created:** [September 26, 2008, 4:08pm UTC](https://forum.kirupa.com/t/actionscript-for-duplicated-movieclips/271698 "2008-09-26T16:08:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![alleballe90](https://avatars.discourse-cdn.com/v4/letter/a/9fc348/32.png) [@alleballe90](https://forum.kirupa.com/u/alleballe90)\
**Post date:** [September 26, 2008, 4:08pm UTC](https://forum.kirupa.com/t/actionscript-for-duplicated-movieclips/271698/1 "2008-09-26T16:08:37Z")

</div>

so heres my problem, im working on a game where duplicated enemies come scrolling in from the side of the screen. and ive made a turret thats automatically supposed to aim at a random enemy.

heres my code that i put in the turret:

onClipEvent (enterFrame) {  
myRadians = Math.atan2(\_root.enemy1.\_y-this.\_y, \_root.enemy1.\_x-this.\_x);  
myDegrees = Math.round((myRadians\*180/Math.PI));  
this.\_rotation = myDegrees+90;  
this.setDepths  
}

since its \_root.enemy1 it only aims at the enemy1. and if i change it to enemy2 it aims at another enemy. but what i want is for it to aim at a random enemy? how do i do that? please PLEASE PLEASE help me. :pac:
