Pimp your Flex app using WSBackgroundPixelSkin

UPDATE 07/10/07: The source code has been updated. Check out the “WSPatternStyleGenerator” to simplify the creation of its CSS patterns, too.

WSBackgroundPixelSkin is a free Flex component for creating patterns within Flex containers such as Application, Canvas, HBox, VBox, Form etc. It based on pure CSS and ActionScript without any images. It creates pretty patterns using the powerful BitmapData classes of Flex.

For determining complex patterns I’ve written a small Flex app, which loads images reading colors based on its pixels and prints this pattern as CSS code. Let me know if there anyone out there who is interested in this app. Then I’ll publish it including source, too.

Note: Programmatic skins used to extends mx.skins.Border or mx.skins.ProgrammaticSkin classes, but in this case WSBackgroundPixelSkin needs the addChild() method for adding instances of DisplayObjects and therefore it extends the UIComponent.

Screen shot


Instructions

Code snippets for using WSBackgroundPixelSkin

  1. //
  2. //  [1] Define the style properties of your pattern as follow:
  3. //  This example describes a simple pattern based
  4. //  on blue and white columns
  5. <mx:Style>
  6.     .bg
  7.     {
  8.         // point WSBackgroundPixelSkin as a borderSkin
  9.         borderSkin: ClassReference("skins.WSBackgroundPixelSkin");
  10.         // define a pixelbased pattern
  11.         // which uses the indexes of the bgColors array below
  12.         bgPattern:  "001010001",
  13.                     "001010001";
  14.         // bgColors defines color using by its pattern definition
  15.         bgColors: #3399CC, #FFF;
  16.         // measure of all pixels,
  17.         // the default value is 1
  18.         bgPixelMeasure: 12;
  19.         //
  20.         background-color: #3399CC;
  21.     }
  22. </mx:Style>
  23. //
  24. //  [2] Point the pixel based style to a container, e.g. Canvas:
  25. <mx:Canvas id="standardCanvas"
  26.     styleName="bg" />
  27. // 
  28. //  That’s all ;)    

Example (incl. source code)

Have a look on these examples including the source code. Feel free to use it, WSBackgroundPixelSkin is open source licensed under the Mozilla Public License 1.1.

Have fun! ;-)

Related Articles

Flex | Open Source

 

14 Comments

 

Leave a comment

*