# How do i make a movie clip appear where the mouse is clicked?

**URL:** https://forum.kirupa.com/t/how-do-i-make-a-movie-clip-appear-where-the-mouse-is-clicked/184948
**Category:** Uncategorized
**Created:** [April 9, 2006, 4:23pm UTC](https://forum.kirupa.com/t/how-do-i-make-a-movie-clip-appear-where-the-mouse-is-clicked/184948 "2006-04-09T16:23:39Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![BevD](https://avatars.discourse-cdn.com/v4/letter/b/4af34b/32.png) [@BevD](https://forum.kirupa.com/u/BevD)
#### Post date: [April 9, 2006, 4:23pm UTC](https://forum.kirupa.com/t/how-do-i-make-a-movie-clip-appear-where-the-mouse-is-clicked/184948/1 "2006-04-09T16:23:39Z")

</div>

Hi,

I’m making a simple spot-the-ball the game and if the user clicks in the incorrect place then I would like to make a cross appear where they have clicked i.e a movieclip appears at the position the mouse has been clicked. I would prefer to attach the code to the button as I understand this a little better.

can anyone point me in the right direction?

Many thanks  
Bev

---

<div class="post-metadata">

### Author: ![rhamej](https://avatars.discourse-cdn.com/v4/letter/r/bb73d2/32.png) [@rhamej](https://forum.kirupa.com/u/rhamej)
#### Post date: [April 9, 2006, 4:51pm UTC](https://forum.kirupa.com/t/how-do-i-make-a-movie-clip-appear-where-the-mouse-is-clicked/184948/2 "2006-04-09T16:51:32Z")

</div>

Like this? =)

---

<div class="post-metadata">

### Author: ![BevD](https://avatars.discourse-cdn.com/v4/letter/b/4af34b/32.png) [@BevD](https://forum.kirupa.com/u/BevD)
#### Post date: [April 9, 2006, 5:05pm UTC](https://forum.kirupa.com/t/how-do-i-make-a-movie-clip-appear-where-the-mouse-is-clicked/184948/3 "2006-04-09T17:05:13Z")

</div>

> [@rhamej](#):
>
> Like this? =)

Yes exactly like that thank you very much except there are 7 games in all each with 3 attempts to get it right. So what would I need to do to clear the x’s from the screen from one game once the user presses a button to continue onto the next game?

thanks again for your help.

---

<div class="post-metadata">

### Author: ![icleric](https://avatars.discourse-cdn.com/v4/letter/i/4bbf92/32.png) [@icleric](https://forum.kirupa.com/u/icleric)
#### Post date: [April 9, 2006, 5:20pm UTC](https://forum.kirupa.com/t/how-do-i-make-a-movie-clip-appear-where-the-mouse-is-clicked/184948/4 "2006-04-09T17:20:56Z")

</div>

make the movieclip containing your cross, then from your library, right click on it and linkage then mark export for AS then give it an id name, c for instance… then place this code in your action pannel

```auto

onLoad=function(){
count = 0;
}
_root.onMouseDown = function(){
	if(condition!=0){
	count++;
	t = _root.attachMovie("c", "c"+count, _root.getNextHighestDepth())
	t._x = _root._xmouse;
	t._y = _root._ymouse;
	}
	t.onEnterFrame=function(){
	_root.condition=0;
	t._alpha -= 12;
	if(t._alpha <= 0){removeMovieClip("c"+count);	_root.condition=1;};

	}
}

```

---

<div class="post-metadata">

### Author: ![rhamej](https://avatars.discourse-cdn.com/v4/letter/r/bb73d2/32.png) [@rhamej](https://forum.kirupa.com/u/rhamej)
#### Post date: [April 9, 2006, 5:33pm UTC](https://forum.kirupa.com/t/how-do-i-make-a-movie-clip-appear-where-the-mouse-is-clicked/184948/5 "2006-04-09T17:33:48Z")

</div>

try this =)

---

<div class="post-metadata">

### Author: ![icleric](https://avatars.discourse-cdn.com/v4/letter/i/4bbf92/32.png) [@icleric](https://forum.kirupa.com/u/icleric)
#### Post date: [April 9, 2006, 5:35pm UTC](https://forum.kirupa.com/t/how-do-i-make-a-movie-clip-appear-where-the-mouse-is-clicked/184948/6 "2006-04-09T17:35:34Z")

</div>

soz i didnt see rhamej before postin 🙂

---

<div class="post-metadata">

### Author: ![BevD](https://avatars.discourse-cdn.com/v4/letter/b/4af34b/32.png) [@BevD](https://forum.kirupa.com/u/BevD)
#### Post date: [April 9, 2006, 5:40pm UTC](https://forum.kirupa.com/t/how-do-i-make-a-movie-clip-appear-where-the-mouse-is-clicked/184948/7 "2006-04-09T17:40:41Z")

</div>

> [@icleric](#):
>
> make the movieclip containing your cross, then from your library, right click on it and linkage then mark export for AS then give it an id name, c for instance… then place this code in your action pannel
> 
> ```auto
> 
> onLoad=function(){
> count = 0;
> }
> _root.onMouseDown = function(){
> if(condition!=0){
> count++;
> t = _root.attachMovie("c", "c"+count, _root.getNextHighestDepth())
> t._x = _root._xmouse;
> t._y = _root._ymouse;
> }
> t.onEnterFrame=function(){
> _root.condition=0;
> t._alpha -= 12;
> if(t._alpha <= 0){removeMovieClip("c"+count);	_root.condition=1;};
> 
> }
> }
> 
> ```

Thanks for you help here!

just one last thing, I want to attach this to a hotspot which denotes the area of the screen where the answer is incorrect and I’ve defined this with an invisible button.

This hotspot already has this code attached to the button itself:

```auto
on(release) {
	attempts=(attempts)+1
	results.gotoAndPlay("guess");
	
}

```

With the code you have just given me I’ve tried adding in the instance name of the button to the function so that: \_root.onMouseDown = function() becomes \_root.incorrect\_btn.onMouseDown = function() but this doesn’t work!

i’m no expert by any means but I’m guessing that by having code attached to the button as well as in a function means that flash is getting confused? How would I combine the above into the function you’ve given to me?

Cheers again and thanks for your patience  
Bev.

---

<div class="post-metadata">

### Author: ![icleric](https://avatars.discourse-cdn.com/v4/letter/i/4bbf92/32.png) [@icleric](https://forum.kirupa.com/u/icleric)
#### Post date: [April 9, 2006, 5:49pm UTC](https://forum.kirupa.com/t/how-do-i-make-a-movie-clip-appear-where-the-mouse-is-clicked/184948/8 "2006-04-09T17:49:17Z")

</div>

try \_root.incorrect\_btn.onRelease = function()…

or onPress, whatever suits what you’re tryin to accomplish

---

<div class="post-metadata">

### Author: ![BevD](https://avatars.discourse-cdn.com/v4/letter/b/4af34b/32.png) [@BevD](https://forum.kirupa.com/u/BevD)
#### Post date: [April 9, 2006, 6:33pm UTC](https://forum.kirupa.com/t/how-do-i-make-a-movie-clip-appear-where-the-mouse-is-clicked/184948/9 "2006-04-09T18:33:42Z")

</div>

> [@icleric](#):
>
> try \_root.incorrect\_btn.onRelease = function()…
> 
> or onPress, whatever suits what you’re tryin to accomplish

thanks for your help - that work’s great 🍺
