July 30, 2005

Flex and JavaScript Popups

I was posed with a question the other day about how to keep JavaScript in-line without hosting the mxml file within a container page (ie JSP, HTML, CF, etc). Flex handles in-line JavaScript popups very similar to Flash. If you've tried to make a call to:

getURL("javascript:window.open('http://www.google.com', 'win', 'width=600, height=600');");

in Flash or Flex you'll note the inherent problem with the new window being opened but also the child window (the one with the Flash movie) has been redirected a page that reads [object Window]. The Flash player actually redirects you to the URL instead of launching the new window and returning.

This describes the exact problem I was questioned about the other day. You can peak at the problem and the solution in an example below along with the code that drives it:

The key is to use the void(0) statement, which tells the browser to stop what it's doing. The popup is launched and the browser is halted. Kind of a nuisance but it's a little bit of code for what you gain from it.

Posted by dennis baldwin at 09:17 PM | Comments (0)

July 26, 2005

Bluetooth GPS Coordinate Conversion

I've been experimenting with GPS over the past couple of years and have learned some interesting things. Last year I bought a Belkin Bluetooth GPS receiver so that I could start talking to it from my Symbian phone. Once I bought this device I was immediately attracted to it's form factor and ease of use (you just turn it on!). The Belkin is extremely different to many of the GPS receivers you're probably familiar with, this one doesn't have a screen. It expects some peer device to serve as its user interface, which might be a PC or mobile phone. The receiver talks over Bluetooth using the NMEA 0183 protocol. This is a basic ASCII protocol where data comes through in the form of comma delimited sentences, hence it's very easy to decode.

So about this time last year I decided to pursue my passion for the Symbian OS and wrote a little program called BlueGPS. I haven't touched it in over a year and to my amazement it's received over 10,000 downloads on the Handango site.

My interest started bubbling again over the past couple of weeks with the announcement of the Google Maps API. It's not that I'd lost interest in BlueGPS, but a little place called SensorLogic occupies all of my days and a lot of my nights ;) Anyway, I'm drawing closer to the point of this post. After integrating a few technologies such as BlueGPS, SensorLogic's Web services, and Google maps, I was able to create the Dennis Tracker. Yes my wife thinks I'm crazy, but this truly is the kinda stuff that keeps me up late at night.

The hurdle I had to overcome (and the point of this post) is that the Belkin GPS receiver sends location data in a format known as GPS Coordinates (degrees and minutes). Google Maps expects the data to be in the format of decimal degrees. The conversion is simple but if you don't know the difference you can spend a lot of late nights trying to figure out why your GPS data appears to be miles off target. Once I applied the conversion I came to find out that my location is within 30 - 50 ft of accuracy.

Let's take a quick look at the conversion:

1. Longitude comes from the receiver in the format of 9645.6109,W
2. Strip off the non-numeric data (,W)
3. Grab the first two chars which represent degrees (96)
4. Grab the rest of the chars which represent minutes (45.6109)
5. Divide minutes by 60 (0.7601816667)
6. Add degrees and minutes for the final value (96.760181666667)

Enjoy and I hope this clears any confusion you might have when dealing with GPS data!

Posted by dennis baldwin at 09:35 PM | Comments (0)

July 20, 2005

HaloTheme for Flex

As you probably know the default theme for Macromedia Flex is called HaloTheme. I've been experimenting with custom themes and if you read any of the docs you'll see a reference to HaloTheme.fla. In my installation I was unable to locate this file and only had access to pulseBlue and pulseOrange.fla. I wanted to post a link to HaloTheme.fla for those wanting to customize the UI a bit. Click here to download it and a thanks to Tony Chen from Flexcoders for hooking me up with this file. I'll be sure to post some different themes for download in the future.

Posted by dennis baldwin at 10:39 PM | Comments (0)

July 16, 2005

Let Flex Consume Your CFCs (MXDJ Article)

I recently finished an article for MX Developer's Journal discussing the integration of Flex and ColdFusion. It goes into brief detail about using the Flex Web Services class to consume ColdFusion CFC's. As in most of the articles I write, I like to provide a sample application because I feel that many developers share the same approach as me to learning...learn by example.

The application consists of a basic Flex form that ties into the ColdFusion examples database and allows the user to update employee information. You can see a screen of the sample app below:

I've yet to receive my copy of the issue but it should be in the July release. Also, if you're interested in downloading the sample code and running it locally then you can do so here: http://www.db75.com/dev/mxdj/mxdj_0605.zip. Please feel free to contact me with any questions or comments.

Posted by dennis baldwin at 10:23 AM | Comments (0)

July 07, 2005

Macromedia Flex and Password Encryption

I was researching some different text encryption algorithms at work and stumbled across one that works fairly well. If you want to enable a simple means of security then you might find this useful. This beats storing a user's password in a SharedObject in plain text.

I stumbled across the following algorithm written in JavaScript: http://javascript.internet.com/passwords/xor-encryption4.html. I decided to convert the code to ActionScript so I could run it in my Flex project. It turns out that I only to make one or two minor tweaks and everything ran flawlessly. You can view the results below. Leave the default text or add your own and then click "encrypt".

and here's the code that makes it all happen:

Posted by dennis baldwin at 11:47 PM | Comments (0)