UPDATE 3: Created a Google Code project here. Let me know if you’re interested in contributing.
UPDATE 2: zproxy has an interesting project here that can convert / translate .NET to Actionscript and Javascript. Check it out!
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)
7 responses so far ↓
zproxy // September 30, 2008 at 12:12 am |
Hey,
I am working on a compiler that can translate .net to actionscript and javascript. Recently i have been adding some wpf support thus i think we are doing something very similar:)
Have a look at my blog post:
http://zproxy.wordpress.com/2008/08/16/wpf-subset-powered-by-flash-and-dhtml/
I will keep reading your blog for updates on your silverlight project
WPF subset powered by Flash and DHTML « c# to javascript, actionscript // September 30, 2008 at 12:13 am |
[...] Update: Chris is working on silverlayout – wpf inside as3. [...]
Dew Drop – September 30, 2008 (Evening Edition) | Alvin Ashcraft's Morning Dew // September 30, 2008 at 8:28 pm |
[...] Silverlayout – Simple Actionscript Layout Library (Chris Cavanagh) [...]
Silverlayout for ActionScript : // October 2, 2008 at 8:18 pm |
[...] From Chris Cavanagh’s Blog … [...]
Silverlight Cream for September 30, 2008 -- #383 // October 2, 2008 at 10:54 pm |
[...] Silverlayout – Simple Actionscript layout library [...]
rutkoski // February 2, 2009 at 10:54 am |
Hi, nice project. I’m working on a project similar to yours. Take a look at http://rutkoski.wordpress.com/category/projects/actionscript-3/layoutmanager/.
Chris Cavanagh // February 2, 2009 at 7:11 pm |
rutkoski – Thanks for the link! Your LayoutManager looks cool. For me, the best thing about custom layout vs Flex is the SWF size… usually by at least 150kb!