Flash Player 10 goes 64-bit!
It's been a long time coming but Adobe has finally announced a beta, 64 bit version of flash player 10. Get this, it is only available for Linux ( at this point ). Linux fan boys can now relish in the fact that they are getting some special treatment. Of course it is still not open source so many won't be happy.
The comment thread on slashdot should be interesting.
If you are interested, checkout the Flash Player page at Adobe Labs.
Unfortunately, for those developing on Linux ( like me ), there are no plans for a debugger version. Oh well, I guess I'll stick with the plugin wrapper.
Flash Player 10 meet Flash's 10th
Last week Flash Player 10 was officially released. If you haven't already updated, update now. This post isn't about that. Being as halloween is around the corner I began to look at Homestar Runner again. Through the wonders of google search I found the following little gem. ...
Homestarrunner's tribute to Flash's 10th Birthday:
Homestar Runner was the inspiration for me to get into flash and realize I liked programming a lot more than cartooning. Without Homestar Runner who knows what I'd be doing now.
If you are wondering, I got nostalgic about the burninator and it led me to the Flash Birthday Movie
Flash Player 10 is official
Flash Player 10 is now official. Lot's of great stuff in this version and people have been creating content for it for months. Also, some of the player enhancements will just make certain things better, since there are more ways your graphics card can be used to making viewing better.
Flexbuilder for Flash post on Flexcoders
Okay, so the title sucks but this morning I posted a workflow for using Flex Builder for working with Flash (FLA) files.
Check it out at Flexcoders.
Flash Player 9.0r115 and Opera for Linux
Recently the flash player got updated to version 9.0r115 in Ubuntu. I already had the debug version of 9.0r115 setup thanks to installing Flex Builder for Linux alpha so I didn't actually need it but downloaded it anyway. This broke flash for Opera since 9.25 doesn't work with the newest flash player( 9.50 beta does but I prefer to work with a stable version on this computer ).
For those of you wondering about the workaround/fix, here it is:
Download the 9.0r48 flash player from Adobe's self service page.
Then follow the instructions on ignoring plugins available here.
Just make sure to use the full path for the 9.0r115 plugin(s) you have available.
Simple Yahoo! Maps Workaround
The Yahoo! Maps Flash Component and API is a nice system to work with. For a simple to use map plug in for flash that looks decent without much work, its the best there is. However I like to work with it and see what hidden gems I can find. Or, as is the case in this article, delve deep inside of it and try to find out how to make it work as I want it to. It's still technically beta, so it has it's own little quirks. ...
As great as the Yahoo! Maps component is, it has one quirk I've run into a couple of times. If you unload the map while it is loading data and tiles it loads excruciatingly slow when you load the map again. In fact, it seems like it isn't loading at all. Usually when I've created a map for a web page or RIA, I create it as a separate SWF movie to be loaded at runtime. The fix for the problem in this situation is simple, if not obvious.
// make sure yahoo map library is removed from global namespace// so that it will always reload. this.yMap.onUnload = function() { _global.com.yahoo = null; }
Unfortunately, this is one of those wild ass guess debug moments - where you just try it and hope it works. I'm not sure what class in the yahoo tree is causing the problems but I figured something was so I just got rid of them all. It probably also helps that the entire yahoo map library is a larger chunk of data so making it all available for garbage collection in that way makes garbage collection actually occur.
Recently, I had a project where my boss wanted me to embed map movie clip in the main movie rather than load it in at runtime. I still had the same type of problem, where the map could get, and is like to be, unloaded while it is in the middle of a data/tile load cycle. Since the Yahoo! map library isn't getting loaded in as it does with an external SWF, deleting the library is worse than the original quirk. Then the map won't even show the copyright info.
So into the problem I dove. I tried everything I could think of. I looked in the classes that I unzipped from the components SWC file to see if I could make some adjustments to unofficial parameters on unload. I used wireshark to see if any HTML requests were missing when the quirk occurred. I even took the SWC apart with Buraks Actionscript Viewer and tried to sort through that mess of code to see if I could find the answer. While I made many interesting discoveries along the way, I made no difference in the issue at hand.
So I made my way to my boss's office to tell him the status. As I walked toward his office I knew he would have a very simple answer for me that would work. I'm stubborn. I'm a programmer. I like to do things my way. I want elegant solutions to my programming problems. He is a designer. He just wants it to work. He's not worried about how it works ( note to other programmers, most people are this way ). I walk into his office and tell him the news. He thinks about it for maybe one second and tells me not to unload it, just move it off the stage.
Don't unload it?! That's like going to a doctor and telling him, "it hurts when I do this." To which the doctor will respond, "Then don't do that." In other words, it makes perfect sense and I can't believe I didn't think about it. Maybe I should have taken a break instead of pushing on for as long as I did to figure it out.
Now, instead of moving it off the stage I just set it's _visible property to false. That just seems a bit more elegant to me, and it just works. In fact in this situation it works better than the other system. Anyone who has used the Yahoo! Maps component knows that before the first tiles load in there is nothing but copyright info. By doing it this way the map loads in the background so when a user click the button to see the map, it comes up instantly.
So to wrap things up, here are my lessons learned:
- If you can't make it elegant, just make it work
- Ask for help from people who don't think like you
- Your mind needs a rest from time to time, take breaks
- load Yahoo! Maps in the background - they work better that way
- Sometimes the answers are simple, if you are racking your brain step back and look at things from different perspective
----
Daryl "Deacon" Ducharme is currently Director of Application Development for the Interactive Agency Provis Media Group, LLC which helps organizations enhance identity, connect with customers and increase productivity.
MTV Adobe Air Challenge
I'm jealous of all the people in Chicago at Adobe Max 2007. There is a lot going on this year that I am particularly interested in. I've seen a preview of flash player 10. Flex 3 and AIR beta 2 are out with some great new features people have been wanting to test out. One good thing though is there is much blogging going on. ...
In one of the most recent blogs I saw a link mentioned in passing. The link led me to the homepage for the MTV/Adobe AIR Challenge. I'm pondering if I should look into building something. There are a lot of smart people who will be doing some stuff as well. Of course, failure sometimes is the best option so I probably will. Now, what should I build? I haven't watched MTV since Tough Enough season 3 ( the last season? ).
If you have any ideas, I would love to read them.
Garbage Collection in AVM2
Just passing along a post to an adobe blog entry regarding garbage collection and memory leaks in the new Actionscript Virtual Machine. I highly recommend following along with the powerpoint file that is linked in the blog.
CNN/YouTube Debates
Since I don't have cable I couldn't watch the CNN/YouTube Democratic Debate on Monday Night. Much like the last debates I planned on watching the video from CNN.com. However, when I went to their website today I noticed something, they changed formats since the last debate. Before, they used the windows media format and now they were using flash video. I am a big proponent of flash video, it's truly cross platform ( PC, Mac and Linux ) and it just seems to work better. Their useage didn't, however, allow something that is now well implemented with flash player 9 but was available in the old Windows Media format - Full Screen Video. This really bothered me because I don't want to squint for 2 hours with my face 2 inches from the monitor while my wife and I try to watch the debates and it should have the ability to go full screen if they have the proper version of flash installed ( which is easy to ensure thanks to express updates ). Being who I am and doing what I do I made a player for the debate. It grabs all 4 parts from CNN and allows the watching of the entire debate all in fullscreen if you desire. ...
As you may notice I also took out the commercial at the beginning of each part. Since I did this without permission from CNN.com I don't know how long this will stay up. If they ask me to set it up with the commercials I will be glad to do that for the right to help distribute something I think is important for every American and many others around the world to see. I plan on doing the same thing with the Republican debate as well unless a better, and legitimate source is available.
Unfortunately, I can't add javascript to my blog page so I am unable to add express update to this page. So if you have problems viewing this page you may need to update your flash player to the most current version. It doesn't take long because Adobe has gone to great lengths to keep the download size to about 1MB.
Centering On Markers with Yahoo Maps
At my work, Flash is one of our core competencies. As a format, its ubiquity is probably its most powerful asset. For us, it is the best format to display some of our other core competencies such as video, 3D and rich internet applications. One thing we we're very happy to see was when Yahoo made a Flash Component and API for their mapping tool. We are still waiting for Google to do the same.
When I first dove into the component I unzipped the SWC and just messed with the innards trying to figure out what I could do with it that was not officially documented. While I did figure out some interesting things about driving directions, changing the logo, changing the copyright info as well as a few other things, we never had a client want to do more with it than show a map, at a certain zoom level and add some markers. Recently we had a client who wanted a map with dynamic markers. When they selected a certain group of points of interest it would only show that group. Easy enough. My boss added a little fun into the mix by saying he wanted the map to adjust its zoom and center itself on the displayed markers. Below I describe the thought process of doing something I hadn't done before. ...
So the question was, how do I center on the current markers. There was no zoomAndCenterToMarkers() function so I had to look deeper. It was there that I found the setBounds() function which, "Sets the map to the center of a rectangle specified by a LatLonRect object." That sounds like just the right function for my problem but there is a hitch. How do I get the latitude and longitude of my markers so that I can create the LatLonRect object?
My markers are all created by address. In the future they may be changed by the client so I wasn't assured a stable set of latitude and longitude data. Once again I checked into the API. Unfortunately, I didn't see any documented or undocumented way to just geocode the address. One of the great things of the yahoo maps API, auto-geocoding, was making this more difficult than I thought it should be. Either that or I was making it more difficult than it should be :) Once I thought about it I realized that geocoding is an expensive process. It takes a server call that takes an unknown amount of time, there must be an event that gets called when this occurs. Low and behold, there was my answer. The EVENT_MARKER_GEOCODE_SUCCESS event broadcast from the map. So the next step was to add this:
yMap.addEventListener( com.yahoo.maps.api.flash.YahooMap.EVENT_MARKER_GEOCODE_SUCCESS, Delegate.create( this, this.onGeoCode ) );
The event object that gets passed into my onGeoCode function has a latlon property so I can start to build the data I need.
private function onGeoCode( event:Object ):Void{ var newCoordinates:LatLon = LatLon( event.latlon ); this.markerCoordinates.push( newCoordinates ); this.showAllMarkers(); }
I add the LatLon object to an array of latitude and longitude data with the idea to call a show all markers function that looks like this:
private function showAllMarkers( ):Void { var coordRect:LatLonRect = new LatLonRect(); for( var index:String in this.markerCoordinates ) { var coordinates:LatLon = LatLon( this.markerCoordinates[index] ); if( coordRect.minLat == null || coordinates.lat < coordRect.minLat ) { coordRect.minLat = coordinates.lat; } if( coordRect.minLon == null || coordinates.lon < coordRect.minLon ) { coordRect.minLon = coordinates.lon; } if( coordRect.maxLat == null || coordRect.maxLat < coordinates.lat ) { coordRect.maxLat = coordinates.lat; } if( coordRect.maxLon == null || coordRect.maxLon < coordinates.lon ) { coordRect.maxLon = coordinates.lon; } } this.yMap.setBounds( coordRect ); }
Simply put, it runs through the array of LatLon objects and creates the LatLonRect object from that data. This example is rather simplistic and doesn't take into account moving between hemispheres because I can be reasonably assured that this project will be limited to a very small area of the planet. Calling showAllMarkers() every time I get new geocode data is expensive and will probably break the application. The solution I came up with was to only call showAllMarkers() once all the markers for a given POI category are geocoded. So in my code I set a variable called markersDisplayedCount that equals the number of markers that are going to be displayed. I then changed my onGeoCode function to look like this:
private function onGeoCode( event:Object ):Void { var newCoordinates:LatLon = LatLon( event.latlon ); this.markerCoordinates.push( newCoordinates ); var someMarkersVisible:Boolean = this.markersDisplayedCount > 0; var allMarkersGeoCoded:Boolean = this.markerCoordinates.length == this.markersDisplayedCount; if( someMarkersVisible && allMarkersGeoCoded ) { this.showAllMarkers(); } }
As you can see, I test to see if all the displayed markers have been geoCoded and that some markers are visible before I call the showAllMarkers() function. The reason I add the someMarkersVisible test was to lessen the risk of a fast moving user from breaking the application. It's not an infallible system but it does the job within the confines of the requirements.
A couple final points from all of this. If instead of zooming to and centering on the markers you just want to ensure they are all within the current display, you can replace this:
var coordRect:LatLonRect = new LatLonRect();
from the showAllMarkers() function with this:
var coordRect:LatLonRect = this.yMap.getBounds();
In this case yMap is my YahooMap object and the getBounds() function gets the current LatLonRect of the map. By making this minor change your map will only change, by zooming or recentering, if the markers are outside of its current bounds. The last point I want to make is that if you are dealing with a mapping application that may deal with crossing over hemisphere boundaries, your showAllMarkers() function will have to take this into account. I believe this will involve ranges from -90 degrees to 90 degrees for latitude and -180 degrees to 180 degrees for longitude.
----
Daryl "Deacon" Ducharme is currently "Code Czar" for the Interactive Agency Provis Media Group, LLC which helps organizations enhance identity, connect with customers and increase productivity.