9.15.2006

Yahoo! Maps in Flex 2 / AS3

Currently, the Yahoo! Maps Flash API is only supported in Flash 8 / AS2. Getting it to work in Flex 2 / Flash 9 / AS3 is nothing new. The current work-around is to publish the API in Flash 8, then load it into Flex and talk to the loaded SWF through the local connection. Why? Well, because Flash 9 uses the new, built-from-the-ground up, ActionScript Virtual Machine (AVM), and the loaded Flash 8 SWF uses the old version of the AVM, they can not talk to or access each other directly.

So, until Yahoo! updates the API, here is an example of how to get it to work in Flex 2 / AS3. And as always, right-click to view/download the source.

Also, I wanted to mention that John over at www.programmableweb.com has a great list of Web 2.0 APIs with descriptions, links, and licensing information for each one. Check it out.

** NOTE: I just noticed that if you right-click on the map and select "View Source" nothing happens. This appears to be a bug and/or wonderful feature of loading Flash 8 SWFs into Flash 9. If you right-click on the Flex portion of the example it will work.

6 Comments:

At 9/25/06 7:54 PM, Anonymous Anonymous said...

There is also the ability of using the Flex IFrame and Ajax to load the Yahoo maps API and integrate Flex together with Geo RSS. This is a basic work around from having to go through Flash 8.

 
At 1/8/07 10:21 AM, Anonymous Hans said...

Very nice sample !!!
When I test it locally, everything works fine, but after uploading to a server, I get Actionscript errors :
SecurityError: Error #2122: Security sandbox violation: BitmapData.draw: http://www.nvvandenboschsa.be/hans/bin/nvvdbsa001.swf cannot access http://us.maps3.yimg.com/aerial.maps.yimg.com/img?md=200611151500&x=67093&y=21520&z=1&v=1.6&t=a. A policy file is required, but the checkPolicyFile flag was not set when this media was loaded.

What can I do to solve this?

I tried to create an application id in yahoo and changed it in flash, but it doesn't work.
Any idea what should be the path for the "Web Application URL" on "https://developer.yahoo.com/wsregapp/index.php" ?

Thanks, Hans.

 
At 3/31/07 5:13 PM, Anonymous Florin said...

How can put another startup location ?

 
At 7/31/07 1:42 PM, Blogger vijayan said...

Hi it’s really super its works fine,
But, how to put a map pointer and the tool tip for the particular address. What are the steps I have to do to get this.

Also I need a help to print the map and location in a separate print button do u have any sample code for this.

 
At 8/7/07 2:21 PM, Anonymous Anonymous said...

I noticed that if you open this page in more 2 tabs or windows, the second map will not work. I wonder if this has to do with the local connection.

 
At 11/23/07 11:08 AM, Blogger Matt said...

This is really nice. We've been building Flex map apps for a while now. I have some links at:
http://www.flexmappers.com/about/flex2-maps-ESRI-Mapserver-guide.html
I wanted to mention the (open source) modestmaps. These guys have done some fantastic work with Flash and Flex 2, to hook into Google, Microsoft and Yahoo maps.
Matt Sheehan

 

Post a Comment

Links to this post:

Create a Link

<< Home