TOUCHLIBRARY EXAMPLE 1 : Simple Paint
Posted: 01 April 2008 07:14 PM   [ Ignore ]
Rank
Joined  2008-02-16
Total Posts:  81
New Member

Hey all!

I just got my FTIR setup up and running and I am really excited about building applications for it in Adobe Flash using Actionscript 3. I did however wanted to build my own classes so now I have:
- com/touch/TouchLibrary.as
- com/touch/TouchEvent.as
- com/touch/profiles/Finger.as

My painting code is now as follows (I know it doesn’t remove the clips from the array, but that can be improved later).

package 
{
    import flash
.events.*;
    
import flash.display.MovieClip;
    
import flash.geom.Point;

    
import com.touch.TouchLibrary;
    
import com.touch.TouchEvent;
    
    public class 
SimplePaint extends MovieClip
    {        
        
private var touchlib:TouchLibrary;
        private var 
circleContainer:Array = new Array();
        private var 
paper:MovieClip = new MovieClip();
    
        public function 
SimplePaint ():void
        {            
            
//show paper
            
addChild(paper);
        
            
//create touchlib object
            
touchlib = new TouchLibrary(stage.stageWidthstage.stageHeighttrue);

            
//configure listeners
            
touchlib.addEventListener(TouchEvent.FINGER_DOWNfingerDownHandler);
            
touchlib.addEventListener(TouchEvent.FINGER_UPfingerUpHandler);
            
touchlib.addEventListener(TouchEvent.FINGER_MOVEfingerMoveHandler);
            
            
//connect to flosc
            
touchlib.connect();
        
}
        
        
private function fingerMoveHandler(event:TouchEvent):void
        {            
            
var oldX:Number circleContainer[event.params.id].x;
            var 
oldY:Number circleContainer[event.params.id].y;
            
            
circleContainer[event.params.id].event.params.stageX;
            
circleContainer[event.params.id].event.params.stageY;
            
            if (!(
oldX == && oldY == 0))
            
{
                paper
.graphics.lineStyle(6);
                
paper.graphics.moveTo(oldXoldY);
                
paper.graphics.lineTo(event.params.stageXevent.params.stageY);
            
}
        }
        
        
private function fingerDownHandler(event:TouchEvent):void
        {
            circleContainer[event
.params.id] = new Circle();
            
addChild(circleContainer[event.params.id]);
        
}
        
        
private function fingerUpHandler(event:TouchEvent):void
        {    
            removeChild
(circleContainer[event.params.id]);
        
}
    }
}

Links:
SCREENSHOT - DOWNLOAD

Image Attachments
Screenshot.jpg
File Attachments
SimplePaintV1.zip  (File Size: 4KB - Downloads: 1141)
 Signature 

Visit http://www.crystalminds.net/

