views:

458

answers:

2

I have a container Canvas named "cnvList" which contains another component horizontal list "hlist". When i hover the mouse over "cnvList", it should display the current mouse position relative to the container cnvList. I have used cnvList.contentMouseX for this. But it should repeatedly track the mouse position repeatedly even when the mouse is not movedk. Can anyone suggest me with code how it can be done?

+1  A: 

Try using the Event.ENTER_FRAME (enterFrame) event on the Canvas, let me know if that does it.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application
    xmlns:mx="http://www.adobe.com/2006/mxml"
    layout="absolute">

    <mx:Canvas id="cnvList" width="100%" height="100%"
        enterFrame="trace(cnvList.contentMouseX)">
        <mx:HBox id="hlist" width="100%" height="100%"/>
    </mx:Canvas>
</mx:Application>
viatropos
Does enterFrame="trace(cnvList.contentMouseX)" provide us the current mouseposition continously even if we dont move mouse or just provides one instance of mouse position?
Roshan
it provides the current mouse position continuously even if you don't move it.
viatropos
Thnx for ur help
Roshan
A: 

Alternatively you try "mouseMove" instead of "enterFrame" to get a trace only when the mouse is moved. You can also add an event listener to Application.application or even the stage itself to get notification when the mouse is moved anywhere in the app.

cliff.meyers