Multi-Touch Water Simulation Example

Microsoft Surface has a cool simulation that allows you to drag your fingers across the table to create a water simulation. That got me to thinking about doing it in Flash. Thanks to David Lenaerts’ excellent Ripple class, it took me about 10 minutes to create the example below.

As you can see the performance is very nice. The code that I used to create this is below. Again, all of the cool stuff comes from David’s code.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import be.nascom.flash.graphics.Rippler;
import flash.events.TouchEvent;
import flash.ui.Multitouch;
import flash.ui.MultitouchInputMode;

Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;

stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;

var t:Bitmap;
var r:Rippler;

t = new Bitmap(new bmap());
addChild(t);

r = new Rippler(t, 60, 6);

stage.addEventListener(TouchEvent.TOUCH_MOVE, handleMouseMove);

function handleMouseMove(e:TouchEvent):void
{
    r.drawRipple(e.stageX, e.stageY, 20, 1);
}

Commentary

  1. Alex says:

    Nice! I’ve seen this class before, but this is the perfect use for it.

  2. 2 minutes later and I have a version of it of you running on the Google Nexus One. Needs to be optimized, but it’s still fun to ripple your head. ;)

  3. phil says:

    Love to see a demo of this running on android.

  4. Here’s it running on a Google Nexus One with 2.2 :

    http://flashmobile.scottjanousek.com/2010/06/04/lee-brimelow-ripple-head-test-google-nexus-one-running-air-app-flash-10-1/

    I didn’t make any mods or optimizations, so besides tweaking the graphic it’s the same. :)

  5. That music made me think you could also combine the effect with a multi-touch theremin.

  6. Ogy says:

    awesomely simple yet awesomely wow..

    great stuff

  7. Shezman says:

    Maybe I’m just dumb but I didn’t find the download link from the google code page :S.

  8. david cao says:

    I running same demo on Moto Droid with 2.1 is very slow.

    like to see more tutorials on mobile platforms optimized, thanks

  9. Lawrie says:

    Multi-touch theremin?! Now there’s an idea!
    Great video Lee. I can’t wait to get playing with multi-touch coding.

  10. David says:

    Hey Lee, I’m glad you found the class useful (and thanks for the credit). It’s an honour to see it used here :)

  11. Nazario Fraija says:

    What multitouch screen is used in the video?

    Thanks!

  12. Nomari says:

    easy and nice
    thanks lee

  13. Klaus says:

    The line

    t = new Bitmap(new bmap());

    does not work on my flash, I did something wrong?

  14. Khaled says:

    Waw nice Demo lee

  15. Hahaha “Milky Hauwert”

    …poor milky…

  16. MeetAndrew says:

    Hi Lee,

    Will that monitor you’re using work on a mac with flash 10.1?

  17. Anthony says:

    @ klaus

    the new bmap() likely points to an image that is in his library exported for actionscript and called bmap :)

  18. lee says:

    @MeetAndrew no OS X does not support multi-touch displays.

    @Anothony yes you are correct sir :)

  19. Klaus says:

    Nice, it works now. Thanks!

  20. Edson Luiz says:

    very good it.
    I did the port to Mototrola Droid and it worked perfectly.

    Hello Klaus.

    To solve this problem select Properties from the image export for action script and class colocque (bmap).

  21. simon says:

    i’ve been using this rippler class for a while now….it’s wonderful

  22. good Demo, like to get my hands on an Android and see this in real life.

  23. Almog Koren says:

    Hi Lee, funny that you used that class I played around with it for the AMO touch table game that I did some time ago,
    http://www.youtube.com/almogdesign#p/u/2/RNJd4KxVmWY

    Its a great example of a really wold project using Flash for touch tables at half the cost of Microsoft surface.

    http://www.almogdesign.net/portfolio/amo-interactive-touch-table-game/

  24. Min Thu says:

    This is a pretty cool example. Water effects are very attractive with multi touches. I hope to see more examples on flash multi-touch.

  25. realflow 100 says:

    Do you actually touch the screen?Will it work with any computer?

  26. Shing says:

    Thanks Lee, nice example! Very cool idea of using rippler for muti-touch device apps. And thanks to David too :)

  27. simon says:

    cool effect. I don’t have a touch screen monitor so I applied it to some web cam tracking. Check it out http://simon-townsend.com/as3/motion-tracking-ripples/

  28. Paul says:

    Newbie question, but where i can get those ui.Multitouch and ui.MultitouchInputMode libraries to make it work ?

Leave a Comment