How to name it ?

Not so FLEXible with FLEX

Posted in Adobe, Flex, Technical by Srini on December 9, 2009

Having been on the Visual Studio side of the fence for more than 3 years, Microsoft eclipsed any opportunity for the need or necessity of a secondary IDE. When opportunity knocked on to work with Adobe Flex, never did I know that I would gasp for my breath at some stage. As we know every language and environment comes with its own pitfalls and Flex has the share of its own, which at the current stage might leave you gasping especially if you have worked earlier on .NET with Visual Studio. Here are some efforts to highlight what you might experience, and suggestions if any to overcome the same.

For starters, the current Go-Live development version of Flex (as of this writing) is Flex 3 whose SDK is pretty much a free download , but if you want to leverage the advantage of the classic IDE support you may need to invest on a Flex Builder 3 license. A limited day evaluation of Flex Builder IDE is available for free on Adobe Downloads if you wish to jump-start. The Flex Builder IDE is built over the fairly known Eclipse IDE and if you have worked earlier on Eclipse (which was perhaps not my case), you might have probably experienced some of the IDE related points discussed here.

A Date with Dates

The Date objects in Flex are treated differently. To jump with an example straight away, if you try to write something like this hoping to set a Date to 28th Jan 2009, you may very well be wrong.

           var myDate:Date = new Date(2009,01,28);

Flex month index is a zero based index, meaning a month “00” will mean January and “01” will be pointing to February! So beware, when you execute the above statement you are setting the Date to 28th Feb 2009. The same holds good while you are debugging and “Expression Watching” any Date Objects. A Watch on the above will give you something like this. Note the month value!

There’s another interesting thing which needs attention here. Date Manipulation in Flex doesn’t get simple either. If you want to move one month back from a date, say 31st March 2009, we generally use AddMonths(-1) in .NET or DATEADD() functions in SQL. I haven’t come across any direct Date Manipulation functions in Flex and one of the ways to do it is provided below.

     var myDate:Date = new Date(2009,02,31);
     var day:Number = myDate.getDate();
     var month:Number = myDate.getMonth();
     var year:Number = myDate.getFullYear();
     var newDate:Date = new Date(year,month – 1,day);

Alternatively we can also do a myDate.month = myDate.month – 1 and use the same myDate object.

Note that we have set the starting date to be 31st March 2009 (A month index of 2 is March). So if you are expecting the newDate value to be 28th Feb 2009, well you may be wrong! The value we get, very interestingly is 3rd March 2009. On doing a month – 1, Flex does not care about which month or which year we are currently in, instead it blindly goes back to 31st Feb 2009. Since Feb 2009 ends on 28th, the difference of 3 is added to the subsequent month and we end up with 3rd March.

We should generally be writing our own logic to handle such scenarios, if need be. Nevertheless, Date manipulation logic finds almost no support in Flex 3 native libraries. DateUtil functions on the web may probably solve some deal though, so if you are on the hunt for one, you can probably start with here – http://code.google.com/p/flexdateutils/wiki/DateUtils

So, enough on dating? How about doing an event – perhaps a pop-up party !!

Handling Events on Popups

If you have found that sometimes when you add an EventListener to a class and it never listens, never worry – you have some company. The event listener mechanism needs a special mention whenever it is raised from a pop-up window.

For a very quick overview, we have an Application class in Flex underneath it we get all the UIComponents. So within any of the component if you say this.addEventListener() it can bubble across till the Application layer making sure that all components within the Application scope are ready to listen. However Popups is an exception, because a Popup is a child of the SystemManager and not the Application class. Treat it as a sibling to Application, who are now probably not on good terms. So you gotta register the complain to their dad for them to fairly work!

To put simply, if the addEventListener() is from a Popup screen then this.addEventListener() is not going to work, instead use Application.application.systemManager.addEventListener() to take benefit.

I came across this situation once, and this is the place where I got the solution – http://www.munkiihouse.com/?p=45

So after dating and partying here is some real stuff to whack your brains!!

FLEXible Maths

If,   a = 100.1;
       b = 200.7;
       c = a + b;

What is c?

You don’t get a free beer if you say 300.8, because Flex thinks it’s 300.79999999999995. Even more strangely, if you change a and b to 100.7 and 200.1 respectively, it calculates perfectly to 300.8. This round-off error gets introduced for some strange odd decimal equivalent for which I haven’t figured out the reason yet. But for the fix, here is something that can help.

