This sample is extracted previously from my Silverlight Project. The source codes are highly configurable and you may customize it for you needs. Though it’s pretty simple but yet very good to act as a background for you application.
Comparison
Flash implementation: 40 Minutes
Silverlight implementation: 1 hour
Blog writing: 30 Minutes
Code variation in the source code:
- Color Setting: RGB to int [AS3] vs Color.FromArgb [C#]
Source codes
Mystery Magic Background [Flash 9, AS3] (9.2 KiB, 1,610 hits)
Mystery Magic Background [Silverlight 2, C#] (44.9 KiB, 2,551 hits)
Flash
Silverlight
Color Setting: RGB to int [AS3] vs Color.FromArgb [C#]
In AS3, there is not class for converting an RGB value to int value. However, it’s not too difficult to calculate the color value from RGB. Below is an example in creating an ellipse by an given RGB variables (I have also included the conversion code of color value to RGB value as well).
// AS3, creating an ellipse var ellipse : Shape = new Shape(); // RGB value to color value var color:uint = red * 0x010000 + green * (0x000100) + blue; ellipse.graphics.beginFill(color, alpha); ellipse.graphics.drawEllipse(0, 0, size, size); // color value to RGB value var red:int = ( color & 0xFF0000 ) >> 16; var green:int = ( color & 0x00FF00 ) >> 8; var bblue:int = color & 0x0000FF;
In the case of C#, you may use the static function FromArgb and create the Ellipse on the fly.
// C#, creating an ellipse Ellipse ellipse = new Ellipse(); ellipse.Width = size; ellipse.Height = size; ellipse.Fill = new SolidColorBrush(Color.FromArgb(alpha, red, green, blue));

September 1st, 2008 at 6:20 pm
for me the silverlight background is not moving :)
September 1st, 2008 at 7:11 pm
The application should work well for Silverlight Beta 2. What about other samples, are they working for you? Which browser (and version) you are currently using?
September 24th, 2008 at 10:54 pm
Thanks for those AS3 color conversion lines. I was banging my head against the wall about converting a getPixel() uint into its separate RGB values. You saved my day!
September 25th, 2008 at 4:28 am
Sander, glad to heard that the information saved your time. Hope you will continue to support my site.
September 25th, 2008 at 9:19 am
import any of this example for flex?
September 25th, 2008 at 2:53 pm
mnieves, currently, I don’t have any plan to deal with Flex now.
September 25th, 2008 at 10:16 pm
ok, Thanks for this useful examples. there great.
December 4th, 2008 at 2:00 pm
great job, i always get inspirations from your work:)
January 20th, 2009 at 6:20 am
Thats nice. It works.
How we get the reverse of same.
i.e. if i have Rectangle and i want to get color in argb() when rectangle is clicked.
Send me some solution.
Thanking you.
July 14th, 2010 at 2:42 am
[...] Flash Silverlight Download [...]