# Pulling random MovieClips with an onMouseDown Listener

**URL:** <https://forum.kirupa.com/t/pulling-random-movieclips-with-an-onmousedown-listener/244486>\
**Category:** flash\
**Created:** [November 19, 2007, 12:50am UTC](https://forum.kirupa.com/t/pulling-random-movieclips-with-an-onmousedown-listener/244486 "2007-11-19T00:50:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mtsfestivus](https://avatars.discourse-cdn.com/v4/letter/m/eb9ed0/32.png) [@mtsfestivus](https://forum.kirupa.com/u/mtsfestivus)\
**Post date:** [November 19, 2007, 12:50am UTC](https://forum.kirupa.com/t/pulling-random-movieclips-with-an-onmousedown-listener/244486/1 "2007-11-19T00:50:08Z")

</div>

Hello all. This is pretty simple and I think I’m pretty close, but I can’t seem to get this to work. Basic functionality will be that wherever you click on the stage, a random MovieClip will be displayed.

I’ve been out of the Flash game for a few months so I’m quite rusty. Any help is greatly appreciated.

```auto
class Main {
	private var $mcRef:MovieClip;
	private var $myArray01:Array;
	private var $clickListener:Object;
	
	public function Main() {
		this.$mcRef.$clickListener.owner = this;
		Mouse.addListener($clickListener);
		this.$mcRef.$clickListener.onMouseDown = function():Void {
			this.owner._x = _xmouse;
			this.owner._y = _ymouse;
			this.owner.randStar();
		}
	}
	
	private function randStar():Void {
		this.$myArray01 = new Array("star01", "star02", "star03", "star04", "star05");
		var myArrayLength:Number = this.$myArray01.length;
		var inRand:Number = random(myArrayLength);
		this.$mcRef.attachMovie($myArray01[inRand], $myArray01[inRand]+"_2", 1);
	}
}

```
