Flash vs Silverlight: Colorful Fireworks Silverlight vs Flash: Stray Sheep
Sep 24

This is the 4th Image Rotator I have made so far. I don’t have much description for this one, just experience it yourself!

By the way, some people raised an issue that the images seems blur in Flash when compared to Silverlight. The main reason is because I have set the JPEG quality to 80% when publishing the SWF. The quality may be poor, but in turn of a smaller file size.

Comparison

Flash implementation: 40 minutes
Silverlight implementation: 50 minutes (Implemented First)
What’s the difference?

  • Rearranging array items randomly [AS3] vs [C#]

Source codes

Flash

Silverlight

Rearranging array items randomly [AS3] vs [C#]

Rearranging an array is useful if you want to make some “Fill” effect. In this sample, during each rotation, the program will randomly generate the target position of each grid. This is done by reorganizing the position array.

// AS3
// create an array
var _positions:Array = new Array(50);
for(var i:int = 0; i < _positions.length; i++){
	_positions[i] = i;
}

// reposition the array randomly
for(var i:int = 0 ; i < _positions.length; i++){
    var targetIndex:int = int(Math.random() * (_positions.length - i)) + i ;
    var temp:int = _positions[targetIndex];
    _positions[targetIndex] = _positions[i];
    _positions[i] = temp;
}

In C#, the code is pretty similiar.

// C#
// create an array
int [] _positions =  new int[50];
for (int i = 0; i < _positions.Length; i++)
{
    _positions[i] = i;
}

// reposition the array randomly
int seed = (int)DateTime.Now.Ticks;
Random r = new Random(seed);
for (int i = 0; i < _positions.Length - 1; i++)
{
    int targetIndex = (int)(r.NextDouble() * (_positions.Length - i)) + i ;
    int temp = _positions[targetIndex];
    _positions[targetIndex] = _positions[i];
    _positions[i] = temp;
}

Shares and Enjoy~

Did you like this post?

Subscribe here:  

12 Responses to “Silverlight vs Flash: Random Moving Rotator”

  1. Eugen Says:

    Nice again.
    Just curios, if I can use your C# code for my image gallery to show different transitions between images?
    Oh, and something else, maybe you can show us how to do some visual effects like Windows Media Player or Winamp has? of course they won’t be tied to music, just some random movement.
    Thx

  2. admin Says:

    Eugen, yes, you can use my code for you own application.

    For those Visual Effect in Windows Meida Player or Winamp, the effect is a little bit difficult to implement. But you may send tell me which effect you want to implmenet and I will see if it is feasible for me to do that.

    By the way, I will continue to create rotator effect here and probably will make a component for user to use all of the effect easily.

  3. Eugen Says:

    thx, I’ll try to use them.

    About effects, anything that is easy to implement, anyway if I’m not mistaken everything there is based on some fancy formulas :)
    I tried to google for some C++ code, but no success :)

  4. Silverlight Cream for September 25, 2008 -- #376 Says:

    [...] Silverlight vs Flash: Random Moving Rotator [...]

  5. Chris Duva Says:

    Hi and thank you for taking the time to share these great effects.

    I am trying to convert this to VB.Net and I have 2 problems.
    1. In the breakImage method of the GridImageAnimator class, VB cannot determine which object’s Children to Add(rectangle) to. Same problem with reference to Children in removeAllChildren with Children.Count and Children.RemoveAt.

    2. When you add the image holders right after the RandomMovingRotator page initialization: LayoutRoot.Children.Add(_backAnimator) VB says: “Value of type BYS_Rotator.GridImageAnimator cannot be converted to System.Windows.UIElement”

    I will be happy to send you the code, if you wish.

  6. New Silverlight Image Rotators · News Says:

    [...] Random Moving Rotator [...]

  7. Manusoft Says:

    To be honest I hate Flash, mostly because everything is embedded. The images you rotate on these web page are embedded in the Flash. You cannot simply reuse the Flash on your own web site to rotate the images you choose. This is also the case with Silverlight. I would prefer a Java applet, that does the exaxt same thing, but where you can add your own parameter values, such as an array of image files to be rotated, speed of rotation, pause between each image displayed, etc… making it reusable by everyone… Can anybody code this as a Java applet?

  8. silverlightuser Says:

    Sigh… yet another moron trying to prove the betterness of Flash without a clue of how Silverlight works. Just for fun, I decided to code this example in Silverlight using Storyboard animations (as you should) and what a surprise, it performs perfectly.

    Why are all the Silverlight counterparts on this site coded by idiots?

    …oh, right, to make SL look bad.

  9. Random Moving Rotator | Silverlike - A Free Microsoft Silverlight 3 Directory Says:

    [...] image rotator created by Terence Tsang. An image will move randomly to different positions and fade out to another [...]

  10. Flash ve Silverlight karşılaştırması | AdobeHaber Says:

    [...] Flash Silverlight Download [...]

  11. convert dvd to mpeg Says:

    how did you change your thing to banana my thing for airplay is just c-76 and some numbers also if you are jailbroken you can have airplay in any app.I did not read the patent and I know apple covers all as much tech as possible in their patents but all iPhones currently in the market do not have IRI”ve been using the Pocket Tunes app for a year a half to listen to Stern on my iPhone, and its worked great. The Sirius app is late to its own party.I did not read the patent and I know apple covers all as much tech as possible in their patents but all iPhones currently in the market do not have IRI”ve been using the Pocket Tunes app for a year a half to listen to Stern on my iPhone, and its worked great. The Sirius app is late to its own party.I have been listening to your shows for awhile no, but I was wondering if there is a way to view your live streams on my iPhone or iPad? Thanks, Scott

  12. Jeanie Nuckoles Says:

    Hmm this post remind me of something :D

Leave a Reply