We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

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

ocgstyles
ocgstyles asked
on
Medium Priority
322 Views
Last Modified: 2008-03-10
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?
Comment
Watch Question

Technology Architect
Commented:
You can simply implement more advance thing with Goole maps.
Checkout
www.google.com/api/maps

If you need more info about that, don't hesitate to reply to me.

BR Dushan

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Dushan De SilvaTechnology Architect

Commented:
sorry link is..
www.google.com/apis/maps
CERTIFIED EXPERT
Top Expert 2008
Commented:
see where you have written "stopDrag()"

it must be inside, onRelease....


just add "onReleaseOutside" also

for example:

if you have written it on button, add releaseOutside as shown below
--------
on (release, releaseOutside) {
      stopDrag();

}
-------------

if code is written on frame,then add onReleaseOutside as shown below
----------
button.onRelease = button.onReleaseOutside = function(){
      stopDrag();

}
----------


Rgds
Aneesh

Author

Commented:
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

CERTIFIED EXPERT
Top Expert 2008

Commented:
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

Author

Commented:
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...

CERTIFIED EXPERT
Top Expert 2008

Commented:
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

Author

Commented:
i think the google maps suggestion may be a good idea.  looking into that...
CERTIFIED EXPERT
Top Expert 2008

Commented:
google maps are not done in flash.

Have you tried my suggesion, it work pefectly..

Rgds
Aneesh
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.