Right mouse click menu example

February 12, 2010

Ever wondered how to add your own right click menu item in the Context Menu of your Flex Application.

In this example I will show you step by step how to achieve this, with ofcourse a small demo application to show the result.
Read more

Easy Unix Time Function

February 10, 2010

Today I was in need of a function that would give me the current Unix Time. It might be possible that you don’t know what the Unix Time is exactly, check out this Wikipedia article.

In my need to get this time, I wrote the following quick and simple code.

It’s actually only 3 lines of code (well 5 with the function statement around it)

1
2
3
4
5
public function GetUnixTime():String{
var myDate:Date = new Date();
var unixTime:Number = Math.round(myDate.getTime()/1000);
return unixTime.toString();
}

That’s it !

If you want to show it in eg a TextInput just do this :

1
txtInput.text = GetUnixTime()

Random number in Flex

February 10, 2010

Every now and then you need to do something at random in your application (i.e. pick a random item from a collection). For that, you’re probably need some random number to decide which option to choose. Here is a simple example that shows you how to generate random numbers in Flex.
Read more

Using baseColor to Style Components in Flex 4

February 10, 2010

Flex 3 was a great product, but to be fair….changing default application appearance was a pain in the ass. I’m not a designer by any means so I was always a bit frustrated when I was trying to do something different with the appearance. Luckily for me and all you programmers out there…Flex 4 offers a nice little solution to change the defaults a bit by setting only one attribute on your application or your components: baseColor.
Read more

List Directory with AIR in Flex 4

February 2, 2010

As you probably know already, with AIR you have access to the local file system. The following example shows you how you can list the contents of a directory with AIR in Flex 4. Besides showing filenames, I also want to display the icon associated with the file.

Read more