Sunday, November 26, 2006

Are you still using trace() in Flex 2.0 ?

If you're still using flash trace() in your Flex 2.0 applications you should have a look at the new ILogger interface in Flex 2.0. I'm using ILogger for my own components and it's great. It's not hard to learn how to use it, especially if you have any experience of logging with .NET's System.Diagnostics.TraceListener (or with Java's log4j).

Unfortunately, with the exception of the
Flex v2.0 Data Services components, I've found that the Flash v9.0 framework runtime itself and the Flex v2.0 components don't log what they're doing and don't use the ILogger interface.

Debugging complex applications with lots of dynamically created nested MXML components would be a lot easier if the framework runtime did an :ILogger.debug("instantiating component") when components were newed, and did an
:ILogger.debug("dispatching preinitialize/initialize/creationComplete event") when "lifecycle" events are dispatched on components and logged when the lifecycle methods (createChildren(), commitProperties(), measure(), layoutChrome() and updateDisplayList()) are called by the framework run-time.

Additionally debugging complex data binding would be a lot easier if the mx:Binding
component in particular logged each time it was triggered.

Figuring out the sequence of things is proving to be one of the hardest challenges of developing big applications in Flex 2.0.

5 comments:

Gareth Edwards said...

Sequence is easily one of the hardest things to work out (I think). Are you using Cairngorm? Also, I find extending the datagrid beyond what is currently capable of is also quite difficult.

Graeme Harker said...

Yep, Cairngorm 2.0

Rich Tretola said...

Are you removing your trace statements before going to production? If not, the Flash Tracer https://addons.mozilla.org/firefox/3469/ can expose things you may not have wanted exposed.

Rich

Anonymous said...

Hello, great site, I found a lot of useful information here, thanks a lot for Your work!
With the best regards!
David

Anonymous said...

Flash CS3 is the way of the future. Adobe is taking all the componets Flex had and putting them in Flash. Example: I came across a simple image loader app written in both Flex and Flash (Actionscript 3.0). The Flash version had 3 simple Actionscript files. The Flex version had a wopping 22 files, not only did it have 22 files, they were all different types of files too. Of, course the majority of people support Flex, but only because it is free unlike Flash fo what $800 bucks. Your going to get more people learning how to program in Flex if it’s free. Here’s the catch, Adobe is playing the hook line and sinker strategy. Adobe made Flex so people would learn how to code in Actionscript. Then they start to limit features in furture releases of Flex, and improve the features in Flash. WHY?…Because Adobe wants all the people who learned Actionscript to go out and purchase Flash for the $800. Microsoft is doing the same thing with Silverlight. How else do you get people interested in a product, make the software free at first to get people hooked then start to charge them for the newer improved versions. Economics 101. Create a big demmand, then limit the supply, force people to pay big bucks. I know I wouldn’t pay $200 - $800 for new software unless I got to try it first. And 30 day demos aren’t enough to get people hooked. You may think I am wrong, but just wait you’ll see.