1 of 2
1
Barebones touch / AS3 example? 
Posted: 14 July 2008 11:18 PM   [ Ignore ]
RankRank
Joined  2008-05-31
Total Posts:  163
Jr. Member

Is there a bare bones example of a truly simple application for use with touchlib?
Im really just looking for an example that places a sprite where I touch. And moves with my finger if I move it.

Id even pay some money for something like this.. And I would even turn around and start documentation on the entire process so others can do this as well.

Does something like this exist.
Yes it is great to sift through other applications, but Id like to see the true basics… Not of AS3 but of a touch enabled as3 script. I just need a starting point.

I see this in some of the code. And this makes perfect sense to me as it looks and seems to work similar to mouse events.

this.addEventListener(TouchEvent.MOUSE_MOVEthis.moveHandlerfalse0true);            
this.addEventListener(TouchEvent.MOUSE_DOWNthis.downEventfalse0true);                        
this.addEventListener(TouchEvent.MOUSE_UPthis.upEventfalse0true);                                    
this.addEventListener(TouchEvent.MOUSE_OVERthis.rollOverHandlerfalse0true);                                    
this.addEventListener(TouchEvent.MOUSE_OUTthis.rollOutHandlerfalse0true);

But how do enable using them? and can I just do something as simple as

public function downEvent(e:TouchEvent){

sprite.x = e.x;
}

What is the equivalent of mouseX? Where could I read about this?

Id really like to start documenting how to really start from point ZERO on how to program for touchlib. Im sure once you understand it, t is much easier… but right now, it is worse than pulling teeth to find something super simple, and straight forward.

