02 Sep 2009 at 17:01
Robert Bak
Uncategorized
No Comments
There’s a new project on Adobe Open Source called FlexPMD (if You’re wondering what PMD stands for the answer is simple – nothing). It’s a tool that scans Actionsript and MXML code and points out bad practices, unused variables, etc. Really helpfull if you’re trying to keep the code clean and get a habit of coding really nicely.
To try it out you really just need to go to the download page, get one of the versions (I’ve tested the command line one on windows and it works very good), generete a ruleset file using the web tool (link on the same page), and that analize the output XML file (you can use the simple web tool which is also provided on the download page).
I’ve put both the jar files and the ruleset (called pmd.xml) in “F:/Flex SDK/Tools/FlexPMD/” so the command to run it for me looks like this:
java -Xmx256m -jar “F:/Flex SDK/Tools/FlexPMD/flex-pmd-command-line-1.0.RC3.jar” -s “F:/THE/DIRECTORY/WHICH/TO/ANALIZE/” -o . -r “F:/Flex SDK/Tools/FlexPMD/pmd.xml”
It might be good to point out that you don’t need to analize the whole project but can also run the tool on any directory in it, which generates files which are easier to read, especially if you’re just starting to clean a big application.
17 Aug 2009 at 14:16
Robert Bak
Flex
2 Comments
Yesterday I’ve started to experiment with geolocation features built into Firefox 3.5 (check here) and Chrome with Gears installed. What was ment as a Flex Cookbook post grew into a handy library. It supports both Firefox and Chrome (including the loading of the address), includes functions to check the users geolocation, track him, etc.
For the geolocation to work you need to have some javascript code in your page, the library injects the code into the DOM so that you don’t need to do it manually, for those of you who are interested how to do it here’s a cookbook post.
The project is hosted on Google Code here, where you can also find a detailed documentation. Below you can find a sample application.
A simplest example I could think off:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:geolocation="com.robertbak.geolocation.*"
creationComplete="geo.send()">
<geolocation:GeoLocator id="geo"
applicationID="YOUR_APPLICATION_ID_HERE"/>
<mx:Label text="Lat: {geo.lastResult.coords.latitude}"/>
</mx:Application>
As you can see the whole configuration consists of adding the library and setting the applicationID, it’s usually the same as your main class name (eg. if you create an application as App.mxml, the applicationID should be set to “App”). This is needed so that javascript in the DOM of the page can call your application with the results.
The lastResult implements the IPosition interface:
IPosition
* coords (ICoordinates)
o latitude (Number)
o longitude (Number)
o altitude (Number)
o accuracy (Number)
o altitudeAccuracy (Number)
o heading (Number)
o speed (Number)
* address (IAddress)
o streetNumber (String)
o street (String)
o premises (String)
o city (String)
o county (String)
o region (String)
o country (String)
o countryCode (String)
* timestamp (Date)

Sample (view source enabled): link