Archive for June, 2008
Scrolling VBox
Posted by: | CommentsIf you give a Flex VBox a fixed height and then fill it with children that exceed that height, the vertical scroll policy kicks in and the VBox scrolls. I try to design my applications to look good on different resolutions and in different window sizes, which means I rarely set a fixed height for my VBoxes, opting for percentage heights instead. The problem I encounter is that it’s nearly impossible to get a variable height VBox to scroll. It will always expand to hold all its children, forcing the application (or other parent) to scroll on its behalf.
One of my coworkers was struggling to get his application to behave correctly in this respect, and so I set to creating a vbox that can be set to a percentage height and width, and will also scroll rather than expand the boundaries of the application.
I was able to accomplish this by simply nesting a VBox within a Canvas. Then I overrode the following methods:
addChildremoveChildremoveAllChildrenaddChildAtremoveChildAt
so that when adding children to the component, they would be added to the VBox, not the Canvas.
I had to be careful, because the VBox had to be added to the Canvas somehow (do you see the circular reference problem?)– I just did a check to see if the child was the VBox. If it was I added it as a child of the Canvas using a call to super.addChild().
Now when I set the height to 50%, the Canvas will remain staunch at 50% and the VBox will scroll once it reaches the borders of the Canvas.
This might be sufficient for use within Actionscript, but I also wanted to be able to add children using MXML. This will be easier to see in the code, but what I did was create an array of children and make it the default property of the ScrollableVBox. I also overrode the commitProperties method to check if the children array had changed, and if so I iterated through the children and made them children of the VBox. I accomplished this detection by using a Boolean flag and the set method of the children array. This procedure is described in the Flex documentation here, look for subheading "Implementing the commitProperties() method.
Download the ScrollableVBox source here.
Incompatible Stickers
Posted by: | CommentsAnyone who has ever ordered a computer online (particularly from HP’s site) should be able to relate to this… As you use the drop down boxes to select the features you want for your computer the web app keeps a diligent eye open for any conflicts among your selections. Although a truly user friendly site would not even display a conflicting choice, much less choose it… let’s overlook that and just say that it’s a helpful feature inasmuch as it points out hardware incompatibilities and the like.
There were two instances when I’ve found this helpful feature to be a bit too helpful. The first happened nearly a year ago when the HP laptops were JUST starting to become available with 4GB of RAM. (Side note: my wife says I can’t get a new laptop until I graduate, which I’ve been on the brink of for the past year or so. So I frequently window shop for laptops). I selected the 4GB of RAM, and was notified that I had to choose a 64 bit operating system. I knew this was not the case (you can have 4GB installed on a 32-bit OS… it might not all be available, but it won’t break the system), regardless, I had specifically chosen not to upgrade to the more expensive 64-bit OS because I had 64-bit OSs available to me already.
I decided to call HP sales and ask them about it, and they told me flatly that it couldn’t be done. The cost of the 4GB RAM upgrade was $700, which I pointed out to them, but they still insisted that they couldn’t sell me a computer with 4GB of RAM and a 32-bit OS. About 4 months later, I discovered that the system did not bark about that particular conflict anymore. I thought maybe somebody got a clue – that is until I started looking at their business laptops (which I became converted to because you can get the WUXGA screens with them, and not the home/office line… I’m not even about to call them and ask them why they can’t put one of them on their home/office computers as Dell seems to have no problem doing it).
Here you can actually choose your stickers. However, as the system will point out, there is a conflict between Windows XP and the Vista sticker, and vice versa. You can get Vista with the XP downgrade, which is compatible with the Vista sticker… otherwise you’ll have to select the XP sticker. Make sure you have a compatible processor too, if you want the Core 2 Duo sticker.
I did recently get a Dell, which is less picky about stickers, and as an experiment I took the Vista sticker off of it and put it on my HP laptop running Windows XP… and sure enought it still works. I don’t dare try sticking the Intel Core 2 Quad sticker on it though, my laptop is a few years old.


