# Problem with MouseEvent.CLICK and visibility of Sprite object

**URL:** <https://forum.kirupa.com/t/problem-with-mouseevent-click-and-visibility-of-sprite-object/291065>\
**Category:** flash\
**Created:** [June 24, 2009, 6:08am UTC](https://forum.kirupa.com/t/problem-with-mouseevent-click-and-visibility-of-sprite-object/291065 "2009-06-24T06:08:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![SrihariCh](https://avatars.discourse-cdn.com/v4/letter/s/f1d935/32.png) [@SrihariCh](https://forum.kirupa.com/u/SrihariCh)\
**Post date:** [June 24, 2009, 6:08am UTC](https://forum.kirupa.com/t/problem-with-mouseevent-click-and-visibility-of-sprite-object/291065/1 "2009-06-24T06:08:47Z")

</div>

Hi all,

```
      I am loading an image using Loader object dynamically on the stage.It works successfully. Here, my loader instance name is: myLoader.

     When I click on the dynamically loaded image, I need to place a small red rectangle at that particular pixel position on the image. For creating a small rectangle, I am using following code:

```

```auto

var redRect:Sprite = new Sprite();
redRect.graphics.beginFill(0xff0000);
redRect.graphics.drawRect(evnt.localX,evnt.localY,7,7);
addChild(redRect);
trace("redRect.visible: "+redRect.visible);

```

My requirement is,  
Whenever I click on this loaded image for first time, I need to display the redRect(rectangle which is red in color) over that pixel-position(say,old\_x & old\_y coordinates) where I have clicked.  
Now, if I again click on the same image for the second time (at a different pixel-position), then the redRect which is already displayed must be made hidden and the redRect must be created(displayed) at new pixel-position(i.e., new\_x,new\_y) and made visible and so on.

```
   Hence, in this way, we need to display the redRect at latest/newly captured pixel-position and must be invisible at all earlier/former/old pixel-positions. 

```

\*\*Hence, all I want is to save the pixel-position values(viz., x & y) where the event had occured latestly.  
\*\*

How to solve my issue?  
Please can anyone reply me the solution for this above issue by sparing 2 minutes of your valuable time in filling this gap of my work.

Thanks in advance…  
Waiting for yor replies…

Srihari.Ch
