Pixelbox

Welcome to Pixelbox. Thursday the 24 of July 2008

Skip to content >>

Caculating Dates in AS3

Here is a little example of how to return a date a set number of days from any given date in ActionScript 3 (Flex, AIR).

I used the example to return a set number of days since one of our issues launched, by sending the function the number of days and the starting date.


/* This is a public static function so it can be called from my 
utility class of useful converts and such! */

public static function returnDateXDaysFromY( x:Number , y:Date ):Date
{
  var xDaysFromY:Date = new Date(); // Date to return
  // I have removed a call to a function to set the time to zero, you can get caught out with summer time etc
  x = ((((x * 24)* 60) * 60) * 1000); // Turn days to miliseconds
  xDaysFromY.setTime( x + y.getTime() ); 
  return xDaysFromY;
}



Hopefully someone else out there will find this handy :)

Meta tags: AIR, ActionScript, Flex

Really simple analytics

At work this morning I got one of those, “can you just”. But it wasn’t asking for me to knock up copy of YouTube or MySpace by the end of the week as a favour, but rather for a simple way or reccording the number of people that interact with and click on an advert [...]

Flickr widget part 2

I had some more ideas about what to do with my flex flickr widget the other day. Inspired by Dunstan’s old blog that he never updates, I though I should get the widget to update related to my situation. For the first incarnation (and I have many more ideas of how to do this) it will [...]

Be Value

Be (everyone’s favourite 24MB broadband provider), have just lanuched Be Value to replace their Be Lite service. Be Value is limited to 8MB speed but still with the unlimited (fair usage) bandwidth. Seeing as I only got about 7.2MB out of the 24MB line, it seemed silly not to switch! This is what their mail shot had [...]
Meta tags: Technology

d.Construct 2007

This weekend I had the pleasure of popping down to Brighton (which I realised I miss from my University days immensely) to attend d.Construct 2007 put on by the clever chaps at clear:left. The day kicked of with a great talk by Jared Spool, who was a great speaker, full of energy (great for first thing [...]
Meta tags: Random

Next Page »