Archive for November, 2008
Testing Out ScribeFire
Posted by: | CommentsI 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.
Styling the UITextField
Posted by: | CommentsI 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:
setStyle() in the updateDisplaylist() method.setStyle() in the commitProperties() method.getStyle() in the updateDisplaylist() method.getStyle() in the commitProperties() method.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, 0x0000ff, false, false, true, null, null, "right", 0,0,0,0);
var defTextFormat:TextFormat = new TextFormat("Arial", 11, 0x000000, false, false, false, null, null, "right", 0,0,0,0);<br/><br/>
_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.
Flex Item Renderers : Extending UIComponent
Posted by: | CommentsI’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.
MacBook Pro : Update
Posted by: | CommentsI’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.

