Flash vs Silverlight: Sponge Image Flash vs Silverlight: Laser Orbit
Sep 03

Here is another 3D application without using any 3D Library. You may navigate the application via a mouse click or mouse wheel. A spring effect is also applied. Let’s see how brilliant it is!

It included both Flash and Silverlight version with complete source codes.

My Recent Updates

Today, I was asked to convert an application, written by me in Silverlight Beta 1,  to Silverlight Beta 2. I am so amazed that the project created in Beta 1 can’t be opened in Visual Studio (with the latest Silverlight Beta 2 Tool).

OK, that’s fine. I try to create a new project and copy and paste the files one by one. However, things didn’t go smoothly. Most of the Controls I created before can’t be reused again due to some syntax problem, double/int problem and some Initialization problems. Actually, I really want to say some swear words to Silverlight at that time. (Just imagine that you can’t open a Flash 8 FLA by Flash 9.)

But may be I can think in another way. Because Silverlight is such a lovely Software, it makes me the only one that can master it a little bit better than my colleague. HaHa.

If you have the same experience as me, please feel free to  share with me. (Or even tell me if is there any effective way to convert Beta 1 to Beta 2.)

Comparison

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

  • Mouse Wheel Event: MouseEvent.MOUSE_WHEEL[AS3] vs Native Method [C#]
  • Image Rendering

Source codes

Flash

Silverlight

Mouse Wheel Event: MouseEvent.MOUSE_WHEEL[AS3] vs Native Method [C#]

Actually, there is nothing special to attach a mouse wheel event in AS3.

// AS3
stage.addEventListener(MouseEvent.MOUSE_WHEEL, on_mouse_wheel);

However, you will be amazed that Silverlight doesn’t support Mouse Wheel Event. Well, we can bear in mind that Silverlight is keep improving. Anyway, after referring to the article http://silverlight.net/blogs/msnow/archive/2008/07/29/tip-of-the-day-23-how-to-capture-the-mouse-wheel-event.aspx. I found a work around in solving this problem.

It’s very simple (but not too beautiful), just too ask the browser to capture the mouse event and handle it in our code. Since different browsers may return different parameters, you have to check everything carefully. Well, don’t think too much, just copy and paste will be ok.

// C#
HtmlPage.Window.AttachEvent("DOMMouseScroll", OnMouseWheel);
HtmlPage.Window.AttachEvent("onmousewheel", OnMouseWheel);
HtmlPage.Document.AttachEvent("onmousewheel", OnMouseWheel);

private void OnMouseWheel(object sender, HtmlEventArgs args){
    double mouseDelta = 0;
    ScriptObject e = args.EventObject;
    // Mozilla and Safari
    if (e.GetProperty("detail") != null)
    {
        mouseDelta = ((double)e.GetProperty("detail"));
    }
    // IE and Opera
    else if (e.GetProperty("wheelDelta") != null)
        mouseDelta = ((double)e.GetProperty("wheelDelta"));   

    mouseDelta = Math.Sign(mouseDelta);
}

Image Rendering

The images used in the example below are resize 2 times to it’s original scale. It’s very clear that Silverlight performs better than Flash in resizing images.

In previous article, it was discussed that there is an "Allow Smoothing" in Flash 9 than can help to produce a better rendering. However, this function cannot be applied to dynamically loaded image, which is quite useless since most of the time we need to load images from Internet.

Note: Thanks for  Sasha Dzeletovic’s suggestion. Actually there is a "smoothing" property for bitmap image which can enhance the smoothness for the dynamically loaded image. (Original Post: Enable Smoothing on Images for scaling in Flex 2)

Shares and Enjoy~

Did you like this post?

Subscribe here:  

21 Responses to “Flash vs Silverlight: 3D Image Navigation”

  1. Sasha Dzeletovic Says:

    Hello,
    Nice post and a nice test! I just wanted to point out that there is a solution for smoothing a dynamically loaded image in Flash CS3 / Flex 2&3.
    You can find the details in this post (check out the comments for various implementations including dynamic):
    http://weblogs.macromedia.com/mc/archives/2006/09/enable_smoothin.html

  2. admin Says:

    Thanks for your suggestion. That’s really easy and it’s my mistake to overlook that.

    I have added your suggtion at the end of the post.

  3. Martin Beeby Says:

    These comparisions you are doing are great!!!!!

  4. Ben Hayat Says:

    Hi Martin;

    I downloaded the source for SL for th, but the code is not for this article. It is for rotating logos.

    Is this a misplaced source?

    Thanks!
    ..Ben

  5. admin Says:

    OH, yes, sorry for the mistake. I have uploaded the wrong files and they are now corrected. You may download it again.

  6. Silverlight resources for Flash developers Says:

    [...] are done in each respective technology.  Terence starts with a concept/question to himself (i.e., 3D image navigation) and then goes about creating that sample in both Flash and Silverlight…with the goal of an same [...]

  7. Shahed Khan (MVP C#) : Silverlight resources for Flash Developers Says:

    [...] done in each respective technology.  Terence starts with a concept/question to himself (i.e., 3D image navigation) and then goes about creating that sample in both Flash and Silverlight…with the goal of an same [...]

  8. unruledboy Says:

    hey, well done!

  9. Joe Gornick Says:

    I’d like to point out that mouse wheel support is not supported for Flash on Mac OS X. You can find a solution here: http://hasseg.org/blog/?p=138.

    Keep up the great work on these Flash vs Silverlight posts!

  10. Silverlight resources for Flash developers | What did you mean ? Says:

    [...] are done in each respective technology.  Terence starts with a concept/question to himself (i.e., 3D image navigation) and then goes about creating that sample in both Flash and Silverlight…with the goal of an same [...]

  11. Telmo Says:

    Great job. Keep up the great work. A great resource for Flash/Silverlight creative designers and developers.

  12. Ion Drimba Says:

    The Image Navigation flash example is scrolling 2 itens with the mouseWheel

  13. Faisal Says:

    Wow! Super example. Excellent stuff.

  14. buzzman Says:

    Greets! Really interesting. keep working! Tnx! Saw!

  15. Roman Says:

    I think Silverlight is much better then Flash.I choose Silverlight.:))

  16. rafiq Says:

    it navigates one by one . not to navigate three slides before

  17. Sleuth Says:

    Great sample!
    We use it for our adult search engine made with silverlight :)
    best regards

  18. Adrian Says:

    You are a wonderful human being.

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

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

  20. Flash vs Silverlight Gallery « Tam Quang Blog Says:

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

  21. chair slipcovers Says:

    Cool, so that’s how its done. Awesome info. though.

Leave a Reply