hi Martin,

If the panorama tool is a 'drag to pan' system and you need to detect the mouse release outside of the Flash area, try this:

Place an invisible button over the entire dragged button, which might be the whole stage. Set this invisible button to goto a blank frame and stop on rollover, leaving the original panorama drag button to pick up it's rollover or onDown(and drag) signal from the cursor.

For some reason this allows Flash to detect when the mouse is released outside of the player (out in the html page) and triggering the on release function of the dragged button - sending the dragged button back to it's starting (stopped) position, where it should also have a command to make sure the panning is halted.

Have no idea why it works, but figured it out when trying to stop scrolling when cursor is released outside the player at: http://www.2GoTo.com... works great.

If you can't get this to work, i can build an exact working example for you.

Dave_Matthews



------------------------------original messages--------------------------

Message: 12
Date: Wed, 23 Nov 2005 10:10:32 +0100
From: "Martin Klasson" <[EMAIL PROTECTED]>
Subject: [Flashcoders] detecting when mouse goes outside of the flash

Hi coders.

This has been up before, and I have done some own tests and searched the
archives as well.

But I can't find the solution, if there is any.

I want a certain thing to happen in my flash when the mouse moves
outside flash. Since the _xmouse/_ymouse stops updating when dragged
outside you cant rely on them (they do work WHEN mouse is pressed and
dragged out from the swf, but that is of course not a solution)

I have also tried to add a big 'button' which has onRollOut/onDragOut
attached to it, but the problem is that button-events above it will
disable the underlying one.

So what I know of there is no solution to this problem, but probably
some decent hacks?

I am not interested in a solution which requires code in the html-page
or so, but if you have such one I would like to know about it as well.

But mainly I wish to know a solution in which flash internally can say
if the mouse-cursor is outside the flash in the html-page.

Thanks Coders

/ martin
---------------------------------------------------------------------------
Message: 15
Date: Wed, 23 Nov 2005 23:02:20 +1300
From: "Campbell Anderson" <[EMAIL PROTECTED]>
Subject: Re: [Flashcoders] detecting when mouse goes outside of the
        flash

If you ever do a cursor replace in a flash movie you will see that when
the cursor leaves the stage the cursor you create stays at the
edge...... so Im pretty sure that you if you listen to the mouse
position and it goest to within on pixel from the stage width its a safe
bet it has gone out.....

a mouse listener:

var xpos:Number;
var ypos:Number;

// Create a mouse listener object
var mouseListener:Object = new Object();

// Every time the mouse cursor moves within the SWF file
mouseListener.onMouseMove = function() {
   xpos = _xmouse;
   ypos = _ymouse;
CheckPosition(xpos, ypos);
};

function CheckPosition(_xpos:Number, _ypos:Number){
        var _StageWidth:Number = Stage.width;
        var _StageHeight:Number = Stage.height;
        //have a buffer zone around the edge to give time to catch event
        var Buffer:Number = 10; //10 pixels

        if(xpos>=(_StageWidth-Buffer) || ypos>=(_StageHeight-Buffer) ||
xpos<=Buffer || ypos<=Buffer){
                result_txt.text = "out";
        }
        else{
                result_txt.text = "in";
        }
}

Mouse.addListener(mouseListener);
stop();


you could use an on enterframe and a decent frame rate and it may get a
better acuracy.

The biggest problem is this isnt 100% but at least it gives you a
starting point.

------------------------------

Message: 14
Date: Wed, 23 Nov 2005 10:43:19 +0100
From: Hans Wichman <[EMAIL PROTECTED]>
Subject: Re: [Flashcoders] detecting when mouse goes outside of the
        flash

Hi,
i had the same problem and approached it a little differently, which might
be or not be of use to you.
I simply check whether the mouse has moved or not.

Your situation might be very different, but in mine I had to update the
rotation in a panorama based on the mouse position within that panorama.
If you'd mouse the out real quick, the panorama went spinning ;) and never
stopped.

So now return an dx/dy based on mouse position and altered by the amount of
time the mouse hasnt moved. In effect if you move your mouse to the left in
the panorama for example it will move quickly at first and slowly grind to
a halt. Same thing happens when you move the mouse outside.

Other that than.... no clue...

greetz
Hans

------------------------------

Message: 16
Date: Wed, 23 Nov 2005 23:14:04 +1300
From: "Campbell Anderson" <[EMAIL PROTECTED]>
Subject: Re: [Flashcoders] detecting when mouse goes outside of the
        flash

P.S. to make it more reliable (but I realise you not happy with using
browser code...would be to surrond the flash movie with a div and have a
javascript listen for a on mouseover and call an fscommand or
externalinterface call (depending on the version of flash).

c.


_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to