ActionScript 3.0

com.hello.formatters.GuidFormatter

Today I needed a fomatter for GUID’s.

I made a quick and dirty extension to the Formatter base class that uses our existing com.hello.core.Guid class to fetch a format constant and then use an instance of the mx.formatters.SwitchSymbolFormatter to apply the pattern to the string representation of the Guid we want to format.

The implementation looks like this… don’t think too much about the details of the implementation – it has been simplified to serve as example of the general idea.

package com.hello.formatters

{

import com.hello.core.Guid;

import mx.formatters.Formatter;

import mx.formatters.SwitchSymbolFormatter;

public
class GuidFormatter extends Formatter

{

public
function GuidFormatter()

{

super();

}


override
public
function format( value:Object ) : String

{

var result:String = “”;


var valueStringLength:Number = value.toString().length;

switch( valueStringLength )

{

case 36:

result = value.toString();

break;


case 32:

var dataFormatter:SwitchSymbolFormatter = new SwitchSymbolFormatter();

result = dataFormatter.formatValue( Guid.FORMAT, value );

break;


default:

error = ERROR_MESSAGE;

break;

}


return result;

}


public
static
const ERROR_MESSAGE:String = “guidFormatterErrror”;

}

}

Uncategorized

Javascript BrowserDetect Script

Today I found myself in the need of a solution for a quick-and-dirty redirection in the case of IPhones… Peter-Paul Koch’s browserdetect script is well functioning and working predictably, so I decided to use that…

var BrowserDetect = {

init: function () {

this.browser = this.searchString(this.dataBrowser) || “An unknown browser”;

this.version = this.searchVersion(navigator.userAgent)

|| this.searchVersion(navigator.appVersion)

|| “an unknown version”;

this.OS = this.searchString(this.dataOS) || “an unknown OS”;

},

searchString: function (data) {

for (var i=0;i<data.length;i++)    {

var dataString = data[i].string;

var dataProp = data[i].prop;

this.versionSearchString = data[i].versionSearch || data[i].identity;

if (dataString) {

if (dataString.indexOf(data[i].subString) != -1)

return data[i].identity;

}

else if (dataProp)

return data[i].identity;

}

},

searchVersion: function (dataString) {

var index = dataString.indexOf(this.versionSearchString);

if (index == -1) return;

return parseFloat(dataString.substring(index+this.versionSearchString.length+1));

},

dataBrowser: [

{

string: navigator.userAgent,

subString: “Chrome”,

identity: “Chrome”

},

{     string: navigator.userAgent,

subString: “OmniWeb”,

versionSearch: “OmniWeb/”,

identity: “OmniWeb”

},

{

string: navigator.vendor,

subString: “Apple”,

identity: “Safari”

},

{

prop: window.opera,

identity: “Opera”

},

{

string: navigator.vendor,

subString: “iCab”,

identity: “iCab”

},

{

string: navigator.vendor,

subString: “KDE”,

identity: “Konqueror”

},

{

string: navigator.userAgent,

subString: “Firefox”,

identity: “Firefox”

},

{

string: navigator.vendor,

subString: “Camino”,

identity: “Camino”

},

{        // for newer Netscapes (6+)

string: navigator.userAgent,

subString: “Netscape”,

identity: “Netscape”

},

{

string: navigator.userAgent,

subString: “MSIE”,

identity: “Explorer”,

versionSearch: “MSIE”

},

{

string: navigator.userAgent,

subString: “Gecko”,

identity: “Mozilla”,

versionSearch: “rv”

},

{         // for older Netscapes (4-)

string: navigator.userAgent,

subString: “Mozilla”,

identity: “Netscape”,

versionSearch: “Mozilla”

}

],

dataOS : [

{

string: navigator.platform,

subString: “Win”,

identity: “Windows”

},

{

string: navigator.platform,

subString: “Mac”,

identity: “Mac”

},

{

string: navigator.platform,

subString: “Linux”,

identity: “Linux”

}

]

};

BrowserDetect.init();

Download it here…
http://petermolgaard.com/projects/BrowserDetect.zip

Tools

Kodiak… 1. beta soon available for download

Rumors are that the team behind Kodiak soon will make the binaries for the first beta available…

It’s going to be quite interesting to see something as “boring” as virtualization presented in a compelling and engaging experience.

One of the typical responses to software that looks good is that it’s either not serious (regardless of the seriousness of the domain the software lives within) or that it’s difficult to use… Kodiak addresses these two responses, so it will be exciting for sure to see how it works once installed and once the virtual machines need to be used.

Register for the upcoming beta here…
http://www.bluebearllc.net/kodiak/

Adobe Flex

Adobe Flex TV

In case you don’t know about the FlexTV channel at YouTube…

…it’s a place where to find video resources of some of the latest stuff and some videos that don’t belong anywhere else, but still are relevant for the Adobe Flex Community. Seeing the informal nature of YouTube videos, it’s a place to put videos that are too short or too “amateurish” (in the positive sense of the word) to pass as actual video tutorials…

If used right, it could become great stuff…
http://www.youtube.com/adobeflextv

Uncategorized

Updated RSL for Flex Data Visualization 3.0.1

Due to a bug in the signing process at Adobe, it appears that the cacheable RSL for the datavisualization components in Flex Builder doesn’t work in 3.0.1.

Adobe has updated the RSL and made it available here.

Go ahead and replace it in your Flex Builder 3.0.1 installation and you’ll hopefully be set.

Read more about it on blogs@adobe…
http://blogs.adobe.com/flex/archives/2008/09/updated_rsl_for_flex_data_visu.html