var objnumberFormatter:NumberFormatter = new NumberFormatter();
objnumberFormatter.rounding = NumberBaseRoundType.NEAREST;
objnumberFormatter.precision = 1;
objnumberFormatter.format(c);

The above snippet will emit a string for a single decimal precision rounding of the result to the Nearest equivalent.

Hope it helps!

Keep looking out, I should be soon adding the IDE related tips.

Sky is the Limit !!

Posted in Microsoft by Srini on March 19, 2009

Remember the app that made Scoble cry. It now has its Web avatar!

WorldWide Telescope Web Client is now available. It looks as close to its Windows Desktop original. Running on top of Silverlight 2, it freezed up just once while I played around with it now. Absolutely brilliant stuff for an Alpha product.

worldwide-telescope

Breaking the barriers of its ability to run in Windows machine only, now Worldwide Telescope can be run from almost all systems supporting IE, Firefox and Safari already. The title is indeed true, now only Sky is the Limit! Give it a try right away, as all that you need is Silverlight 2 installed.

Can you make others Live?

Posted in Charity, Microsoft, Windows Live by Srini on February 28, 2007

And that, by doing a simple Search !!

Yes, you can easily reach millions of children with financial aid indirectly by searching at http://click4thecause.live.com

For every search performed there between January 17 and March 31, 2007, Microsoft will make a contribution to ninemillion.org, a UN agency-led campaign providing education and sports programs for the nine million refugee youth around the world.

I know, Live is no-where getting near to Google Search as of now, but I’m going to give it a try for the whole of March and then comment on my observations. I’m bookmarking the page so that I can contribute my two cents atleast !!

Give it a try, and spread the word.

Cross posted at my other blog

MSN Direct and SPOT

Posted in Microsoft, Microsoft.NET by Srini on January 25, 2007

While I was browsing through the long list of Microsoft’s announcement for this years CES, I landed on a video commercial speaking about MSN Direct and the long touted SPOT (Smart Personal Object’s Technology) watches.

Intersetingly, the announcement of MSN Direct and SPOT has come out on the last year CES itself, but this Video commercial is looking new to me which also speaks about Microsoft .NET Micro Framework !! Continued research revealed news that Micro Framework came to public BETA on mid-2006 itself.

Anyways, this promo is worth a watch.

Check it here

Yahoo Messenger for Windows Vista

Posted in CES, Microsoft, Windows Vista, Yahoo by Srini on January 10, 2007

While Microsoft Chairman and Chief Software Architect, Bill Gates pushed Windows Vista at the key note address of CES 2007, other partner companies will also promote hardware, software and services targeted for Windows Vista. On the race, it is expected that Yahoo will be showcasing its new Yahoo Messenger specifically powered for Windows Vista.

                          yahoomessenger.png

 The new Messenger looks brilliant on the Design and also on features. This is an excellent example of how Vista’s new APIs can be leveraged across the applications that runs on the top of this OS. Yahoo Engineers have nicely utilized the power of WPF, usability of Sidebar Gadgets and hopefully the powerful desktop search feature.

You can check out the official site , and don’t forget to check the video preview

P.S : Channel 10 is making extensive coverage on Microsoft at CES. There’s also a video on the new Yahoo Messenger for Windows Vista.

Hello world!

Posted in Blog Updates, Misc by Srini on December 25, 2006

In an attempt to group all my technical and semi-technical posts at one place, I have replicated the relevant posts from my older blog to here. Also from now on, all my technical posts will be posted over here and only here !!

To maintain a smooth transition, I have imported the older posts with the older dates itself and of-course ‘yes’ with all your comments preserved :). The game is on !!

Microsoft Robotics Studio

Posted in Microsoft by Srini on December 16, 2006

If Robotics has impressed you ever, and have you been wondering why there isn’t any tool available to make easy productivity on these lines – now, the answer is here. Microsoft has now announced its Robotics Studio 1.0 !!

To the extent I understood, Robotics Studio will be a new software development kit for the robotics community to program on a wide variety of hardware.

