Tuio Flash Blog

Tuio as3 library

Our library currently supports:

  • TUIO 1.1
  • Cursors, Objects and Blobs in 2D, 25D & 3D
  • Binary data stream via TCP & LocalConnection
  • Callbacks & legacy TouchEvents
  • Fully implemented OSC parser

The goal of this library is to deliver a very modular, fast and open as3 Tuio framework that can be easily extended and reused. Another very important aspect is the backwardscompatiblity to make porting of existing Tuio Flash projects as easy as possible.
The diagram below should provide a pretty good overview of the library's key components.

as3LibDiagram

In the following article most of these components will be explained bottom up following the dataflow.

Tracker

Our library supports all Tuio trackers that implement Tuio 1.0 or 1.1 and can deliver their tracking data via TCP and LocalConnection in a raw binary stream.

Bridge

A Bridge can be used to convert UDP Packets into a TCP stream or a LocalConnection.

Connectors

Connectors implement the IOSCConnector interface so other connection types can be easily added. The interface is designed to also allow outgoing streams so the OSC package may also be used in the near future to send OSC commands from Flash to an OSC Server but the currently available IOSCConnectors don't fully implement that part yet.
LocalConnection: This method delivers the best performance in local environment.
TCP: This is currently the only way to directly receive data from a tracker on another computer.

OSC

The library sports a fully featured OSC parser implemented in the OSCManager class that can also be used for other osc based protocols. The OSCManager currently isn't able to send OSC commands but this will be added in the near future when the actual TUIO part of the library is feature complete.

TUIO

The TuioClient implementation is oriented interface wise on the original Tuio Java implementation and uses a callback listener model outside of as3's original eventmodel in order to guarantee the best performance for modules that build upon this api.

Legacy

The legacy package is a collection of classes that make use of the TuioClients Callback model to offer interfaces that are compatible with the interfaces used in earlier Flash/TUIO libraries. e.g. the TouchEvent of the Tuio/XML library.

New Eventmodel

The new eventmodel is currently still worked on but will basically be a combination of the old TouchEvent and the callbacks of the TuioClient.

Callbacks

As already mentioned before this callback model is very similar to the one used in Java and is simply used by implementing the ITuioListener Interface and attaching an instance as a listener to the TuioClient. You can find more on that topic in our Guide section in the article Using the TuioClient.

