UPDATE 3: Created a Google Code project here. Let me know if you’re interested in contributing.
UPDATE: You can try out a sample SWF here (try resizing the window to see effect). It doesn’t include any embedded fonts, so if you don’t have Arial available you might not see much!
Here’s a simple library that gives you Silverlight / WPF -like layout controls in Actionscript 3. A few notes:
- Some of the classes you’ll find are Grid, StackPanel, Image, Border. I’ve broken the typical [lower] camel-case naming convention for consistency with WPF / Silverlight.
- If the size of the final SWF isn’t important to you (150 kb+), just use Flex instead :) Obviously it’s way more powerful and better suited. This library is good for simple layouts and if you prefer very small SWFs.
- Don’t expect too much from it and let me know which bugs you find (and fix). Some of the “stretch” behavior may differ slightly from Silverlight’s defaults (again, let me know any improvements you make).
- The Grid class supports ColumnDefinitions and RowDefinitions; currently each definition item only supports the Width / Height (adding MinWidth, MinHeight etc would be fairly trivial though). Values can be “Auto”, a size (in pixels) or nothing (defaulting to “stretch” behavior).
- ContentControl is intended to wrap regular Flash controls and resize them appropriately (Image derives from ContentControl).
- TextBlock and TextBox have TextFormat and EmbedFonts properties (they use embedded=true by default).
- Border supports multiple child elements. I know it shouldn’t; so just pretend it doesn’t🙂
- Let me know if it’s useful enough to share on CodePlex or wherever.
For documentation, the best bet is use FlashDevelop and let its intellisense help out. For more detail take a look at the source; most public properties are defined at the bottom / end of each class. Most ‘set’ properties that affect layout call the base FrameworkElement’s Invalidate() method.
Here’s the link again. The zip includes a basic test project for FlashDevelop to get you started🙂
Hope it’s useful! (it was to me)🙂