July 4
I'm getting ready to head out the door to go fishing, but I thought I'd share this little code snippet. It took me a while to realize this was the easy way to handle truncation with an ellipsis. Now I use it all the time (my blog inserts double greater than signs, sorry):
myString.slice(0, 150).concat(myString.length » 150 ? "..." : "");
slice() is a function on the String class in AS3 that allows you to determine the starting and ending point of the string you want to use. The concat() method, also native to the String class, does just what it indicates. It concatenates another string to the string. By leveraging a ternary operator using the same length as we are slicing from the string, we can determine if we need the ellipsis or not.
The ternary operator (myString.length » 150 ? "..." : "") states "If this string's length is great than 150 characters, concatenate an ellipsis (a "..."), else concatenate a blank string". Very concise, and easy to understand.
If you live in the US, have a happy & safe Independence Day!
June 7
A few weeks ago I converted a project to Flex 4 from the Flex 3 SDK. Overall it wasn't too terribly bad, even though the project is rather large. However, I am using deep linking to track the users position in the application, so that bookmarks can easily be created.
One of the things that readily became apparent is that deep linking, using the BrowserManager, breaks normal operation of Spark ComboBox and DropDownList components. If you attempt to perform a browsermanager.setFragment() in the change handler of one of these components, the dropdown list will not close properly and requires an additional click.
The workaround for this is to perform your setFragment call in a method called by callLater(). It's not an optimal workaround, especially if you need to do this in a lot of places in your app. But it works.
I filed a bug for this with Adobe, and it was confirmed by them as a bug. The downside is that it has been closed and deferred to a later build. I figured I would post this as a quick point of reference for those of you who run into this. If you want to check out the bug report, see the Flex SDK Bug site. I hope this helps save someone else some time and hassle.
May 19
I'm preparing to release a personal project to public beta in a few weeks. As part of the private beta, I have people giving me feedback on the user interface. Chas, my wife, complained that the time picker component I was using, from the Yahoo Astra package, was confusing. Another of her complains was that she couldn't tab through the time fields without difficulty. I have had this complaint as well, so her feedback was valuable.
In looking around at the various timechooser/timepicker controls out there, I didn't really find anything I felt worked well. I think some folks have made noble efforts at creating some nice controls, but I just didn't feel they hit the mark when it came to simplicity, usability or ease of implementation. I really did not want to develop my own because I realized this would take me a couple of my evenings. However, after hours of searching I set about to do exactly this.
I'm not going to go a lot into how I built it in this post. Overall its relatively simple, made from a DateChooser, Spark TextInputs, and a DropDownList. It has built-in validation and the isValid property on the object can be bound to determine when the date is a valid value.
Click here to see demo and view source (right click on the demo to view the source)
I have not done extensive testing on this, but would appreciate any feedback or bugs you might find. It's not skinned, so it's not the prettiest thing in the world. Also, I built the control for a Spark app in Flex 3 Compatibility mode. The demo I provided works with without Flex Compatibility mode, and you will need to change the namespaces of the ns tags to mx when you want to use it with Flex 3 Compatibility mode. I would love any feedback you might have!
May 3
I wanted to create a quick list of Flex-specific plugins I find most helpful for my day-to-day Flex development. Mostly this serves as a reminder to me when I rebuild my IDE, but I thought others may find them useful too.
FlexFormatter - This is probably the plugin I use the most. In addition to highly configurable code formatting, FlexFormatter also has some excellent tools to assist in generating ASDoc comments. Installation is easy, just download and drop the jar files into your Eclipse plugins folder, then restart Eclipse.
FlexPMD - I recently discovered FlexPMD and wish I'd had this tool much sooner. The FlexPMD Eclipse plugin works with FlexPMD to help you spot and solve issues in your code. It comes with some prepackaged tests, but you can also create and customize your own. It encourages best practices code, and will help you improve your code before you push it to production. FlexPMD can be executed from ANT tasks, and there is plenty of documentation on how to integrate this into your Continuous Integration tooling.
ActionScript Framework Downloader - If you work with frameworks and other libs, this is a tool you cannot live without. It allows you to download common frameworks directly into your project with a couple of clicks. HUGE time saver! Read the installer instructions carefully, as it does require the SVN command line tools in addition to the plugin.
Flex Builder Localization Tool - Another tool I recently discovered, the Locatization Tool assists you in removing hard coded strings in your application and replacing them with calls to localization scripts.
Mylyn -
Not Flex-specific, but Mylyn is a very popular plugin to assist with code versioning and issue
tracking. I use it with JIRA/SVN and Trac/SVN. I won't go into it a lot
here simply because so many resources already exist for Mylyn. But I do
highly recommend adding it to your workflow!
If you know of any other "cannot live without" Flex plugins for Eclipse, I'd love to hear about them.
April 29
OK, I've had enough. I've been reading this whole Apple vs. Adobe thing for months. I have my own strong opinions and they probably suck just as much as yours. And yours. And yours. So I won't bore you guys with my opinions. I am, however, just plain irritated over the whole thing. This crap shouldn't be happening. It's like two 14 year olds in an IRC chatroom arguing.
Mark Aplet and I were "discussing" the issue earlier and I mentioned a potential solution. He thought I should share this with Mr. Jobs, but unfortunatelty I'm job hunting at the moment so I just can't take the time out of my schedule to meet with him.
Now, before I outline my solution, let me just say that the only Apple product I own that I currently use is an iPod Shuffle. It's pretty awesome. I think Apple makes great hardware, and OS X seems like a decent OS. I don't use them for my own reasons, but I'm not a hater of their products, by any means. I do have an interest in the debate because I want the solutions I develop to work on all platforms. If I am working with HTML 5 in two years, so be it. I am fine with that. I love technology because it is ever changing and I love learning. But I think there's a solution to this problem which provides benefit to everyone.
Why not just create an "Apple Platform Certification" program? If a vendor, any vendor, wants to have a runtime on the Apple platform, be it iPhone, iPad or OS X, have the runtime/language/platform be certified through Apple before it is accepted. This provides two benefits:
- Apple can guarantee that the platform runs acceptably on their platform.
- Users can be sure that their experience will not suffer due to third party code.
How would this certification program work?
- Apple must provide a public certification guideline that vendors must be able to pass
- Apple can provide support to vendors to become certified. Vendors must pay Apple for this support
- Apple provides testing tools to the vendors to test their product for certification before submitting to Apple for certification. Vendor pays a fee for these tools?
- Vendors submit runtimes/platforms to Apple for certification.
- If the vendor is certified, the must maintain certification with each new major version they release
- If the vendor fails certification they can continue to pay Apple for certification support and resubmit for certification until they are able to pass the process.
- There would need to be special certification process for open source platforms. This could be provided for free by Apple to show goodwill.
Now, I am not saying this is a perfect solution, nor am I saying it is complete. What I am saying is that maybe this can be the basis for further discussions on a solution to the issue rather than inflamed and emotional arguments on the topic. This doesn't just address the Apple vs Adobe issue. it addresses the Silverlight issue and any other potential runtimes or platforms (Java?) that represent issues for the Apple ecosystem.
Do you have any other potential solutions?