Profile
 
 
Posted: 14 July 2008 11:40 PM   [ Ignore ]   [ # 1 ]
RankRank
Joined  2008-05-31
Total Posts:  163
Jr. Member

Im hoping something as simple as this

package{
    
    import flash
.display.Sprite;    
    
    public class 
Touch extends Sprite{
        
        
public function Touch(){
            addEventListener
(TouchEvent.MOUSE_DOWNdownEvent);                        
        
}

        
public function downEvent(e:TouchEvent){                    
            
var curPt:Point parent.globalToLocal(new Point(e.stageXe.stageY));                                    
            
            var 
sprite1:Sprite = new Sprite();
            
addChild(sprite1);
            
sprite1.graphics.lineStyle(50xff0000);
            
sprite1.graphics.drawCircle(0,010);
            
sprite1.graphics.endFill();
            
sprite1.curPt.x;
            
sprite1.curPt.y;
            
        
}
    }
}

Profile
 
 
Posted: 15 July 2008 12:43 AM   [ Ignore ]   [ # 2 ]
Avatar
RankRankRankRankRankRank
Joined  2007-04-08
Total Posts:  2293
Moderator

You need to first download all the classes from the touchlib svn. http://touchlib.googlecode.com

We have a class in the actions folder, called rotateablesclable. If you extend this class or make a new one and add a sprite to it, then you automatically get an object that moves around when touched.

To do something simple, like moving, rotating, and scaling a sprite, you would do…

package{
    
    import flash
.display.Sprite;    
    
import flash.events.*;        //This imports the TouchEvents also
    
import app.core.actions.RotatableScalable//Imports the class you need

    
    
public class Touch extends Sprite{
        
        
public function Touch(){

        moveable
:RotatableScalable= new RotatableScalable();
        
        
sprite:Sprite = new Sprite();
        
        
moveable.addChild(sprite);
        
this.addChild(moveable);
                                   
        
}       
    }
}

Or you could make a seperate class that extends RotatableScalable. Then add that class to your main document.

this isn’t tested, but should give you an idea of what you need.

 Signature 

Follow me on:
My Website - Youtube - Twitter - Linkedin

Profile
 
 
Posted: 15 July 2008 07:39 AM   [ Ignore ]   [ # 3 ]
RankRank
Joined  2008-05-31
Total Posts:  163
Jr. Member

thank you!

Im going to start a wiki entry (if that is ok) on the entire process with nothing left out on how to start your first touch app.

everything from SVN checkout of touchlib to publishing the app, and everything in between. (will assume only that the person knows some AS3 and nothing else)

Hopefully people will come into it and add/edit it as well. At least for spelling mistakes =)

Profile
 
 
Posted: 15 July 2008 10:11 AM   [ Ignore ]   [ # 4 ]
RankRank
Joined  2008-02-01
Total Posts:  243
Jr. Member

I can give you an app if you want?  A simple touch this, mouse over on this, mouse out on this etc

 Signature 

fingerpuk.tumblr.com

Profile
 
 
Posted: 15 July 2008 10:20 AM   [ Ignore ]   [ # 5 ]
RankRank
Joined  2008-05-31
Total Posts:  163
Jr. Member

Yeah, I would love it (with the source right ?  ). May I use it as the base for the how-to article?

Larky - 15 July 2008 10:11 AM

I can give you an app if you want?  A simple touch this, mouse over on this, mouse out on this etc

Profile
 
 
Posted: 15 July 2008 10:39 AM   [ Ignore ]   [ # 6 ]
RankRank
Joined  2008-02-01
Total Posts:  243
Jr. Member

Sure, as long as we get credit.  I’ll post a link up in a few hours, I need to go through and remove all the copyright stuff and the names of people I’m not allowed to share etc.  We’ll have a ton of buttons that do stuff on MouseOver, and then some will take you to a working photo app showing pictures of stuff and things. smile

 Signature 

fingerpuk.tumblr.com

Profile
 
 
Posted: 15 July 2008 03:45 PM   [ Ignore ]   [ # 7 ]
Avatar
RankRankRankRank
Joined  2008-02-22
Total Posts:  559
Moderator

cerupcat is right you should try his method first. I found that working through problems is a great help.
You can give a man a fish and he can eat it.
or
You can teach a man to fish and he can eat forever
lol

 Signature 

http://www.justinriggio.com cool mad
http://www.niceminds.com My blog

Profile
 
 
Posted: 15 July 2008 03:54 PM   [ Ignore ]   [ # 8 ]
RankRank
Joined  2008-05-31
Total Posts:  163
Jr. Member

I know , I know. Im a big believer of this. But I have also found, show someone how to do something you know how to do… save a mans sanity.

If we can build upon the shoulders of others we can build higher than they.

Im planing on taking this really really far. But I want to create documentation so good no one ever has to ask these questions again. And so others can take it further than they could if they spent all their time learning what is already known.

justin - 15 July 2008 03:45 PM

cerupcat is right you should try his method first. I found that working through problems is a great help.
You can give a man a fish and he can eat it.
or
You can teach a man to fish and he can eat forever
lol

Profile
 
 
Posted: 15 July 2008 04:24 PM   [ Ignore ]   [ # 9 ]
Avatar
RankRankRankRank
Joined  2008-02-22
Total Posts:  559
Moderator

your right too. Just give it one more try. I can also give you some code free to use if you want.

 Signature 

http://www.justinriggio.com cool mad
http://www.niceminds.com My blog

Profile
 
 
Posted: 15 July 2008 04:35 PM   [ Ignore ]   [ # 10 ]
RankRank
Joined  2008-05-31
Total Posts:  163
Jr. Member

Im trying it now. Just got home from work.

Ill let you know what happens.

justin - 15 July 2008 04:24 PM

your right too. Just give it one more try. I can also give you some code free to use if you want.

Profile
 
 
Posted: 15 July 2008 05:38 PM   [ Ignore ]   [ # 11 ]
RankRank
Joined  2008-05-31
Total Posts:  163
Jr. Member

So.... Hmmm.... Ummm....
First, I cant start from scratch because no matter what I do I can not get the fla to see the .as

I used
package app.demo.touch{

the .as was in a folder called touch. That folder was in the same folder that the fire folder was in… so it should have worked. I checked this 20_ times. The .fla was in the same folder the fire.fla was in as well.

So then, I tried to just use that fla and that .as, and just go from there. Well this is what i have.
The sprite creation from click is to make sure It is working (it is not).

If I delete everything but my code to add a sprite on click it works great.
I tried 50 different things.

Im so lost.
Where is the documentaton to tell me where stuff should be built?
Can I just put the .as and .fla in the same folder? how does it know how to get everything else then?

Please help.

Error
1046: Type was not found or was not a compile-time constant: RotatableScalable.

Profile
 
 
Posted: 15 July 2008 06:04 PM   [ Ignore ]   [ # 12 ]
Avatar
RankRankRankRank
Joined  2008-02-22
Total Posts:  559
Moderator

------------------------------------------------
//Structure
------------------------------------------------

src - Flash CS3 source and deployment assets
int - internal libraries
ext - external libraries (papervision, tweener, etc..)

com.touchlib - TUIO socket (renders touch input)

app.core.action - Actions for objects (Rotate/Scale, scroll, doubletap, LockMedia)
app.core.canvas - Container and lens objects (MediaCanvas, nCanvas, Zoom)
app.core.element - Interactive objects that typically act as controllers (Knob, Slider, Toggle)
app.core.loader - External content loaders
app.core.object - Objects that can be rendered on a canvas element (ImageObject, VideoOject)
app.core.utl - Misc utils

app.demo - Demo applications assets

------------------------------------------------
//Development
------------------------------------------------
Here is some general guidelines to follow when building demo applications.

Think of the app.demo folder as you would Windows Program files, all application classes and assets
go into a folder. A typical folder:

app/demo/appName - Folder
app/demo/appName/assets - externals (images, fonts)
app/demo/appName/appNameClass.as - Document Class
app/demo/appName/readme.txt - About the app (license, version)

When committing new applications please keep graphics to minimum, exclude things like background
and text objects unless necessary for programs operation. If possible put on solid black background.
Also try to clean up any unused library elements.

Use flash components as much as possible eg: Button

------------------------------------------------
//FLA Setup
------------------------------------------------
Document Class: app.core.appName
Source Paths: ../lib and ../ext
Publish Resolution: 1024x786
Background: Solid Black
Publish path: deploy/appName.swf

------------------------------------------------
//Deployment
------------------------------------------------
www - dynamic web objects
local - dynamic local objects
appName.swf

 Signature 

http://www.justinriggio.com cool mad
http://www.niceminds.com My blog

Profile
 
 
Posted: 15 July 2008 06:11 PM   [ Ignore ]   [ # 13 ]
Avatar
RankRankRankRank
Joined  2008-02-22
Total Posts:  559
Moderator

here is some code I wrote

package app.demo.myMovieClip{

    import flash
.events.*;
    
import flash.display.*;
    
import flash.geom.Point;
    
import flash.filters.*
    
    
import flash.events.*;
    
import app.core.action.RotatableScalable;


    public class 
MyMovieClip extends RotatableScalable {

        
public function MyMovieClip() {

//----------------------connect to TUIO-------------------------------------------------------
            
            
TUIO.init(this,'localhost',3000,'',true);
            
trace("MyMovieClip Initialized");
//---------------------------------------------------------------------------------------------            
                        
var player:MovieClip = new MovieClip;
            var 
controlBar:Sprite = new Sprite;
            var 
buttons:SimpleButton = new SimpleButton;
            var 
player2:MovieClip = new MovieClip;
            
            
player.graphics.beginFill(0x000000);
                        
player.graphics.drawRoundRect(-2, -23202401010);
                        
player.graphics.endFill();
            
player.player.200;
            
addChild(player);
            
            
            
controlBar.graphics.beginFill(0x666666);
            
controlBar.graphics.drawRect(-220032040);
            
controlBar.graphics.endFill();
            
player.addChild(controlBar)
            
            

        
}
    }
}

 Signature 

http://www.justinriggio.com cool mad
http://www.niceminds.com My blog

Profile
 
 
Posted: 15 July 2008 07:06 PM   [ Ignore ]   [ # 14 ]
RankRank
Joined  2008-05-31
Total Posts:  163
Jr. Member

ok… so here is one of my HUGE problems.

I have

AS3/int/app/demo/myMovieClip/myMovieClip.as
AS3/scr/touch.fla

For the document class of touch.fla I have
app.demo.myMovieClip.myMovieClip
This does not work...

if I was in php at AS3/scr/touch.fla i would include(’../int/app/demo/myMovieClip/myMovieClip.as’wink;

but in the examples they use app.demo.fire.FireDemo

so why does it work for them, and not me?
I will be honest, I started from scratch and got it to work for 2min… then it started saying that it could not find it again.  WTF… I dont know either.

Profile
 
 
Posted: 15 July 2008 07:29 PM   [ Ignore ]   [ # 15 ]
RankRank
Joined  2008-05-31
Total Posts:  163
Jr. Member

To top it all off, if I have open the fire example, rename it and write over the touch.fla (just to make sure the old one was in the right place), then use the same document class that t was rejecting, it works great.

I went through the settings on both to make sure they where exact, and they where.

but now, that I have tricked the computer to working correctly, I get an error
5008: The name of definition ‘MyMovieClip’ does not reflect the location of this file. Please change the definition’s name inside this file, or rename the file.
/Users/ameyer/touchlib-read-only/AS3/int/app/demo/myMovieClip/myMovieClip.as

Profile
 
 
   
1 of 2
1