Flash vs Silverlight: Image Slide Show using Perspective 3D

This item was filled under [ 新闻News ]

 

Hi Guys! I am back. Sorry for disappearing for more than a month. I am busy with one of my personal projectPencake Free Ecard. You may use the application I build using Flash to Create your own Ecard. Take a look, I believe you will be interested on that.

Anyway, today I will bring you a 3D Image Slideshow using the perspective 3d technology in both Flash and Silverlight. Implementing this effect in the past is not that easy. However, thanks for the advancement of the technology, you may now create it on the fly.

Images used inside the applications are all collected from Pencake Ecard Website.

 

Vote for this sample

Flash is Better? (78 votes)
Silverlight is Better! (213 votes)

 

Comparison

Flash implementation: 1 hour

Silverlight implementation: 40 minutes (Implemented First)

What’s the difference:

  • DisplayObject.z vs PlaneProjection.LocalOffsetZ / GlobalOffsetZ

Source codes

 

Flash

Silverlight

Flash: DisplayObject.z vs

In Flash, you may use the z property to modify the Z position of an object. However, setting the z property doesn’t mean that the objects will be sorted by the z value. The display order of the UI objects are still governed by the item added order. This is a big issue since you will have no idea which object should be on top after applying rotationX, rotationY or rotationZ.

You will find that I have done some simple hacking in my code to solve out the z-index problem.

Actually, I don’t fully understand the mechanism of perspective 3D in Flash. May be there are some solutions that could help us to solve out the sorting problem.

Silverlight: PlaneProjection.LocalOffsetZ / GlobalOffsetZ

Silverlight seems to have a more powerful perspective 3D capability. Firstly, items applied with perspective 3D will be sorted automatically. We don’t really have to do any calculations. Sorting is done perfectly even we have applied RotationX, RotationY or RotationZ properties.

Secondly, Silverlight provides two properties LocalOffsetZ and GlobalOffsetZ for us to set the position of an object. This is very useful since it allows us to rotate an object with respect to another origin defined by the GlobalOffsetZ, GlobalOffsetX and GlobalOffsetY. Unlike Flash, it can only rotate with respect to a fixed origin. But of course, we could still solve this problem in Flash by some nested children method.

  1. // C#  
  2. // create a new projection  
  3. PlaneProjection planeProjection = new PlaneProjection();  
  4.   
  5. // create a new image  
  6. Image image = new Image();  
  7. image1.Source = new BitmapImage(new Uri(“image_path.jpg”, UriKind.Relative));  
  8. image1.Projection = planeProjection;  
  9.   
  10. // rotate 90 degree with respect to the center of an image  
  11. planeProjection.RotationY = 90;  
  12.   
  13. // rotate 90 degree with respect to the origin which has z value of 100 behind the image  
  14. planeProjection.RotationY = 90;  
  15. planeProjection.GlobalOffsetZ = -100;  
  16. planeProjection.LocalOffsetZ = 100;  

Related Post

喜欢这篇文章的人还喜欢。。。

You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Comment

Anti-spam text: (Required) *
To prove you're a person (not a spam script), type the security text shown in the picture. Click here to regenerate some new text. Click to hear an audio file of the anti-spam word