Monthly Archives: July 2006

Getting it on with Flex 2 "content" coordinates

In Flex 2, UIComponent class provides several useful functions to convert Flash’s global and local x and y coordinates to “content” coordinates. If your component has a 10-pixel border, and its subcomponents always appear inside that border, you might want to establish a content coordinate system that makes a subcomponent at (0,0) appear at (10,10) instead. This is a great addition that I noticed in either beta 3 or the final release of Flex 2. I’ve been making great use of functions like contentToLocal, contentToGlobal, localToContent, and globalToContent. You’ll also find the contentMouseX and contentMouseY properties which automatically convert mouse coordinates.

There’s one missing bit of functionality that I can’t find in the documentation. I’d like properties for the content area width and height. Maybe a rectangle representing the bounds of the content area. Windows Forms in the .NET Framework have a property called ClientRectangle which has this functionality. As a poor hack, I might assume that the distance to content (0,0) should be the same on the opposite corner. That won’t work on the Panel component, though. The title bar of the Panel is bigger than the bottom border. So how do I figure out where to find the bottom-right point of an arbitrary component’s content area?

As a worst case scenario, I could put a temporary, invisible component in there and use constraint-based layout to align the component at the bottom-right corner, but I’d rather just do a little math to calculate this value.

Update (7.17.2006): After some searching, I discovered the viewMetrics property in the Container class. It returns an EdgeMetrics object that holds the sizes of each of the borders. You might also find the viewMetricsAndPadding property useful as well.

AdvancED Flash Interface Design spells it out

I write code by day, but I combine my Actionscript skills with a love of art and design by night. Looking to pick up some new tricks, I recently picked up AdvancED Flash Interface Design by Michael Kemper, Guido Rosso, and Brian Monnone. Inside, you’ll find tips for combining the strengths of Photoshop, Illustrator, and Flash, all sorts of little tricks to help you achieve interesting visual effects, and a decent overview of the different stages of design, from planning to completion.
Continue reading

Add FlexComponents to your mailing lists!

The new FlexComponents mailing list is now live. Whether you’re having an issue subclassing one of the base Flex Framework components, or you’re starting from scratch on top of the UIComponent class and want to know more about all those functions you can override, this is the place to go. Unlike the famous FlexCoders list, which covers all aspects of Flex (check it out, if you haven’t yet), the components list will only focus on custom components.

Adobe wants the community to go hog-wild with components. That’s why Ted started the list. I don’t doubt that Flex.org will be expanding soon to include all sorts of useful component information. If you’re interested in some of what the community is building already, check out the Flex Exchange. It just opened, so more and more components should be added in time.

I recently posted a very simple component there. It’s a specialized TextInput box that will grow or shrink to fit its text. This component is beyond simple to implement, but it worked well in my Regular Expression explorer and I’m sure that others can find uses for it too.