Sep 17
This is a very simple rotator with flip effect. You may further customize it by modifying the scaleY and rotation as well.
Personally, I really like making image rotator since I always got many ideas on the transition effect. I hope I can implement as many as possible.
Comparison
Flash implementation: 50 minutes (Implemented First)
Silverlight implementation: 30 minutes
What’s the difference?
- Remove Children: removeChildAt [AS3] vs Children.RemoveAt[C#]
Source codes
Flip Rotator [Flash 9, AS3] (347.5 KiB, 2,974 hits)
Flip Rotator [Silverlight 2, C#] (398.3 KiB, 3,274 hits)
Flash
Silverlight
Remove Children: removeChildAt [AS3] vs Children.RemoveAt[C#]
In AS3, you have to be very carefully about null object, especially adding/removing object to the child. Otherwise, you may got into error troubles.
// AS3
// Create a triangle mask
var sprite:Sprite = new Sprite();
// ok
addChild(sprite);
// also ok, the sprite will be added to the end of the display list
addChild(sprite);
// will throw an error
addChild(null);
// ok
removeChild(sprite);
// will throw an error
removeChild(sprite);
// the best practise
if(sprite && contains(sprite){
removeChild(spirte);
}
// remove all child
while(numChildren > 0){
removeChildAt(0);
}
In C#, it will only throw exception for Add operation. On the other hand, the Remove function will only return a flag indicating whether the action is successful.
// C#
Rectangle rectangle = new Rectangle();
Children.Add(rectangle);
// throw an ArgumentNullException
Children.Add(rectangle);
// throw an ArgumentNullException
Children.Add(null);
// return true
Children.Remove(rectangle);
// return false
Children.Remove(null);
// remove all child
while(Children.Count > 0){
Children.RemoveAt(0);
}

September 18th, 2008 at 1:48 am
[...] Flash vs Silverlight: Flip Rotator [...]
December 19th, 2008 at 12:58 am
[...] (This sample is similar to my previous post “Flip Rotator“. You may take a look as [...]
February 12th, 2009 at 3:04 am
no comment
June 21st, 2009 at 1:21 am
[...] Flip Rotator [...]
December 6th, 2009 at 1:55 pm
Nice posts. Keep it up.
January 20th, 2010 at 4:31 pm
If I wanted to substitute canvasses made with Expression Blend instead of jpgs, I would delete
private String[] IMAGES = { “images/image1.jpg”, “images/image2.jpg”, “images/image3.jpg” };
But I am not sure how to finish the substitution. Any suggestions?