Goodbye and thank you, Flash Player, for all that jazz

July 27th, 2017

My adventure with Flash Player had started back in 2002 when I’ve explored the capabilities of this platform for the User Interface prototyping at Philips Research using Flash MX components and ActionScript 2.

 

 

One of my first commercial work was games development together with Sean Wood using Flash lite development for one Japanese mobile operator, later we’ve done together interactive maps app for Ayuquila river basin area for United Nations University.

My interest into the development of UI components using Flash platform had led to my collaboration with Judah Frangipane on Tree component with Drag and drop support.

Later I worked with Dmitry Leader on Re:mark application to be used by mentors for adding remarks to the reviewed documents, early days of the company that is now known as Grammarly.

Then we played with an idea on building audio player in Flash for ukrainian mobile operator Kyivstar and Anton Antropov.

In 2005 a group of ex-employees from Macromedia and Microsoft had established an startup in intriguing Ukraine to build on Web an user customized application built in Macromedia Flex 1.5 and later Adobe Flex 2, that’s how I did open an new chapter in my life with Flex UI framework.

I’ve spent with Flex UI framework almost 10 years of my development career, did a few talks at Ukrainian Flash User group, open-sourced InputAssist component, but after Adobe decision in 2011 to abandon the future development of Flex framework it become obvious that sooner or later every seasoned Flex developer has to move on.

Nowdays my choice of technologies for modern web application is React and Redux state container, Javascript with Ecmascript 6 touch, npm and many more.

Yes, we will say the final goodbye to Flash player runtime in 2020, but Web and UI interfaces will remain with us till the very end of our professional life.

When 2 – 1 = 2 when doing math operations with dates in ActionScript

September 4th, 2011

Let’s say we have the following use-case: we have to create a calendar with Month view. The Month view can start on any day, it can be 1st of March, it can be 15th of March, it can be even 31th of March.

So, assume that our current date range starts with 31th of March. And now, what if we want to scroll the date back one month? Hah,easy, you would jump immediately with straightforward solution, just subtract 1 month from current Date.

Writing a few lines of code, doing some traces.

var startDate : Date = new Date (2011, 2, 31);
var newDate : Date = new Date (startDate.time); //displays Thu Mar 31 2011
 
trace ("startDate=", startDate.toDateString()); 
newDate.month--;		
 
trace ("newDate=", newDate.toDateString()); //displays Thu Mar 3 2011

..and wait a minute, how it is possible that 2 – 1 = 2 for new month value?

Well, the issue is that Flash Player behind the scene is fixing invalid resulting date for February month. We could not have February date with 31 days, so somebody has to do something about it, right?

To sum up we should remember about this feature of Flash Player when dealing with invalid dates and the correct operation for subtracting 1 month from existing date can be the following:

var startDate : Date = new Date (2011, 2, 31);
var initNewDate : Date = new Date(startDate.time)
var newDate : Date;
 
initNewDate.month--;				
newDate = handleShorterMonths(startDate, initNewDate, 1);
trace ("newDate=", newDate.toDateString()); //displays Mon Feb 28 2011
 
private function handleShorterMonths(startDate : Date, dateToCheck :Date, monthIndex : int) : Date {
   var correctDate : Date = dateToCheck;
   if (dateToCheck.date < startDate.date) {
        correctDate.date = startDate.date - dateToCheck.date;	
	correctDate.month = monthIndex;
   }
   return correctDate; 
}

Interactive sample with view source enabled that illustrates the issue:

Get Adobe Flash player

Alternatively, if you do not like to do Date Math operations by yourself, you can always rely on As3Commons DateUtils.as class.

This utility class has a very well written API to do various Math operations with Dates – you add days, months, years, etc. to existing date with an ease.