Profile
 
 
Posted: 01 April 2008 08:16 PM   [ Ignore ]   [ # 1 ]
Avatar
RankRankRankRankRankRank
Joined  2007-04-08
Total Posts:  2539
Dedicated

Look good, i’ll have to try it out.

I’m not sure why you’re wanting to write you own classes though. I mean, we have a growing framework that will eventually have most if not all things one would need including events for, up, down, out, over, tap, double tap, swipe, hold, scroll, etc. If anything, we could use help adding to the collection rather than rewriting things that are made. If you’re interesting in helping with the AS3 framework, let me know.

Otherwise, good work.

 Signature 

MTmini, MTbiggie, & Audiotouch creator & Community Core Vision Co-founder

Follow on:
My Blog | Facebook | Twitter | Youtube

Profile
 
 
Posted: 01 April 2008 11:58 PM   [ Ignore ]   [ # 2 ]
Avatar
RankRankRankRank
Joined  2006-11-09
Total Posts:  1499
Administrator

Runs very well Mark congrats smile we look forward to seeing more development. I would love to compare your performances results with the existing TUIO.as on the SVN. Are you planning on releasing your lib?

I like the connected indicator as well, it would be nice if a client would check ~5-10 seconds for a connection and connect to it.

 Signature 

~

Profile
 
 
Posted: 02 April 2008 05:03 AM   [ Ignore ]   [ # 3 ]
Rank
Joined  2008-02-16
Total Posts:  81
New Member
cerupcat - 01 April 2008 08:16 PM

Look good, i’ll have to try it out.

I’m not sure why you’re wanting to write you own classes though. I mean, we have a growing framework that will eventually have most if not all things one would need including events for, up, down, out, over, tap, double tap, swipe, hold, scroll, etc. If anything, we could use help adding to the collection rather than rewriting things that are made. If you’re interesting in helping with the AS3 framework, let me know.

Otherwise, good work.

Well I had a hard time finding the TUIO class. Then someone helped me by using SVN to download all of the examples files including the TUIO, but when I loaded the FLP and tried to test some programs somehow it couldn’t find the class and there was a yellow exclamation mark in front of it. Besides that I didn’t quiet know how to use it (wished I would have looked on this forum) and so to save me from more trouble I decided to explorer the protocol (learning even more) and begin building my own which I completely understand what it does, which events will be fired and what I can expect with a total freedom of naming everything the way I prefer and putting everything in a way I find logical. This DOESN’T mean I don’t like the TUIO class, I think the framework is GREAT! And if you guys need my help on anything let me know and I will try and help and test with it. For now I will continue building on my own class, trying to improve it, but you should know that I will be mainly focussing on the 2d cur part and I see it as fingers touching the screen.

That being said, seen the fact that this is an opensource community and sharing information is what we do here. I will release the source of my library, together with an easy to read and understand documentation with tons of examples on how to use each function.

Thanks both c.moore and cerupcat for your replies! They mean a lot to me. And c.moore I appreciate your time to test my simple application :D I am glad to hear that it works nice. Knowing that this particular paint program is pretty heavy.

 Signature 

Visit http://www.crystalminds.net/

Profile
 
 
Posted: 03 April 2008 12:37 PM   [ Ignore ]   [ # 4 ]
Avatar
RankRankRank
Joined  2007-09-13
Total Posts:  333
Sr. Member

"an easy to read and understand documentation”
That sounds great, Mark. Is there such thing for the TUIO class?

Profile
 
 
Posted: 03 April 2008 12:44 PM   [ Ignore ]   [ # 5 ]
Avatar
RankRankRankRankRankRank
Joined  2007-04-08
Total Posts:  2539
Dedicated

@GFantini: lol, yes. The current SVN with will be getting complete documentation along with tutorials very soon. Even TUIO will be understandable =)

@March. Well keep up the good work. Be interesting to see the differences in your structure.

 Signature 

MTmini, MTbiggie, & Audiotouch creator & Community Core Vision Co-founder

Follow on:
My Blog | Facebook | Twitter | Youtube

Profile
 
 
Posted: 03 April 2008 03:27 PM   [ Ignore ]   [ # 6 ]
RankRank
Joined  2008-03-11
Total Posts:  138
Member

Nice work there Mark. I am a newbie trying ti understand the whole AS3 world but your app is nice and readable - my head doesn’t hurt so much!

@Cerupcat: Could you point me to the SVN mentioned above? grin

 Signature 

~ myHead.addEventListener(Event.ENTER_FRAME, functionProperly); ~

Profile
 
 
Posted: 09 April 2008 02:07 AM   [ Ignore ]   [ # 7 ]
Rank
Joined  2008-03-26
Total Posts:  19
New Member
Mark - 02 April 2008 05:03 AM

but when I loaded the FLP and tried to test some programs somehow it couldn’t find the class and there was a yellow exclamation mark in front of it.

Try renaming the com_old folder name to “com”, i.e. rename “com_old” to “com”.

It worked for me.

Profile
 
 
Posted: 07 January 2009 07:19 AM   [ Ignore ]   [ # 8 ]
Rank
Joined  2008-08-21
Total Posts:  6
New Member

Nice app, we tested yesterday using the brush and we published a video:

Profile