04
Nov

Testing Out ScribeFire

I don’t generally use Firefox for my every day browsing, but I do like the plugins. I use the S3 Organizer, Elasticfox (formerly the EC2 plugin) and the SQLite manager plugins fairly regularly. In fact I generally only browse with Firefox in two circumstances, 1) if I’m testing an application I’m developing or 2) when I need to do a quick search while using one of the plugins. If Firefox was configured to run first and foremost as an application platform, and secondarily as a browser, I wouldn’t feel cheated.

Anyway, today I’m trying out ScribeFire, I’ve had it installed for some time but have never gotten around to using it. Configuring it for my blog was a simple 3 step process. And now I’m going to test publishing. If I have any problems, I’ll write about them. If not, then the post ends here.

03
Nov

Styling the UITextField

I recently had a battle figuring out how to change the visual styles of the Flex UITextField component.  It came highly recommended by many over the TextField in that it added among other things, the ability to “use styles”.  They must mean it’s ability to inherit styles from its parent, because my experience with styling these monsters was a nightmare.  Although now I know the trick, it won’t be nearly so hard next time.

My goal: to change the color and decoration of a UITextField when the data it displayed was a particular value.

Initial unsuccessful attempts:

  • Call to setStyle() in the updateDisplaylist() method.
  • Call setStyle() in the commitProperties() method.
  • Call getStyle() in the updateDisplaylist() method.
  • Call getStyle() in the commitProperties() method.
  • Call textColor = 0x0000FF; in both of the aforementioned methods.
  • During this first round, the only thing I tried that did work was to change the UITextField to a Label. Unfortunately that broke my goal, I reverted to this several times over the course of several hours as I struggled with this.

    I didn’t start making progress until I refined my searches to the UITextField, rather than the UIComponent which I assumed was to blame. I also had a peek at the code and discovered that the implementation of setStyle() in UITextField was intentionally left empty, design by contract be damned. This discovery further allowed me refine my searches and I discovered the existence of the setTextFormat() method.

    I got off to a rocky start with setTextFormat(), trying initially to call it from the createChildren() method. This didn’t work. I tried it in several places and eventually found that it works when it is placed in the commitProperties() method. I’ll have to figure out why sometime when I have more time.

    Here’s the code that worked, inside commitProperties(). Keep in mind this is a list item renderer.

    var formatter:TextFormat = new TextFormat(”Arial”, 11, 0×0000ff, false, false, true, null, null, “right”, 0,0,0,0);
    var defTextFormat:TextFormat = new TextFormat(”Arial”, 11, 0×000000, false, false, false, null, null, “right”, 0,0,0,0);


    _status.text = data.status;
    if (data.status == “Changed”)
       _status.setTextFormat(formatter);
    else
       _status.setTextFormat(defTextFormat);

    You can lookup the TextFormat constructor in the documentation to see what all those fields mean, but they’re essentially most of the common styles you may want to use in a TextField. I may do some more experimentation/research to see if there’s a different/better place to put it (especially if you don’t want it being set/created each time the item renderer re-renders.

    03
    Nov

    Flex Item Renderers : Extending UIComponent

    I’ve taken a step that I’ve been wanting to do for quite some time, extending UIComponent.  Sometimes I think it’s amazing that I’ve made it this long without having to do it.

    I’m working on a project right where I’m using an ItemRenderer in a List control (nothing new) but there may be up to 100 of these renderers on screen at any given point, and even more on a large monitor.  I tried the quick and dirty method of extending HBox and adding labels and such, and I’ve finally seen firsthand what others have described about bloated item renderers.  It took about 8 seconds to render the screen on my development machine (which is a pretty powerful computer).  I decided that was unacceptable and that I finally needed to dig in.

     There are quite a few good resources I made use of, some of them more complete than others.  The first thing I did was read the Adobe documentation (Creating and Extending Flex 3 Components, PDF), specifically Chapter 9 (Advanced Visual Components in ActionScript).  It was a bit overwhelming at first, but as soon as I sat down to write some code it started making more sense.

    I’m going to document a few of the things I discovered (many of these apply only because I was creating a list item renderer).

    First, it’s pointless to do much initialization in the createChildren method.  My component consisted of a checkbox, an image, and a bunch of UITextFields (based on the recommendations from others).  I was able to set some styles on the image and the checkbox, but no method of setting styles on the text fields seemed to be effective in the createChildren method.  This point merits its own post.  For the text fields, all I did was create and add.

    Second, commitProperties is where I handled setting my data and my visual styles on the text fields.  The documentation on commitProperties seemed a bit scattered, and it actually took me some time to arrive at this conclusion.  I had the impression that some of this, particularly styling should be taken care of in the updateDisplayList method.  I tried with no success, possibly because I was still trying to call setStyle on my UITextFields (see comment about meriting its own post above).  I ended up just setting the sizes and placement in updateDisplayList (which is mentioned in all the documentation).

    Third, invalidateProperties and invalidateList (for ArrayCollection, etc) are useful for refreshing the renderers.  I tried a few convoluted methods of getting the screen to refresh programmatically, most of which worked and none of which I was pleased with, before I stumbled upon the invalidateList method.

    Fourth, in trying to change the styles of my UITextFields, I independently discovered that it’s good to go to the code (the framework code) when trying to figure something out.

    That sums up my first experience, in a nutshell, with extending UIComponent.  I’m excited about trying another one, which I am sure will go over a lot more smoothly.  I didn’t need to override measure() in this one, my next subproject will be working on a component that will help me remove the mystery from it.

    01
    Nov

    MacBook Pro : Update

    I’ve been using my new (used) MacBook Pro for a week now, thought I’d post a quick report about it.  The short summary is that it has replaced my old laptop for all the functions that I used my laptop for.  In this respect it’s performance has been nearly flawless (more about that in a minute).  Unfortunately I don’t think it will be replacing my desktop as my primary development machine anytime soon– which is OK.  My original intention in getting a Mac wasn’t to “switch” (though I have to admit I was curious about whether it would happen or not).

    Now for some of the issues I’ve encountered:

    Running Windows on the Mac.

    Despite what you’ll read on the VMWare Fusion 2 packaging, Windows is not “even better on the Mac”.  Although the performance is considerably better than I’ve come to expect from other virtual machines, I still don’t get the same performance as I did on my old laptop as far as Windows is concerned.  Running my compiler is noticably slower, checking my email in Outlook is about the same (I blame Outlook 2007, not Fusion, for this, though).

    I was originally excited about the 3D support Fusion boasted, unfortunately the two games I’m into these days use OpenGL (which isn’t supported in Fusion) and not DirectX.  Before anyone gloats because they recommended Parallels to me, which supports OpenGL, let me just say that gaming on a VM would be insane when I’ve got a perfectly good Windows PC.

    I’ve got a lot of time invested into this, so I’ll probably stick with Fusion for the convenience of switching between Windows and Mac.  I don’t think I’ll be using my Windows VM too much anyway, except when I’m on the road or at school.  Or when I need to Recycle all of the Trash I have on my Mac…

    Subversion Clients

    I do 90% of my actual coding in Flex Builder these days, and fortunately for me Eclipse has a mature, feature rich Subversion plugin (Subclipse) I can use while I develop.  I don’t use it very much when I develop on Windows because TortoiseSVN is better and I don’t have to get around the concept of “importing into a project” which Subclipse seems to want to force you to do.  Unfortunately there’s nothing that really compares to TortoiseSVN for the Mac.  The closest I’ve found is SCPlugin, which integrates into Finder, but it’s not nearly as mature as Tortoise.  It’s a little odd, especially considering how many developers you see using Macs these days, hopefully the situation will improve in the near future.

    Did the Definition of “Delete” Change?

    Please, anyone… is there a key somewhere on the MacBook Pro keyboard that behaves exactly like the “Delete” button on a PC keyboard?  (I mean besides the right-arrow/delete sequence).

    It’s easier for me to criticize than to praise, but let me just say that my MacBook excels at being a Mac, no complaints there.  I’m actually using iTunes again (which I haven’t for a long time because it used to suck so much resources on my previous PC).  And as far as notebooks go, you’d be hard pressed to find a better looking one anywhere.

    That’s my two cents.

    25
    Oct

    Simple Flex Builder Performance Tip

    I wanted to put this little tidbit out for boosting Flex Builder’s performance on all platforms.  I was ecstatic when I got my new desktop this past June (quad-core, 12MB cache, etc., etc.) and the build process flew.  It was awesome (see complaints in previous post about my laptop seeming like a dinosaur in comparison), but as time went by it started getting more and more sluggish about building my apps.

    There wasn’t any apparent explanation (except for maybe the fact that I was running Windows Vista with only 8GB of RAM) so it was a little disheartening.  On the other hand I wasn’t seeing any performance decreases in any of my other “benchmark” apps (JBoss 4.2 startup in 10 seconds, NetBeans startup in 15 seconds, Photoshop CS3 in 8 seconds) so I got a little suspicious.

    I did a little searching around and ran a few experiments, and came to realize that the more projects I had open, the longer it would take to build any one of them.  When I started closing the projects, there was a corresponding increase in performance.  This information allowed me to focus my search efforts and sure enough, Flex Builder will process every open project to see if it needs to be recompiled, and in the process compile the project you’re interested in.

    So close some of those projects (right-click, or in case of a Mac two-finger-tap, and close).

    25
    Oct

    My MacBook Pro

    I’ve been needing a Mac for some time, if for nothing more than to test my AIR applications (I’ve run into a few quirks with some of the AIR specific features of Flex between OS X and Windows).  The original plan was to get a Mac Mini this Christmas, until my brother told me he was selling his MacBook Pro.  A few factors, namely the weak options available on the Mini, and the fact that my HP (circa 2005) has seemed slower than mud since buying my new desktop computer this summer, led to my wife allowing me to buy it.

    I have now been a Mac owner for about 8 hours.  I’ve used them before on a limited basis when the BYU CS department still had a Mac lab, but I just wanted to take a few minutes now and post a few obervations and thoughts I’ve had getting up and running.

    It seems there’s a tradeoff between having a quiet notebook or having a cool notebook.  My HP has a fairly loud fan (it’s actually pretty embarassing taking that thing out in the library) but it never gets hot.  The MacBook feels like it’s about to spontaneously burst into flame.  I haven’t owned the Mac long enough to decide which vice I prefer, but the loud fan was one of my bigger annoyances on the HP.

    I discovered that “tapping” on the touchpad is disabled by default in Mac, which is funny because it’s generally enabled by default on most PC notebooks.  A quick google search got me back in business (System Preferences -> Keyboard & Mouse -> Trackpad).  And though I don’t like how dragging works: double-tap and drag, then wait a second for it to drop OR tap again; I do like the tap-with-two-fingers instead of the right click (on the PC you have to resort to the buttons to get a “right-click”).

    One of my computers on the network has been recognized, but none of the others are there and I can’t figure out how to manually browse the network to set up some “mapped drives” or the Mac equivalent.

    The final thing that’s screwing me up are the keyboard shortcuts.  A lot of the common ones are similar between Mac and PC, just different enough to screw up whatever you’re trying to do.  I’m not sure how I’ll work this one out– when I was fixing my touch pad I noticed where I could map my keyboard shortcuts.  The problem is that I’ll be using a PC-type keyboard at home when I’ve got the MacBook plugged into my KVM, but I’ll be using the notebook’s keyboard when I’m at school and on the road.  I guess I’ll see how this pans out in the next few weeks.

    Overall I’m excited to see what happens.  My plan now is to continue to use Windows and OS X, but I’m curious to see if one wins out over the other.

    13
    Oct

    Book Review: Head First Design Patterns

    Head First Design Patterns by Eric and Elizabeth Freeman was great.  The designers of the series really tout their method of presenting the material as being on the cutting-edge, and although I can’t speak for everyone, the the content really got through to me.

    I took a class a few semesters back that had design patterns as a core part of the curriculum, and it really opened my eyes as far as software development goes.  We used the GoF book as our text, which is a very thorough, technical book that I have often been thankful to have in my personal library.  I can’t deny that it comes up pretty dry when you’re trying to wrap your mind around a design pattern for the first time.  There were a few design patterns we studied in the class (out of a total of about 20) that I left without having grasped well enough to where I felt I could apply it in real project (specifically the incarnations of the Factory patterns, with the exception of a simple factory).

    The treatment of these patterns in HFDP really helped clear up a lot of the points I had struggled with before.  Reading about the patterns I felt I understood already gave me an even better understanding.  And the book is quite enjoyable, I’m not usually able to read “tech” books word for word.

    I recognized a lot of the examples my professor used in class (which he borrowed from HFDP), and I remember him mentioning the book once or twice.  I wish he had recommended it, because I probably would have benefited from it sooner.

    At any rate I highly recommend this book, and will definitely try out a few more books from the series.  I’ve already ordered HF Object-Oriented Analysis and Design, and HF Software Development (two other topics I “already know about”).

    13
    Oct

    Angle Brackets in MXML

    After using this blog theme for a few months, I should have known… When I was transferring some of the blogs from my CS 462 labs (which, incidentally, contained a lot of XML) I noticed that this theme was tenacious in the way it ate my angle brackets.

    Apparently Flex Builder doesn’t like them either when you’re editing MXML (note: though I dislike the use of XML based syntax in a scripting language like ColdFusion, I don’t mind it as much for laying out visual components, which seems a short step from using HTML)… but I forget that MXML is in fact, XML and that there are some occasions when it doesn’t like you using angle brackets.

    There are some exceptions, for example if you have the code (a > b) ? ‘x’ : ‘y’ inside a click handler, that is allowed.  Don’t try to use it inside a label or a text attribute though.  The good news is that because it’s XML, you can fall back to the good ol’ HTML escape sequences (i.e. > and <) when you need to display those characters.

    13
    Oct

    Error #2044: Unhandled IOErrorEvent; text=Error #2038: File I/O Error.

    I started this post a few months ago while I was working on an AIR application that uploads files to a remote server (by way of an upload script).  I ran into this error, Error #2044: Unhandled IOErrorEvent; text=Error #2038: File I/O Error,  which caused me considerable grief until I discovered the simple solution.  I got the same error in an application I was working on today, and so decided to finish this post.

    I looked up the problem when I first encountered it, and there seemed to be a consensus that the problem was due to using a bad URL for the location of the upload script.  That was actually the case for me today, so I was able to fix it right away.

    When I encountered the problem a few months ago, you could say that it was from using a bad URL, but it was much less obvious.  I had written the upload script in ColdFusion, hosted on a CF server.  I was certain that I had the URL typed correctly because I could access it in my browser.  I discovered over an hour later that I had an authenticated session that allowed me to see it in the browser, a privilege not shared by the AIR app.

    The problem was ultimately remedied by placing a special Application.cfc in the upload script’s directory that did away with the requirement for any session variables.  This particular case may have been due to a combination of the CF server’s settings and the fact that I was using AIR, and not a Flex app that might have been served from the same server as the upload script.

    26
    Sep

    Book Review: Adobe Flex 3 Bible

    Adobe Flex 3 Bible by David Gassner doesn’t contain anything ground breaking or spectacular, but overall I was impressed with both the breadth and depth of the book.  Granted, at roughly the thickness of a real Bible (978 pages including index), it would be quite a shame not to achieve some depth.

    What I especially appreciated was the in depth treatment of data access in Flex, particularly when it comes to integration with an application server of some sort.  When I began learning Flex it was difficult to find documentation explaining how this was done, and was glossed over in the books I had in a very unsatisfying manner (even in my favorite Programming Flex 2, I’m afraid).  I had to mostly fend for myself by pouring through example code.  It took me about 2 weeks of concentrated effort before I was able to set up my own project to use FDS and JBoss.

    Adobe Flex 3 Bible would have been a big time saver for me at that time.  It devotes over 200 pages explaining how to set up and use BlazeDS, AMFPHP, ColdFusion and ASP.NET for data access with Flex.  I was really impressed by this.  Not only is it good information, but it’s presented in a way that’s easy to understand.  I’d recommend this book to beginners on the basis of this section alone.

    One of the cover’s bullet points state “Create desktop applications with AIR” and was a bit misleading.  There’s only a small section toward the back of the book that deals specifically with AIR.  It’s not technically incorrect though, because there are insights and information about developing AIR applications interspersed throughout the book (and considering how similar Flex development and AIR development are in terms of syntax, this is not surprising).  If you’re looking to jump right into AIR development and want all the details in one place, please don’t get this book for that reason.