views:

241

answers:

5

I have an idea for a website which involves a canvas area which has no limit to its size. Basically you would be able to add items to the canvas (notes, photos whatever really). You would then be able to drag the canvas which would move those items along with the canvas until they disappear of screen. If you dragged the canvas back the other way they would appear again.

Question: Which would be the best suited to this type of thing, Flash or Javacsript?

My main worries are the speed at which javascript/ flash could handle moving multiple items around on screen in the way discribed. Which language would handle better for a user on a slow machine.

UPDATE:

Thanks for your opnions guys, but to clarify what are the benefits of canvas over straight jQuery DOM manipulation? or visa versa. I've never used canvas before.

+2  A: 

My initial thought would be to go with Javascript - if it's good enough for Google Maps, it's probably good enough for your app too.

Greg Hewgill
I second Javascript + Canvas.It's better to leave Flash out if at all possible.As a note I made an interactive Demo with canvas and it worked on the iPhone (no flash) just fine. Had it been flash it wouldn't have worked at all. Either way people we're impressed with the page working on the iPhone.
Robert Gould
+1  A: 

Do you need to use canvas, what you're describing could be done with just javascript and the DOM. It would perform perfectly well unless there are a huge number of elements and it would be cross-browser compatible. For canvas you would require exCanvas to support IE which can sometimes slow things down.

slashnick
+1  A: 

The best way would surely be Javascript. And I would even say that you should reconsider the use of canvas. It sounds like it could be done in pure DHTML. In that way you wouldn't lose support for IE.

Consider using one of the javascript frameworks; Prototype or jQuery come to mind. It will ease your coding immensely. Given the development in javascript-engine performance (next versions of Webkit (Squirrelfish Extreme) and Mozilla (TraceMonkey) will be lightning fast) the worries about performance may be moot.

Also if you decide that you can't do it without canvas consider using John Resig's processing.js.

erlando
+4  A: 

I don't think this is a question that will get you an objective answer - Flash developers will tell you Flash is better, web developers will say JavaScript. Trying to remain objective, I'd say that both technologies are suitable for what you describe, but have different advantages.

Flash will definitely render faster, even on slow machines, and is much richer graphically.

JavaScript is more accessible and works on a greater number of devices. Use a good JS framework though.

Iain
I think lain hit the nail on the head here...
vanhornRF
+1  A: 

I'd say go with flash (or DOM if you don't need the extra punch). Here's my reasoning:

  • You can do cool transformations with canvas (skewing, rotations, gradient fade-ins in images, reflection effects, etc) that you can't with DOM. The downside is that doing these cool things is math heavy.

  • Canvas doesn't work in IE. IE's equivalent (VML) apparently has a root-access security hole.

  • The DOM has been around for longer than canvas and since it's more widely used (and depended upon), it's more optimized and polished than canvas.

  • The Flash community has a lot of good free components available that may already do what exactly you want.

  • Flash and DOM have a lot of good documentation and tutorials, canvas not so much.

  • Flash can do pretty much everything that the DOM and canvas can, plus audio, video and grabbing input from your web cam.

Leo