Comments (32) Trackbacks (20)
  1. Where it can be used?

  2. It can be used to create e.g. multitouch or fiducial based applications in flash/as3. See tuio.org or nuigroup.com for more on that topic.

  3. is it possible to determine the tracker? i have 2 cameras working, but need to determine from which camera the tuio data is coming from.

    Cheers.

  4. If your trackers support TUIO 1.1 you can get that information by checking yourTuioClient.currentSource

  5. When do you think the support for sending OSC will be added ?
    Thanks

  6. It already is in the latest svn revision. I’ll write a guide about this when I am done with writing the new guides and updating the current ones.

  7. is there an OSC library that does only that?
    I mean, a full osc dedicated one?

  8. I think flosc had som classes for handling osc but that is based on the old brdging via XML. I don’t know of any newer fully OSC dedicated libraries but the osc part of my library should cover most osc needs since it was designed to be an independent part.

  9. Awesome! Just what I was looking for. I tested it and it works perfectly so far. Thanks for your great job.

  10. Ah, I moved that article when I updated the guide section some time ago and seem to have missed to fix this link. Thanks for pointing that out. Should work now.

  11. You should start by very clearly SHOW what this library is about. I was looking for an open source (flash) blog engine, and ended up here. Where I had to scroll browse around for a while to find out what this was all about.

  12. well sorry for the confusion. I somehow stopped at putting the words tuio everywhere, which if you don’t know what tuio is, isn’t very helping I guess.

  13. have one bug
    use in flash builder, if creat [object InvalidatingSprite] i can’t received event such as TOUCH_DOWN…

  14. Does it work with a normal Sprite? The dispatching should work with every subclass of DisplayObject. You could try adding your listener directly to the TuioManager which also dispatches the TouchEvents on itself but with the original event target. Via this you can have a look what happens to your TouchEvents.

  15. Hi gimmix, thanks for this very powerful lib.
    I’m currently on the svn version and it works well !
    I don’t know if it’s the right place to put some suggestions but i’ve got some ideas (not ordered) :

    – As mentionned in the main “how to use TuioManager” comments, it would be great to be able to get an array of all the cursors / fiducials / … that are on a same object.

    – As the new version is using flash 10 (or upper), it would be nice to convert the Arrays to Vector.. Some arrays relying on the getObjectsUnderPoint() function won’t be changeable, but it would be a great improvement on recursing and recurring functions.

    – The TuioDebug is blocking the GestureManager (and maybe TuioManager too) when set to DISCOVER_NONE. I don’t know if it’s the right thing to do, but when the debug is initialized, it could be automatically inserted in the ignoreLists.

    – The RotateGesture is fine but the algorythm could be much simplier by using the Math.atan2(dist.x,dist.y)

    – I understand the TuioCursors (or TuioContainer) are defined accordingly to the TUIO 1.1 specs, but adding the stageX and stageY variables into the Class would be handy when accessing the TuioContainer. Again, i’m sure you could have many reasons to not implement that.

    That’s it for now, thanks again for this lib !
    I had wrote my own library when all of this was new and nothing was available but this is really the upper level.

    One last thing, in my lib i created some classes that implemented already the drag/scale/rotate functionnalities, it was really useful to just have to create subclasses and define “rotatable = true”, scalable = true, movable = true or tapable = true without having to duplicate codes between different classes.

    Keep on,

    Ben

  16. thanks for the input! I’ll have a look into it.

  17. 2 more small things :
    – in the Rotate and ZoomGesture, the touch Points informations are not accessible in the event parameters, therefore the Point corresponding to the center of these touch points is not accessible either. Getting this point would allow the scaling and rotating algorythm to be calculated around this point, so scaling or rotating an object by its corner (for exemple) would make the object’s transform around this point and not around the center. This really makes a difference for the touch & transform feeling and avoid a lot of “loosing the target” behaviour if you see what i mean.

    – i added a small implementation to use the mouseEnabled property on parent objects.

    If you’re interested by some of my modifications feel free to tell me and i’ll give you the sources.

  18. The first point actually is possible and the rotation and zoom gesture are already implemented in the way you described it in the current svn revision of the library. That the points in the actual event are not accessible is due to the use of as3′s native gesture event.

    Modifications and fixes are always welcome ;)

  19. Hi, loving the look of this library.

    Is it possible however to track more than one fiducial on the table at once with the same id? It’s important for my current project.

    Cheers.

  20. Yes that is possible if you implement your own ITuioListener which will allow you to do whatever you need to with the incoming trackingdata.

    See this article as a reference to get started http://bubblebird.at/tuioflash/guides/using-the-tuioclient/

  21. Is in version 0.8 already the support for sending OSC?
    Thank you for a great job!

  22. yes sending OSC is supported since v0.7. I should probably integrate that into this page ^^

  23. hi, am developing a Flash application using tuio as multitouch. but it’s having the problem that when i show a pop up Window to render the facebook login, i can’t create another tuio for that window to listen mouse/touch event. Seem only one window can connect tuio at a time.
    Anybody have solution for this?

  24. Hi, is the new window a part of the flash app, a new window of the flashapp or a normal browser window? If it is part of the flash application I would suggest faking the window inside the global stage.
    Otherwise you could try to find or write a little script that takes the udp/tcp messages from the 3333 port and forwards them to two different ports e.g. 3334 & 3335 where the flash application and the facebook window listen.
    If it is a normal browser window you will need to use some kind of tuio2nativetouch bridge which you can find here tuio.org/?software

  25. it’s a new window of AirApp from using this fb APIs : http://code.google.com/p/facebook-actionscript-api/
    can u show me how detail of faking is? or is it possible to switch tuio to listen to that window?

  26. Sorry if this has been answered previously, but do you know if Wacom’s OS X drivers provide TUIO data, or whether they can be adapted? I’m interested in the Cintiq, and specifically the new 24HD Touch.

  27. Mh I only know of this project which runs in windows. Maybe you can ask there for some help or port http://nuigroup.com/forums/viewthread/8933/ and http://code.google.com/p/bamboo-tuio/

    Maybe you can borrow a citiq somewhere and check if it works with tongseng -> https://github.com/fajran/tongseng/

  28. Thanks for the reply. I have a 24HD Touch on its way. I’ll post my results next week once I’ve run it through its paces.

  29. Can you advice about Flash versions supported by TUIO AS3 library? I have Flash CS3 Professional that supports ActionScript 3.0 (I know it is old version). It seems that flash.net.DatagramSocket is not available (OSCDatagramSocket extends DatagramSocket). Thanks!

  30. Hi Krists. You have to be able to publish Air2.0 if you want to use the UDPConnector or at least Flash 10 for the library to work properly. Afaik that isn’t possible in CS3.
    If you are working on Windows I’d suggest that you only create your graphical assets and animations in Flash and export them as .swf files and import those into a FlashDevelop project in which do all the coding and the final export.

  31. Thanks for reply! I figured out I can use LocalConnection connector and udp-flashlc-bridge with my setup.


Leave a comment