# Detecting mouse movement in transparent stage

**URL:** https://forum.kirupa.com/t/detecting-mouse-movement-in-transparent-stage/261204
**Category:** flash
**Created:** [May 24, 2008, 7:01am UTC](https://forum.kirupa.com/t/detecting-mouse-movement-in-transparent-stage/261204 "2008-05-24T07:01:36Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![danazoni](https://avatars.discourse-cdn.com/v4/letter/d/e47c2d/32.png) [@danazoni](https://forum.kirupa.com/u/danazoni)
#### Post date: [May 24, 2008, 7:01am UTC](https://forum.kirupa.com/t/detecting-mouse-movement-in-transparent-stage/261204/1 "2008-05-24T07:01:36Z")

</div>

Hello,

I have a flash movie that detects and points to the mouse position (it’s a compass sitting on a table). It works fine as long as the rest of the stage is clear, the problem is when it is embedded into a html file - when the mouse is on areas of text, a box or anything other than the swf itself.

I’ve tried two options -

[LIST=1]  
[_]the .swf is the top layer, with the whole stage being transparent except for the pointing object itself (so it can show the rest of the html underneath) - in this case the mouse is detected only on the opaque area (i.e., the little pointing object).  
[_]the .swf is the background layer (as explained [here](http://www.kirupa.com/forum/showpost.php?p=2227771&postcount=4)) - in this case the mouse is not detected in the areas of the html menu and html text body block that are (in a layer) on top of it.  
[/LIST]  
The problem seems to be that transparent areas (in option 1) and/or covered areas (option 2) are not part of the stage’s scope. Currently, my compass registers to the stage to “listen” to events, is there another way to get mouse position events, outside the scope of the stage?

Or is there any other solution to this problem?

Thanks

---

<div class="post-metadata">

### Author: ![Groady](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/groady/32/3750_2.png) [@Groady](https://forum.kirupa.com/u/Groady)
#### Post date: [May 24, 2008, 7:22am UTC](https://forum.kirupa.com/t/detecting-mouse-movement-in-transparent-stage/261204/2 "2008-05-24T07:22:12Z")

</div>

The short answer is no. Mouse position is only registered over the player itself.

---

<div class="post-metadata">

### Author: ![Felixz](https://avatars.discourse-cdn.com/v4/letter/f/ecb155/32.png) [@Felixz](https://forum.kirupa.com/u/Felixz)
#### Post date: [May 24, 2008, 10:13am UTC](https://forum.kirupa.com/t/detecting-mouse-movement-in-transparent-stage/261204/3 "2008-05-24T10:13:51Z")

</div>

Create a transparent rectangle as child of root

---

<div class="post-metadata">

### Author: ![danazoni](https://avatars.discourse-cdn.com/v4/letter/d/e47c2d/32.png) [@danazoni](https://forum.kirupa.com/u/danazoni)
#### Post date: [May 24, 2008, 8:31pm UTC](https://forum.kirupa.com/t/detecting-mouse-movement-in-transparent-stage/261204/4 "2008-05-24T20:31:43Z")

</div>

> [@Felixz;2330492](#):
>
> Create a transparent rectangle as child of root

Is that any different than dragging an empty box to the stage? because I tried that (borders but no fill, same size as the stage) and the mouse wasn’t detected in the empty/transparent area, only when on top of the (opaque) borders.

If it is different, do you mind explaining how exactly this should be done?

Thanks again

---

<div class="post-metadata">

### Author: ![Felixz](https://avatars.discourse-cdn.com/v4/letter/f/ecb155/32.png) [@Felixz](https://forum.kirupa.com/u/Felixz)
#### Post date: [May 24, 2008, 9:06pm UTC](https://forum.kirupa.com/t/detecting-mouse-movement-in-transparent-stage/261204/5 "2008-05-24T21:06:29Z")

</div>

make no border but only fill, there is no difference what color u use, but make sure that alpha is zero.

```auto
graphics.clear();
graphics.lineStyle();
graphics.beginFill(0,0);
graphics.drawRect(0,0,stage.stageWidth,stage.stageHeight);

```

If u have scaleMode set to NO\_SCALE use RESIZE Event listener to redraw all

---

<div class="post-metadata">

### Author: ![danazoni](https://avatars.discourse-cdn.com/v4/letter/d/e47c2d/32.png) [@danazoni](https://forum.kirupa.com/u/danazoni)
#### Post date: [May 25, 2008, 9:49am UTC](https://forum.kirupa.com/t/detecting-mouse-movement-in-transparent-stage/261204/6 "2008-05-25T09:49:49Z")

</div>

This solution works however it creates another problem - it disables the functionality of the html underneath (for example, the links in the layer below no longer detect hovering and cannot be pressed).

---

<div class="post-metadata">

### Author: ![Felixz](https://avatars.discourse-cdn.com/v4/letter/f/ecb155/32.png) [@Felixz](https://forum.kirupa.com/u/Felixz)
#### Post date: [May 25, 2008, 2:03pm UTC](https://forum.kirupa.com/t/detecting-mouse-movement-in-transparent-stage/261204/7 "2008-05-25T14:03:43Z")

</div>

There is no possibility to have mouse avaiable both to HTML and Flash.  
U can temporarly extend that area and hide on MOUSE\_LEAVE Event

---

<div class="post-metadata">

### Author: ![danazoni](https://avatars.discourse-cdn.com/v4/letter/d/e47c2d/32.png) [@danazoni](https://forum.kirupa.com/u/danazoni)
#### Post date: [May 25, 2008, 5:27pm UTC](https://forum.kirupa.com/t/detecting-mouse-movement-in-transparent-stage/261204/8 "2008-05-25T17:27:21Z")

</div>

> [@Felixz;2330902](#):
>
> U can temporarly extend that area and hide on MOUSE\_LEAVE Event

what do you mean?

---

<div class="post-metadata">

### Author: ![Felixz](https://avatars.discourse-cdn.com/v4/letter/f/ecb155/32.png) [@Felixz](https://forum.kirupa.com/u/Felixz)
#### Post date: [May 25, 2008, 5:33pm UTC](https://forum.kirupa.com/t/detecting-mouse-movement-in-transparent-stage/261204/9 "2008-05-25T17:33:18Z")

</div>

It could be something like an advertisement which expands on mouse over and shrinks when mouse leaves flash area