The letter from Tandy Trower, General Manager, Microsoft Robotics Group, reads : Microsoft Robotics Studio delivers in three areas of software:

  1. A scalable, extensible runtime architecture that can span a wide variety of hardware and devices. The programming interface can be used to create applications to drive robots using 8-bit or 16-bit processors (from a connected PC) as well as 32-bit systems with multi-core processors; and devices from simple touch sensors to laser distance finding devices.
  2. A set of useful tools that make programming and debugging robot applications scenarios easier. These include a high resolution visual simulation environment that integrates software physics supplied by the Ageia Technologies PhysX engine.
    While Microsoft Robotics Studio can be used with programming languages such as those included in Microsoft Visual Studio and Microsoft Visual Studio Express, also included is a new visual programming language that enables the creation of applications using a simple drag-and-drop interface.
  3. A set of useful technology libraries services to help developers get started with writing robot applications, and tutorials which illustrate the basics of how to get started in a variety of programming languages.

Seems pretty cool. Should have to wait and watch on how it evolves 🙂

Zune Debuts, Vista Ready, Office 2007 Complete

Posted in Microsoft by Srini on November 15, 2006

The Redmond based Software Giant is all set to roll out some of its biggest product line-up !!

After keeping silent for a long long time, Microsoft is now ready to take on Apple with a toughest challenge. To me iPod is unbeatable and has already set a trend. We’ve gotto watch how much impression is Zune going to make !! But, they are out just on time to make business over the Christmas and ThanksGiving holiday season.With almost similar pricing, feature sets and killer-looks the competetion looks very close. However I’m not convinced with the Zune’s Portal.

Well, now the biggest news is out 🙂 The much awaited OS from Microsoft which has been on development close to 5 years is all set to release. The Home Page has all the news you want to know. While the Internet is flooded with reviews after the RTM , I have been reading pretty cool reviews so far. Don’t miss out Paul Thurrott’s coverage on WinSuperSite !! We cannot ask for anything more comprehensive than that, and there is more to come 🙂

With enhanced security, superior performance, integrated Desktop Search, improved Speech Recognition, IE7 and WM11 bundled and a brand new UI and not to forget what you see – a cool new packaging, it all seem to rock the world completely.

And for the MS Office freaks, the official news is out. The launch date announcement will be out pretty soon and I hope it will join Vista on the Jan/Feb range.

On both Windows and Office front, they are going for an upgrade after a huge time and ofcourse with revolutionary changes. Its going to be an exciting time ahead !!

Google Doodles !!

Posted in Google by Srini on October 21, 2006

Actually you guys would have noticed it a lot of times before, the Google Doodle that Google puts up on their home page on Holidays and other important events. Now sample these two, what they made earlier for – “The FIFA WorldCup’ 06” and “American Independence Day’ 03”. (I’m breaking rules here.. they have mentioned not to use them anywhere else :)) You’ll fall in love the moment you watch it!! Creativity at its best 🙂


Now the interesting thing is, Google has dis-associated itself ever from creating a Doodle when the Holiday has a religious relevance. They have verbally accepted it before. Infact you can never even see one for Christmas or Easter. But just now i saw them doing one, but still without breaking the rule!! See where it goes and tell me what does it strike you when you see it? What all can you infer and interpret?

It’s 2-2 !!

Posted in Microsoft by Srini on June 21, 2006

The current Indian News channels seem to have got the audience pulse correctly. While I couldn’t resist sleeping (without watching the match) last night after a tired day, the England-Swedan match was chasing me even in my dreams. As the first job of the morning I switched on the TV to know the scores, and almost every news channel tickerd them in bold “It’s 2-2” 🙂 While we speak on this topic, let me remind you we are speaking totally outside the topic !!!

Well, the news is Microsoft is almost 2 down !! Robert Scoble, a most respected Microsoft Technical Evangelist and a highly popular MS blogger is quitting Microsoft to join a new start up company named PodTech.NET. Known to the blogging world as Scobleizer, his Blog is an Encyclopaedia for any technology enthusiast. Sample this – his own post on his decision. Must Read 🙂

Yes I know, you might have rightly got the second now. They will be two down by 2008. If you want the original story from Horse’s mouth – here it is. I got the Scoble news only a day before Bill Gates, to be struck by a twin blow on back to back days 😦

However they will begin to gear it up by stepping up Ray Ozzie and Craig Mundie up on their corporate ladder. So two up !!

Related LinksChannel9 Video Interview with BillG and SteveB & BillG’s EMail to All Employees

Also, Special Thanks to Vadivel and Sriram :).