Flash vs Silverlight: Grid Transition Rotator Flash vs Silverlight: 3D Image Space
Sep 07

A simple water drop effect on an image. It demonstrated how to use masking/clipping in Silvelight and Flash.

Vote for this sample

Flash is Better! (461 votes)
Silverlight is Better? (401 votes)

Comparison

Flash implementation: 1 hour 30 minutes 
Silverlight implementation: 1 hour 
What’s the difference?

  • Masking: mask [AS3] vs EllipseGeometry + Clip [C#]

Source codes

Flash

Silverlight

Masking: mask [AS3] vs EllipseGeometry + Clip [C#]

This time I am going to show how to use an Ellipse/Circle to mask an image. It also demonstrates how to move the mask.

Remarks: Since the masking approach is different in Flash and Silverlight, the effect produced in the samples above doesn’t look exactly the same.

// AS3
// create the mask
var imageMask : Shape = new Shape();
imageMask.graphics.beginFill(0x000000);
imageMask.graphics.drawCircle(0, 0, radius);

// position the mask to the center of the image
imageMask.x = image.width / 2;
image.Mask.y = image.height / 2;

// mask the image
image.mask = imageMask;

addChild(image);
addChild(imageMask); // you must add the mask into the stage, too

// move the mask
var mask:DisplayObject = image.mask;
if(mask){
	mask.x = newX;
	mask.y = newY;
}

In C#, it’s more less the same. However, if you want to reposition the mask, the approach is slightly different.

// C#
// create the mask
// You may use RectangleGeometry as well
EllipseGeometry ellipseGeometry = new EllipseGeometry();
ellipseGeometry.Center = new Point(0 , 0);
ellipseGeometry.RadiusX = radius;
ellipseGeometry.RadiusY = radius;

// mask the image
image.Clip = ellipseGeometry;
LayoutRoot.Children.Add(image);

// move the mask
EllipseGeometry ellipseGeometry = (EllipseGeometry)image.Clip;
if(ellipsGemoetry != null){
	Point center = ellipseGeometry.Center;
	center.X = newX;
	center.Y = newY;
}

Random Posts

20 Responses to “Flash vs Silverlight: Water Effect”

  1. Water Effect by Flash | FlexMan Says:

    [...] http://www.shinedraw.com/animation-effect/flash-vs-silverlight-water-effect/ [...]

  2. Silverlight Travel » Blog Archiv » Flash und Silverlight Says:

    [...] http://www.shinedraw.com findet man ein recht interessanten [...]

  3. Ricardo Says:

    Thanks for the article. The links to the source code aren’t working.

  4. admin Says:

    Ricardo, sorry for that, I just migrated the server and the download path was not set properly. I have fixed the problem and you may download it again. Thanks.

  5. Ross Says:

    You specified the time it took to developed and code repository sizes for both run times. Can you explain how come Flash took 30 mins longer when the code size is half the size of Silverlight? Or just give some thoughts on why there are differences.

  6. admin Says:

    HI Ross, Thanks for your question.

    Actually I started to implement Flash and then copy the logic to Silverlight. That’s why the time used on the Silverlight is lesser. I think I will specific which technology I started first to give reader a better idea the effort behind.

  7. Silverlight vs Flash: Kaleidoscope Says:

    [...] my previous article Water Effect, we have discussed how to clip the object easily using Ellipse or Rectangle. However, if you want [...]

  8. infocyde Says:

    Look almost exactly the same, with maybe the Flash image being slightly crisper.

  9. Pete Says:

    @infocyde funny, I actually thought the flash version was more pixelated :)

  10. Vinney Says:

    The biggest difference I can see is sort of goo animation effect of the mask. If you notice, the SL trails are more fluid and react quicker and clearer. In order for the flash animation to achieve this level of seamless transitions, you’d just about have to double the frame rate. Sure you could speed the animation up, but look how clean the SL is. Until your cursor is flying across the image, you don’t see multiple circles, it looks like one metamorphicing, organic shape.

  11. Joseph Says:

    Maybe it’s the red border causing the greens to stand out more but the Flash image looks more crisp to me too. (Look up color theory and the War Craft 3 christmas ork effect for possible reasons why.)

    Otherwise the effects appear the same visually though there does seem to be a difference in how their movement was implemented. (Note however that I am using Flash 10)

  12. From Flash to Silverlight… - Rudi Grobler Says:

    [...] Flash vs Silverlight- Water Effect [...]

  13. Lubbykko Says:

    Good site! Interesting information.. )

  14. solo sexo Says:

    Here is much work done, obviously. Good site

  15. birdwing Says:

    The circle jitters in silverlight its not as smooth as flash.

  16. James Friedman Says:

    I assume people are thinking silverlight is better because of the quality of the image underneath the effect. In Flash, image smoothing is turned off on Bitmaps by default to save quality, you just have to set the bitmaps smoothing property to true or if you are drawing bitmapdata, pass in true as an argument for smoothing.

  17. erik Says:

    the flash demo is terrible.

    I don’t have silver light installed and can only imagine it is no better from the remarks, has anyone here ever heard of the bitmapdisplacement “filter” in flash. It has the potential to look like real water, with ripples, and refracted light if you really get complex, try a search on google. I would offer a link, but it’s been around for a long time so I’m positive you can find it. Blows these out of the water!

  18. erik Says:

    haha, I even had a demo of it open by accident, your welcome:

    http://www.flash-filter.net/rain-drop-water-effect.phtml

    I even think the link is a poor example, some one couldn’t restrain themselves with the effect, I hate it when people over use flashy effects, it makes out community look like a bunch of noobs.

  19. Silverlight user Says:

    Wee, here we go again with the 24 fps and the “i can’t even see the SL example but I still think flash is better” crap.

    Learn to compare please.

  20. best online classifieds Says:

    Very impressive indeed.
    Good job. Please keep the good stuff coming.
    We love it.

    Warm regards,
    Alexander and colleagues

Leave a Reply