Link to home
Start Free TrialLog in
Avatar of ocgstyles
ocgstyles

asked on

Flash - Detecting Movement Outside of Stage in SWF Embedded in HTML

I'm trying to make a map using Flash MX that will be embedded in a web page.  The problem I'm having is with the maps movement.

Here's a sample of what I'm trying to achieve:
http://maps.mapnetwork.com/floridakeys/cvb/index.asp

Notice that you can move the map around.  You can still move the map when the cursor is in the white part of the screen.  The map will stop moving when you release the mouse outside the stage too.

My map, it doesn't do that.  

If I use startDrag() to start dragging on mouseDown and release outside of the stage, stopDrag doesn't work.  

Only thing I can think of is that Flash isn't detecting these mouse movements, and maybe they are passed in using FSCommand.

Can anyone give me some guidance?
ASKER CERTIFIED SOLUTION
Avatar of Dushan Silva
Dushan Silva
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Aneesh Chopra
Aneesh Chopra
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ocgstyles
ocgstyles

ASKER

forgot about that...
that may work for one half of it.  i'll elaborate.

i am coding two ways to move the map.
  1) using startDrag() and stopDrag()
  2) using a "controller" movieclip to detect mouse movement.  the controller will move the map using fancy acceleration etc.

so the releaseOutside should work for the first method.  

only problem is the controller uses onClipEvents (mouseMove, mouseDown, mouseUp) to detect the mouse state.  When I leave the stage, the code for onClipEvent(mouseUp) is never called.  

here's a sample of the map:
http://www.modunique.com/ee/map.html

then, you should use the "release, releaseOutside" event instead of "mouseup"

there will not be much change....

just change the event declaration with following

replace this:
----------
onClipEvent(mouseUp){
--------

with:
-------
on (release, releaseOutside) {
------

Rgds
Aneesh
i thought using on(release, releaseOutside) will turn the movieclip into a button.  i thought that because the cursor turns into a hand.  will the other events (enterFrame) still work after attaching the on(...) event handler?  i'll have to give that a try...

if you dont want the cursor turns into a hand..

do this..


if your btn instance name is "btn"

write the following code on frame..(not on button)
-------------
btn.useHandCursor=false;

btn.onRelease=btn.onReleaseOutside = function(){
 stopDrag();
}
---------------

now cursor will not change to "hand"

Rgds
Aneesh
i think the google maps suggestion may be a good idea.  looking into that...
google maps are not done in flash.

Have you tried my suggesion, it work pefectly..

Rgds
Aneesh