Yahoo! Actionscript 3 API Library launched today.
I am proud to announce the new Yahoo! AS3 Libraries that were released today on the Yahoo! Flash Developer Network. We timed this launch with the 360Flex conference in San Jose at the Ebay campus. I will be presenting the Yahoo! AS3 Maps Commuication Kit tomorrow morning. As a side note this is my first contribution to the Yahoo Developer Network since I started here a couple months ago. Let us know what you think, and what else you would like to see. We’re here to make your job easier. We don’t want you to worry about accessing all of our data, we want you to concentrating on creating the best application with our data.
Happy Mashing!
49 Responses so far
Tim
March 5th, 2007
11:59 pm
This looks great. I think I might have a record for the shortest lived project ever with FlexMap.
Mrinal Wadhwa
March 6th, 2007
12:00 am
Hi Scott
The api is GREAT!!! and I’m very excited about it … I even started making a small mashup but I could not find a method to programatically set MapType to say Hybrid. I was expecting this to be in the MapController.
Am I missing something here?
Thank you
Derrick
March 7th, 2007
12:01 am
Hey, nice work. Legible comments in your code, a first
, must be the sunny weather.
Anupam
March 8th, 2007
12:01 am
Hi Scott,
For some time i am playing with AS3 toolkit of yahoo maps..
I have certain issues with it..
I could not get the CustomPOIMarker click event using that tool kit..
So i tried to extend the code provided by Yahoo..
Here is the problem i can get the click event but i m not able to get the data which is passed by the EVENT_POI_CLICK i.e Latlon and Marker object..
When i try to debug through the code i got the error like..
undefined
at flash.external::ExternalInterface$/call()
at com.yahoo.webapis.maps.utils::ExternalInterfaceBuffer/com.yahoo.webapis.maps.utils:ExternalInterfaceBuffer::methodChurn()[D:\anupam.shah\Flex\yahoo-as3-api-libraries-1.0.0-beta\source\as3\com\yahoo\webapis\maps\utils\ExternalInterfaceBuffer.as:104]
at Function/http://adobe.com/AS3/2006/builtin::apply()
at ()
at flash.utils::SetIntervalTimer/flash.utils:SetIntervalTimer::onTimer()
at flash.utils::Timer/flash.utils:Timer::_timerDispatch()
at flash.utils::Timer/flash.utils:Timer::tick()
I am pretty stuck with this..Can you provide some kind of help on this issue..
The changes which i have made in the code are like this..
in the source folder..
AS3/
com–>yahoo–>webapis–>maps
–>events–>MapEventDispatcher.as
–>methodgroups–>MapController.as
AS2/
as2map.fla
com–>yahoo–>webapis–>maps
–>MapService.as
These are the 3 files that i have added mathod to handle POICLICK event.
Please tell me if i am missing some thing
I really appreciate your efforts in providing the AS3 library for Yahoo Maps
Thanks,
Anupam
Mrinal Wadhwa
March 8th, 2007
12:02 am
Hi Scott,
Thank you for adding the setMapType function to the new update of the API .. The Yahoo AS3 API is awesome.
Thank you
Scott
March 8th, 2007
12:03 am
Anupam, download the latest version (beta 1.0.1) of the communication kit that is up on http://developer.yahoo.com/flash/as3_api_libraries.html. There were a few tweaks in it that might help you out.
The as2 MapService.as class is not used anymore.
I hope that helps,
Scott
2007-03-08 00:00:00
Anupam
March 8th, 2007
12:03 am
Hi Scott,
Thanks for the comment. I have not tried the communication kit yet but will definitely let u know once i use it.
The quick question that comes to my mind is that are you planning to give all the methods in the communication kit in the future release. or we will get the fully functional apis from yahoo to use in flex 2.0?
We are planning an enterprise level application using flex 2.0 and yahoo maps.
So we need to make decision about which api version to use?
Can you provide some details on this matter?
Thanks and regards,
Anupam
Anupam
March 8th, 2007
12:04 am
Hi Scott,
I have tried the communication kit. and added a method to handle the poi marker click event in the latest version.
There are few problems that i am facing.
1. While debugging the application using flex builder it is giving the same error as
undefined
at flash.external::ExternalInterface$/call()
at…….
which i have posted before.
2. I have added the method poiMarkerClicked in as2map.fla file and also in the file MapEventDispatcher.as from the as3 folder of the source.
I am able to catch the event in the flex and get the latlon object from it.
but when i try to get the marker description etc. i am getting the empty string
and the last result object is not null!
I am pasting the function code that i have written in as2map.fla file
function poiMarkerClicked(ev:Object) {
var rtnObj:Object = new Object();
rtnObj[index] = ev.marker.index.toString();
rtnObj[description] = ev.marker.description.toString();
rtnObj[title] = ev.marker.title.toString();
EIBuffer.addCall({method:swfDomId + “.poiMarkerClicked” + id, data:rtnObj});
}
I think i should be able to get the title,description and index using lastresult object from flex but i am getting empty strings.
3. One very basic question as i am newbie in Action Script. I have seen that marker object which i get is of movieclip type. Can i pass the movie clip object from as2 and consume it in Flex 2.0?
Sorry for writing big posts on the blog but i cant find any answers on the yahoo group flash developer mailing list.
Can you please provide some information regarding this issues?
Any help will be greatly appreciated.
Thanks
Anupam
Venkat
March 8th, 2007
12:04 am
I am trying the same thing as Anupam stated above. Any ideas on this will be greatly appreciated. thanks.
venkat
Scott
March 8th, 2007
12:05 am
Hi guys,
The AS2 Maps Component beta 3.5 events will be added to the AS3 Maps Communication kit very soon. This includes the onPOIMarkerClicked event. I added the event today, but it has not yet been posted as we are just testing it before we release it.
I will also be posting a tutorial on extending the architecture once we get our blog set up on the Yahoo! developer center.
Make sure you have the latest 1.0.1 beta of the Communication kit downloaded from the site as it has the most up to date fla, and the proper class file that goes along with it.
Thank you for your support
Scott
venkat
March 9th, 2007
12:06 am
761 – Yahoo! Actionscript 3 API Library launched today.
That is great news Scott. You did a fantastic job with the maps communication kit. I will be checking back for the new maps with the events added. Cant wait to give it a try.
- venkat
Scott
March 10th, 2007
12:06 am
Hey guys,
The new library has been posted on the developer network. Download it and update your files. The swf and class files have all been updated, all the new events (including the onPOIClicked event) in the 3.5 beta of the AS2 component have been added. Once again, thanks for supporting this project.
Enjoy!
Scott
venkat
March 10th, 2007
12:07 am
Thanks you very much for the new library Scott. I will try it out soon.
Anupam
March 11th, 2007
12:07 am
Hi Scott,
Thanks a lot for the great support to the AS3 library…
I am trying it out today…Will keep you posted about it..
Thanks a ton..
Cheers,
Anupam
Anupam
March 12th, 2007
12:08 am
Hi Scott,
I have checked the new AS3 communication toolkit and especially onPoiClick Event. But the method doesn’t give any information about the marker object that we get in Flash Api.
I have tried to extend the method and got success in doing so.
I am posting my code here so if there is something wrong plz provide your inputs.
function onPOIClicked(ev:Object) {
var rtnObj:Object = new Object();
var myMarker:Object = ev.marker;
for (var p in myMarker) {
rtnObj[p] = myMarker[p].toString();
}
for (var q in ev){
if (typeof(ev[q]) != ‘movieclip’) {
rtnObj[q] = ev[q];
}
}
EIBuffer.addCall({method:swfDomId + “.onPOIClicked” + id, data:rtnObj});
}
So i am getting all the fields of markers like “index”, “title” and “description”.
Please provide your inputs.
Thanks,
Anupam
Scott
March 12th, 2007
12:08 am
Looks good,just as long as you don’t return any movieclip information you should be good. The cross AVM communication does not like it when movieclip instances are passed back and forth, it seems to really get confused and error out.
I am glad to see you extending the code, that is why we released it.
Thanks,
Scott
venkat
March 12th, 2007
12:09 am
Scott and Anupam,
I am trying to get the same information about the marker that you have implemented. But I am new to this flash and flex and don’t exactly know which class to extend to include the code snippet that you provided. Can you please give me some ideas on this? thanks a lot in advance. I tried to listen to the onPOIClicked eventbut the object returned does not contain a marker instance. Not sure how to proceed on this.
venkat
March 12th, 2007
12:09 am
nevermind. I have figured out how to get the marker properties. thanks a lot Scott for this beautiful library.
Scott
March 12th, 2007
12:10 am
I am glad you are liking the library. Also, thank you for all the communication I am sure all the discussion will create great applications. I am not sure if you guys know about the Yahoo! Developer Network Flash discussion group. Lots of users are already subscribed to that group including a number of internal Yahoo! developers. Posting a question or comment there will ensure many people see it and will increase the probability that someone will respond quickly. You can sign up for the group here: http://tech.groups.yahoo.com/group/ydn-flash/
Once again, thanks for supporting our libraries and I look forward to seeing what you guys are creating!
Anupam
March 13th, 2007
12:10 am
Hi Scott,
I am aware of the Yahoo Developer Network Mailing list and I am already a member of that…
I will be definitely posting my findings over there
Thanks,
Anupam
Grant
March 13th, 2007
12:11 am
Just FYI on a problem in the as2map.fla. I just downloaded it, and couldn’t figure out why the maps were loading so tiny in all the examples (a very tiny dot).
I opened up the FLA, resized the map inside the mapClip library clip to the full document dimensions (was 5×5, now 600×400), and the problem went away (maps aren’t tiny dots in Flex anymore).
Not sure if this is a resize function that isn’t working, or the map was sized wrong, buy at any rate this looks all good now.
Thanks for this, BTW…this will make my project a lot easier to build!
Scott
March 13th, 2007
12:11 am
You should set the size when you set the tag using the width and height attributes. If you manually size the component in the .fla you may see some flashing. Another good practice is to keep the visibility off until the map is loaded or until tiles are loaded (events are broadcast for both), this ensures everything is sized and ready and the user won’t see flashing or weird resizing.
None the less, thanks for pointing this out Grant.
Anupam
March 15th, 2007
12:12 am
Hi Scott,
I am trying to place 2 map instance in the single applicaion file of the map.
I am getting one map and the other map is not displayed.
I have also tried with changing the id of the map i have set the unique id of the second map to 12345.
I am getting one map but second map is not displayed.
Do i need 2 swfs i.e as2map.swf or can i use the same swf in two places? Right now i am using the single swf but no sucess.
Can you provide some input on this?
Thanks,
Anupam
scott
March 15th, 2007
12:12 am
Hey guys,
Like I posted on the ydn forum we are looking into this right now. Something happened when the AS2 map component was updated in the last couple weeks. Once we figure it out we’ll post an update and we’ll let you know.
Thanks for being so patient.
Scott
2007-03-15 00:00:00
Marc Love
March 16th, 2007
12:19 am
Hi Scott,
I am trying to capture an event from a marker click event with no success.
I have the following code:
private function onMapLoaded(ev:Object):void {
var myMarker:Object;
var panTools:PanTool = new PanTool(myAS2Map);
panTools.setPanTool(true);
var widgets:Widgets = new Widgets(myAS2Map);
mapController = new MapController(myAS2Map);
widgets.showNavigatorWidget();
widgets.showSatelliteControlWidget();
new Overlays(myAS2Map).showTrafficOverlay(true);
latLonController = new LatLonController(myAS2Map);
latLonController.setCenterByLatLonAndZoom(Number(56.58369172128337), Number(-5.1416015625),12,0);
myMarker = index:’*',title:’test’[0].name,markerColor:0xff0000};
latLonController.addMarkerByLatLon(‘CustomPOIMarker’,Number(56.58369172128337), Number((-5.1416015625), myMarker);
myMarker.addEventListener(onPOIClicked,test);
}
public function test(ev:Object):void {
Alert.show(“Hello”);
}
I am new to Flex and actionscript and I am not sure what I am doing wrong.
Cheers for your help in advance.
Marc
March 18th, 2007
12:20 am
Sorry, I did a quick cut and past and took out references to my HTTPService. The line should be:
myMarker = index:’*',title:’test’,markerColor:0xff0000};
and the line:
myMarker.addEventListener(onPOIClicked,test);
should be:
myMarker.addEventListener(‘onPOIClicked’,test);
however this is not causing the test function to be called when I click on the marker.
Marc
March 18th, 2007
12:20 am
Did it again.
My marker line should be:
myMarker = {index:’*',title:’test’,markerColor:0xff0000};
Marc
March 19th, 2007
12:21 am
Hi Scott,
I get the following back:
y: 56.41…..
x: -5.41…..
latlon: [object Object]
type: poiMarkerClicked
Don’t see how I can get at the id, title and description of the marker from this.
Marc
March 20th, 2007
12:20 am
Hi Scott,
Sorry for posting so many times but I am determined to get this working. I have managed to capture the onPOIClicked event with the following code:
mapEventDispatcher = new MapEventDispatcher(myAS2Map);
mapEventDispatcher.addEventListener(‘onPOIClicked’,poiClicked);
public function poiClicked(ev:Object):void {
Alert.show(ev.lastResult.title);
}
However ev.lastResult.title is just returning an empty string. How do I get at these properties of the clicked marker.
Cheers again for your help in advance.
Anupam
March 21st, 2007
12:13 am
Hi Scott,
I am trying pretty hard to get multiple instances of the map on a single page
Can you please provide some input into this..
Sorry for disturbing you again..
If u can provide some input as where to change the code it will be of gr8 help!
Thanks
Anupam
Scott
March 21st, 2007
12:13 am
Hi Anupam,
Me an another engineer (who wrote a good part of the original Maps AS code) spent yesterday afternoon looking into this. Unfortunatly we weren’t able to come up with anything. We confirmed it is not working as is with ExternalInterface, we wrote a LocalConnection version with the same result. Both map shells load, the widgets and panning instantiated on both maps, however only one map loads tiles, and there is a considerable delay before the one map loads the tiles. We used a few different http sniffer programs to see what was going on, and we noticed calls to the server were being dropped. What we are not sure of is if this is a security “thing” in the flash player, if the player is being overloaded with cross-avn activity, something in the as2 component is conflicting with avm2. We have confirmed that everything works “fine” if you load two maps into a regular flash 8 file. I put the word fine in quotes because there are a few issues, and a few dropped calls but avm1 seems to get around them. Unfortunatly we are stumped at this point, if anyone out there has any suggestions let use know. I know the other engineer was going to spend some more time with it last night, I will update you if he comes up with anything. I don’t know how much time we’ll be able to spend on this as you are the only one (as of now) running into this issue. Do you need two maps in one application, could you get around it by loading another instance of the application into an iframe? Is there going to be communication between the maps, you could always use LocalConnection if the other map is in an iframe. Let us know what your specific use case is and I will throw out any other suggestions I may have.
Thanks,
Scott
2007-03-21 00:00:00
Grant Shepert
March 21st, 2007
12:14 am
Hi Scott,
I’ve been working extensively with the AS3 kit and Yahoo maps; I’ve added quite a few extensions successfully (like a simple marker/polyline manager for adding custom SWFs), but the one issue I cannot resolve is setZoomLevel(). I’m trying to use a Flex slider component to issue calls to the zoom. It will work sporatically, like if I drag the map to a position, but if I double-click (panning the map), then zoom, it stalls untils I double-click again, at which point it will pan and then zoom. I can get the zoom call to work every time if I add a setCenterByPointDelta(new Point(0,0)) call right before the setZoomLevel() call, but if I have panned the map the zoom is offset by a bit…however, if I dragged the map before the zoom, the zoom is dead on.
This is the latest version of the function in the as2map swf:
function setZoomLevel( data:Object ) {
myMap.setCenterByPointDelta( new Point(0,0),0 );
myMap.setZoomLevel( data.zoom );
}
I tried substituting a setCenterByLatLonAndZoom() call in there, but this doesn’t always get the right latLon (again, depending upon how the map has been positioned, ala double-click pan or drag.
Because a stalled zoom call will always ‘appear’ after a double-click, I know the zoom call is being issued from Flex to the swf, and I’ve tried every which way I can think of to trace the issue, but to no avail.
I’d greatly appreciate any insight into this you can offer.
Anupam
March 22nd, 2007
12:14 am
Hi Scott,
The use case in which i want to use multiple instances of the map is like this
We are building an Enterprise level application using Flex 2.0.1
I have designed an mxml component for map and all the functionality is achived using this component.
I have created a view stack in an mxml application file and
i am using this component in different views.
In first view i am showing the information related to some service engineer and where they are located using markers.. and on the click of the marker i am handling certain events.
so the user can edit or add the information regarding that particular service engineer.
In the second view i am showing the information related to some service parts and where they are located.It is called sites in the application.
Here also on clicking on the marker some event is triggering and user will be able to do CRUD operations on the Equipments.
I have tried to achieve this functionality by putting component on two different views but one of them is not loading.
Can you suggest any other approach to achieve the same functionality?
Thanks,
Anupam
Mario
March 26th, 2007
12:15 am
The present AS2+AS3 solution is SLOW and fragile. You’ll notice that a more direct tiling approach implemented in FlashEarth outperforms the API’s that were developed by the might of Yahoo and Google. Amazing what one little developer can do!
A native AS3 tiling implementation should be VERY fast, smooth and stable in comparison to the current approach. It’s baffling to see such a delay on the part of major vendors. Surely they can do better then a one man shop?
Go FlashEarth go (www.flashearth.com).
2007-03-26 00:00:00
Scott
March 26th, 2007
12:16 am
I had an issue with the local search and couldn’t retrieve more than 25 records. I wrote the following function to “fix” it…
for( var i:int = 1; i < 5; i++){
var begin:int = i * 25;
var end:int = (i * 25)- 25;
overlays.localSearchOverlay(“Thrivent”, undefined as Object , begin, end , 2000, undefined as String, undefined as String);
}
Alert.show(i.toString());
}
Scott Morgan
March 26th, 2007
12:17 am
Hi Scott,
Thanks for the comment, i’m not sure what you are trying to do but you do not have to loop and call the method multiple times. I just set it up to return 200 results with one call. Now if you want to show more than 200 you may have to do something like this because the external interface might get clogged up since the object will be so large. One simple call like this works fine:
overlays.localSearchOverlay(“Thrivent”, undefined as Object , 1, 200 , 50, undefined as String, undefined as String);
I also lowered your radius, 2000 miles seems a little excessive.
Scott
Raghu
March 28th, 2007
12:17 am
Hi Scott,
I’ve been using the Yahoo! Maps AS3 library for a while and found a tough nut. I’m trying to add an anchor tag in a CustomPOIMarker description. Instead of launching an URL, I want to call an actionscript.
Initially, I tried this:
“Click”
But, after reading the documentation I guess AS3 does not support “asfunction” anymore. Instead, it is now a TextEvent. So, I replaced the “asfunction” call with this:
“Click”
and then…
addEventListener(TextEvent.LINK, handler);
This does not work either. If I try this with any UI component of Flex, it works. For ex., if I use a TextArea or a Button and set the “htmlText” property to what I did above, everything works fine. With CustomPOIMarker, this does not work.
I have two questions therefore:
1. Only the first click on the marker fires the click event (onPOIClicked). First click expands the marker. Further clicks do not fire any event. If they do, I guess the event is different. Is that right?
2. Is there a way in which I can use “addChild” on the marker object? This way, I can create any control in Flex that supports “htmlText” and then add it to the marker.
Will appreciate any help in this context.
Thanks,
Raghu
2007-03-28 00:00:00
Raghu
March 28th, 2007
12:18 am
Sorry! I did not realize that the post will convert into a real anchor. Corrections in my previous post:
Read the first “Click” as “Click”
Read the second “Click” as “Click”
Thanks
scott
April 17th, 2007
12:19 am
First off, what is up with this line?
myMarker = index:’*',title:’test’[0].name,markerColor:0xff0000};
Scott
April 18th, 2007
12:21 am
No worries with all the posts. Off hand I can’t remember what is coming back in that object. Add this to your event handler and trace out what’s coming back:
public function poiClicked(ev:Object):void {
for (var p in ev.lastResult) {
trace(p + ‘: ‘ + ev.lastResult[p]);
}
}
Let me know how that works.
Scott
shivnikum
May 19th, 2007
12:22 am
i am unable to trace the event onPOIClicked and the string of that POI
plz help me out from this situation
thanks
Tonic
May 25th, 2007
12:22 am
Hello, i’m french, so excuse me if i make fault.
I display “CustomSWFMarker” in my map, it run good.
But it’s impossible to recover as “CustomPOIMarker”, an event to know when user click (“onPOIClicked”) on the marker.
Is there a tips or an event to intercept mouse events with “CustomSWFMarker” ?
Thank you…
Chuck
June 25th, 2007
12:23 am
Scott-
Is onPOIClicked event available in the AS2 flash component? I am having difficultly finding it.
I REALLY APPRECIATE YOUR HELKP AND THIS FORUM!!!!
Scott
June 26th, 2007
12:23 am
Yes there is, in the documentation for the AS2 component it reads.
“EVENT_POI_CLICKED
Static property that contains the name of the poiMarkerClicked event.”
http://developer.yahoo.com/maps/flash/V3.5/flashReference.html
vijay
July 20th, 2007
12:24 am
Hi Scott,
I have exactly the same issue which Marc faced . My “onPOIClicked” returns me only this:
x: -122.39209
latlon: [object Object]
y: 47.635784
type: poiMarkerClicked
I am looking for the “title” and “description”. Please let me know how to go about this.
-vijay
2007-07-20 00:00:00
Al
September 12th, 2007
10:54 pm
Take a look at this:
http://digitallyinsane.wordpress.com/2007/03/13/yahoo-maps-as3-communication-tool-kit/
Might help you
Ryan
November 8th, 2007
9:15 am
Scott,
I have spent considerable amount of time trying to get two instances of the map working. Did you ever come up with a solution?
Thanks,
Ryan
scott
November 8th, 2007
10:23 am
Hi Ryan,
I am no longer working at Yahoo so I am no longer working on the communication kit, but I can tell you this. This isn’t a just a maps communication kit bug, this is a known avm2 issue, even if you load a two standard avm1 movieclips into an avm2 application there is going to be issues. We did a bunch of tests we the most basic movieclips (a blue box, that’s it) and we ran in to the same issues.
The only real solution will be a true as3 api released for Maps. I no longer have the ability to push for it inside Yahoo. I am with you, now we have to beg from the outside. I know they are discussing it internally, as for a date I do not know. Hopefully sooner than later before they lose all of their customers to either third party apis or competitor apis.
Finally, Yahoo releases Maps API in Actionscript 3
February 11th, 2008
8:10 am
[...] developers have been requesting an Actionscript 3 Yahoo Maps API. To cool the fires I wrote the Yahoo Maps Communication Kit, which was a hack that allowed you to use the Actionscript 2 Yahoo Maps component in an [...]
Leave a comment