Flash and Silverlight: 3D Image Rotation Flash and Silverlight: Explode Image Rotator
Aug 30

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

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));

Shares and Enjoy~

Did you like this post?

Subscribe here:  

9 Responses to “Flash and Silverlight: Mystery Magic Background”

  1. JOKe Says:

    for me the silverlight background is not moving :)

  2. admin Says:

    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?

  3. Sander Bontje Says:

    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!

  4. admin Says:

    Sander, glad to heard that the information saved your time. Hope you will continue to support my site.

  5. mnieves Says:

    import any of this example for flex?

  6. admin Says:

    mnieves, currently, I don’t have any plan to deal with Flex now.

  7. mnieves Says:

    ok, Thanks for this useful examples. there great.

  8. peak Says:

    great job, i always get inspirations from your work:)

  9. Piyush Says:

    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.

Leave a Reply