RIA Developer, Flex / Flash, Widgets
Posts tagged Tip of the day
Tip of the Day – When to use try… catch… finally
Jan 17th
A wise Adobean once told me to use try / catch / finally statements sparingly. It didn’t mean much to me at the time since I honestly don’t use them very often. Instead, I opt to check conditions prior to executing “at risk” statements.
So… here’s my advice that when it comes to try / catch statements.
Preventing errors from occurring is far better than generally handling them.
Take a look at this example.
var goodObj:Object = {foo: "bar"}; var badObj:Object = null; tryErrors(goodObj); tryErrors(badObj); function tryErrors(obj:Object):void { // DO THIS if(obj) trace(obj.foo); else trace("doing something else"); // NOT THIS try { trace(obj.foo); } catch (e:TypeError) { trace("error occurred"); } } /*** OUTPUT *************** bar bar doing something else error occurred ***************************/
Do not use blanket try / catch statements.
You gain nothing by catching an exception that your application can’t deal with at that point.
For example, if you’re trying to convert a string to a number, and you know it might fail, but you have a default value, you should catch the exception, set the default value, and allow execution to continue.
Another example, if you try to call a Web Service and the call fails, and that particular call isn’t critical to your application, you could catch the exception, warn the user that some information is not available, and continue execution.
Only use try / catch when you have to.
I don’t have any specific benchmarks, but I do know that using excessive try/catch statements will degrade performance of your flash application. Probably because Flash Player is single threaded, but an Adobe person would probably have more information on that than I do.
An application I worked on a while ago used a try catch block around every single function… not my fault, it’s code that I inherited… anyways, it’s performance and execution times were horrendous.
Tip of the Day – Tools of the freelancer
Jan 16th
So I ran across this blog post this morning, brought to us by themikej. He discusses some tools he uses in his everyday life as a freelance contractor.
Everything he mentions in this post I personally use, and he sums it up well.
So for today’s tip, I recommend reading it.
Oh… and I stole my blog theme from him.
Tip of the Day – Using Fireworks to skin those Flex Applications
Jan 15th
Today I was going to post about using flashvars and widget development. However, as I started to document the process, it became too much information for a single tip. So I’m going to do a separate post walking you through my widget development process. Now on to today’s tip!
To be honest with you guys, I’ve never really been a huge fan of Fireworks. I’m a Photoshop guy, and I have been since version 5.5 (hooray ImageReady). However, at our last SeaFlex meeting Marty gave a quick introduction into Flex skinning using Fireworks. My eyes were opened! So here is the basic run down of creating Flex skins using Fireworks CS4.
- Within Fireworks go to Commands > Flex Skinning > New Flex Skin

- Select the components you want to skin.

- Skin to your heart’s desire.

- When you’re finished, go to Commands > Flex Skinning > Export Flex Skin

- I created a new folder called testSkin and saved to that.

- Now in Flex Builder. File > Import > Skin Artwork

- Browse to the folder we just exported our assets to.

- Make sure the image to component mappings are correct.

- And…. you’re done.

Amazing.
:: UPDATE ::
Marty just posted a PC (and more in depth version) of the skinning your Flex applications with Fireworks. Read it here!
Tip of the Day – Flex Builder, Open Resource shortcut
Jan 13th
So while thinking about the tip I wanted to write today… I thought about my development process, and trying to identify things that I do to speed up my development. That way I can share them with all of you.
One thing that has become second nature to me is the use of the Open Resource shortcut in Eclipse (and therefore Flex Builder). This handy little shortcut is a life saver.
For all the pcs: ctrl + shift + R
For all the macs: ⌘ + shift + R

This panel allows you the type in the resource you want to open, even if it is open already, and will bring it to focus. It’s amazing! Use it, love it, cherish it.
