Silverlight vs Flash: Random Moving Rotator Silverlight vs Flash: Resilience Rectangle
Sep 25

Today, when I was packing for my old files, I suddenly found out a flash game that was implemented by me 8 years ago. I was using Flash 4 at that time and the coding is really horrible.

It’s a memorable application and I got you here for the complete rewritten version. The original Flash 4 source is also included inside the zip file.

For your reference, Stray Sheep is my favorite Japanese cartoon character when I was young. I hope you will love it as well.

Comparison

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

  • Keyboard Event:  KeyboardEvent [AS3] vs KeyEventArgs [C#]

Source codes

Flash

Silverlight

KeyboardEvent [AS3] vs KeyEventArgs [C#]

Adding keyboard event is very easy in AS3. However, it will become very complicated when many keys are pressed at the same time. If you are game developer, I think you probably understand what I mean.

// AS3

stage.addEventListener(KeyboardEvent.KEY_DOWN, on_key_down);

private function on_key_down(e : KeyboardEvent):void{
	switch(e.keyCode){
		case Keyboard.LEFT:
			// do something after pressing left arrow
			break;
		case 70:
			// do something after pressing the "f" key
			break;
	}
}

The code is similar in C#. The main difference is that the keyboard event seems work only for the RootVisaul Control. I will try to figure it out later on.

// C#
this.KeyDown += new KeyEventHandler(Page_KeyDown);

void Page_KeyDown(object sender, KeyEventArgs e)
{
	switch (e.Key)
	{
		case Key.Left:
			// do something after pressing left arrow
			break;
		case Key.F:
			// do something after pressing the "f" key
			break;
	}
}

Shares and Enjoy~

Did you like this post?

Subscribe here:  

21 Responses to “Silverlight vs Flash: Stray Sheep”

  1. Alan Le Says:

    I can’t turn left with the flash version.

  2. JOKe Says:

    Yep the Left arrow in Flash version doesn’t work :)
    Maybe u need a tester ? :) huh I’m kidding :)

  3. unruledboy Says:

    I played extractly that desktop sheep when I was in win9x time :)

  4. unruledboy Says:

    use mouse to drag the sheep around? and the sheep can really walk around?

  5. admin Says:

    Alan and JoKe, I have uploaded a wrong version of swf. The problem is fixed.

    unruledboy, the desktop version is really great. I hope I could have time to implment a similar version and depoly in to AIR.

  6. Jared Says:

    Why does the Sliverlight one scroll the page everytime i push up or down? (Mac FF)

  7. links for 2008-09-25 « 思考と習作(ブックマーク) Says:

    [...] Silverlight vs Flash: Stray Sheep FlashとSilverlightとの違いについて、同じゲームを元に比較しているページ (tags: flash silverlight 比較) [...]

  8. admin Says:

    Jared, I am not sure as well. But I think its the Microsoft’s responsibility to solve out that. haha.

  9. Martijn Croezen Says:

    This method of reading keyboard input is not useful for games though.
    Right now you’re just reacting on the keyDown event, which is fired by your keyboard.
    When the user holds down a key, you’re receive 1 keypress, a small delay and then the same keypresses repeatedly.
    the duration of the delay, and the speed of the repeated keypresses is user defineable on their own computer.

    In games you should (in flash) put your keyboard reading function in your main game loop, so it gets called every frame, and instead of waiting for key events, just check which keys have been pressed using (for example) Key.isDown(Key.RIGHT)

    This also enables you to read out more than 1 key at a time.

    there should be something like that in silverlight too, but i’m not sure.

  10. Seyed Mohammad Hossein Mayboudi Says:

    Very Interesting for both of them, try to use two key!? up+right or …

  11. Samit Chakraborty Says:

    This is cool!

  12. Cubefield 2 Says:

    This is a great post and its very creative indeed but if only you people would properly give cubefield a shot. Its a great game. Very addicitve and very entertaining to all age groups.

  13. poptropica counterfeit cheats Says:

    Nice game but why dont you guys try poptropica counterfeit island instead. Its a great game and im doing a blog with all the cheats. Pls check it out

  14. Bloxorz Passcodes Says:

    Feels great that there is still good content on the internet

  15. Dukan Diet Australia Says:

    Today I made some delicious Dukan diet Mexican chicken fajitas. I fancied the whole works

  16. Dukan Diet Australia Says:

    Awesome article. I am bookmarking this on my Digg & Reddit accounts right away.

  17. Sheepskin Rugs Says:

    Many thanks for publishing this post, We were looking for it all over the internet and merely identified a fair volume of information right here.

  18. Stepanie Runzler Says:

    Time is money as the old saying goes, and by studying this put up, I spotted that I saved myself a number of valuable time, which might have been otherwise spent on reading low consistency information throughout the almighty web. Thanks for the straight to the purpose, priceless input!

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

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

  20. Asante Samuel Jerseys Says:

    My brother recommended I may like this blog. He used to be totally right. This submit

    truly made my day. You can not believe just how so much time I had spent for this

    info! Thank you!caiyifang/comment201110

  21. youth freestyle vest Says:

    1…

    well, I think the most important still is written by heart, this is the most important, this is like a person’s soul, as the flesh in how beauty, no soul, it was just a pile of meat ah, but say little song song Lou. Hope you’ll like it.jessonlin/comm…

Leave a Reply