inicio mail me! sindicaci;ón

Archive for May, 2009

SWFAddress url sorting utility

UPDATE:

I don’t know how I missed this, but since v 2.1 SwfAddress has the getPathNames() method which does exactly what my bit of code does… ah well. Anyway I’ll leave it up as it has the basics of string splitting and other stuff…

Thanks to Cam for pointing this out… and while you’re at it check out his blog, he’s a much better coder than myself (but sucks at the guitar ;) )

Just thought I’d post this up as it might be helpful to someone…

Normally if you’re building a site using SwfAddress (and you should, not having any form of deeplinking in your flash site these days is utterly unforgivable) you could just on the swfAddress change do something like

switch(String(e.value).replace("/", "")){

case "news" :

openNews();

break;

case "shows" :

openShows();

break;

}

But what happens if you want to use subpages (/news/news-item), or subsubpages (/news/news-item/photo)… or however many… well, something like this will help you a lot.

var string:String = "/news/news-item";

function sortDeepLink(_deeplink:String):void{

var urlArray:Array = [];

if(_deeplink.charAt(_deeplink.length - 1) == “/”){

urlArray = _deeplink.substring(1, _deeplink.length - 1).split(”/”);

} else {

urlArray = _deeplink.substring(1, _deeplink.length).split(”/”);

}

switch(urlArray.length){

case 0 :

//Home address

trace(”Home”);

break;

case 1 :

//One tier address - ie. /news/

trace(”URL (one tier): ” + urlArray[0]);

break;

case 2 :

//Two tier array - ie. /news/news-item

trace(”URL (two tier): ” + urlArray[0],urlArray[1]);

break;

default :

//Invalid URL

trace(”URL invalid”);

break;

}

}

sortDeepLink(string);

//

You can extend the switch function to handle as many tiers as you need by just adding more cases - you can also add a 404 function in the default case if you want.

I’d love to know if anyone uses this, so post a comment if you do!

AS3 - Clock Clock clone

A few days ago the fantasticly talented Ed Watt (@designed) posted up a link on Twitter to the Clock Clock project by those crazy Swedes Humans since 1982… Anyway, I decided to have a go at recreating it in AS3 just for the hell of it…

Here’s the example, and here’s the source (it’s pretty bad, just thrown together but it works)…

EXAMPLE

- and Illuminated Example

SOURCE

DropDown menu class - as3

Hey everyone!
I keep meaning to update this blog with various titbits and stuff, but I never seem to have the time - anyway, thought I’d post up this wee drop down (combo) menu class I decided to build yesterday - It’s not been from any specific project, I just decided that the flash community needs a better dropdown that the horrific one included as standard. Anyway, it’s pretty basic just now, but it’ll do the basics and it’s totally skinable which was my main aim.

EXAMPLE

Usage is pretty simple…

import com.liamr.ui.dropDown.DropDown;
import com.liamr.ui.dropDown.Events.DropDownEvent;

var array:Array = [{label: "Hello World", data:"English - (formal)"},
{label: "Bonjour", data:"French - (formal, for daytime use; 'n' as a nasal vowel)"},
{label: "hej", data:"Danish - (informal; pronounced hey)"},
{label: "dia duit", data:"Gaelic - (informal; pronounced gee-ah ditch; literally 'God be with you')"},
{label: "Hallo", data:"German"},
{label: "ciĆ o", data:"Italian - (pronounced chow; informal)"}];

var dd:DropDown = new DropDown(array, “Please choose…”, true, 100);

dd.addEventListener(DropDown.ITEM_SELECTED, newSelect);

dd.x = 10;

dd.y = 10;

addChild(dd);

function newSelect(e:DropDownEvent):void{

trace(e.selectedId, e.selectedLabel);

label_txt.text = e.selectedLabel;

content_txt.text = e.selectedData;

}

Just drag the DropDown class folder from the example fla, add the code above and you’re there…

enjoy!

SOURCE