Need Help with touch inputs
Posted: 14 June 2008 03:27 PM   [ Ignore ]
Administrator
Avatar
RankRankRankRank
Total Posts:  597
Joined  2008-02-12

Hey guys ive been trying to implement touch inputs to a flash app i have. it hasnt been going to well. Mainly because its the touch inputs arent working.... anyway here is
a bit of code maybe someone could point me out to how to fix it. Provide me the code to implement touch inputs.

public function ParticleStream (container:DisplayObjectContainerwidth:int 800height:int 600)
        
{
            this
.container container;
            
stage container.stage;
            
canvasWidth width;
            
canvasHeight height;
            
            
initStage();
            
initLines();
            
initBitmap();
            
setFullScreenQuality();
        
}
        
        
/**
         * Sets up stage listeners
         */
        
private function initStage():void
        {
            stage
.scaleMode StageScaleMode.NO_SCALE;
            
stage.addEventListener(Event.RESIZEstageResizeListener);
            
//stage.addEventListener(Event.MOUSE_LEAVE, mouseLeaveListener);
            
            
            
stage.addEventListener(TouchEvent.MOUSE_MOVEtuioMoveListener);            
            
stage.addEventListener(TouchEvent.MOUSE_DOWNtuioDownListener);                        
            
stage.addEventListener(TouchEvent.MOUSE_UPtuioUpListener);                                    
            
            
            
stage.addEventListener(MouseEvent.MOUSE_MOVEmouseMoveListener);
            
stage.addEventListener(MouseEvent.MOUSE_DOWNmouseDownListener);
            
stage.addEventListener(MouseEvent.MOUSE_UPmouseUpListener);
            
            
stage.addEventListener(FullScreenEvent.FULL_SCREENsetFullScreenQuality);
            
stage.addEventListener(Event.ENTER_FRAMEupdate);
        
}
        
        
/**
         * Sets up line variables
         */
************************************************************************************
************************************************************************************
                private function 
tuioMoveListener(e:TouchEvent)
        
{
            
var tuioobj:TUIOObject TUIO.getObjectById(e.ID);                            
            
            var 
localPt:Point parent.globalToLocal(new Point(tuioobj.xtuioobj.y));                                                        
        
}
        
private function mouseMoveListener(e:MouseEvent):void
        {
            
//paused = false;
        
}
        
        
/**
         * Listens for mouse or touch press
         */
        
private function tuioDownListener(e:TouchEvent)
        
{
            
var tuioobj:TUIOObject TUIO.getObjectById(e.ID);                            
            
            var 
localPt:Point parent.globalToLocal(new Point(tuioobj.xtuioobj.y));    
            
//localPt.x, localPt.y
        
}
        
private function mouseDownListener(e:MouseEvent):void
        {
            
// Allow a kind of drawing-mode when mouse is pressed
            
spread SPREAD_MIN;
        
}
        
        
/**
         * Listens for mouse or touch press
         */
        
private function tuioUpListener(e:TouchEvent)
        
{
            
var tuioobj:TUIOObject TUIO.getObjectById(e.ID);                            
            
            var 
localPt:Point parent.globalToLocal(new Point(tuioobj.xtuioobj.y));                                                        
        
}
        
private function mouseUpListener(e:MouseEvent):void
        {
            
// Spread lines out when mouse is released
            
spread SPREAD_MAX;
        
}
*************************************************************************************
*************************************************************************************

private function 
update(e:Event):void
        {
            
//if (paused) return;
            
            // Line movement is set by how much the mouse has moved since its previous position and a random value
            
var dx:Number = (container.mouseX px Math.random() * 2) / 2;
            var 
dy:Number = (container.mouseY py Math.random() * 2) / 2;
            
            
// Limit the amount of movement
            
if (dx < -spreaddx = -spread;
            if (
dx spreaddx spread;
            if (
dy < -spreaddy = -spread;
            if (
dy spreaddy spread;
            
            
// Store the mouse position
            
px container.mouseX;
            
py container.mouseY;
            

            
// Line thickness varies up and down with sine
            
var s:Number Math.sin(size += 0.2) * 4;
            
            
// Put the red, green and blue values together into a single hexadecimal value
            
var c:uint = (Math.sin(red += RED_STEP) * 128 127) << 16 | (Math.sin(green += GREEN_STEP) * 128 127) << | (Math.sin(blue += BLUE_STEP) * 128 127);
            
            
// Create a new point on the line
            
list.push(new particlePoint(pxpydxdysc));
            
            
// Draw!
            
drawLines();
            
drawBitmap();
        
}

well as you can see all my mouse events do is detect if the left mouse button has been pressed or not and change the spread/thickness of the drawlines function. in Update i have my actual work being done, where is checks for the location of the mouse and draws accordingly. my main problem is i am unable to change this part so it works the way its working with the mouse.

any help would be apprecaited.

NOTE: any by the way i know my touch inputs dont do anything at the moment either.... what i am more worried about is how to get my touch events to draw first and then i plan to work on the spread.

thanks in advance for the help

Taha

 Signature 

My MultiTouch Blog

Profile
 
 
Posted: 14 June 2008 05:22 PM   [ Ignore ]   [ # 1 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  1351
Joined  2007-04-08

Is that all your code? I don’t see where you connect “Tuio.init(blah, blah blah).” You need to import the flash.events and have TUIO.init(). Do you have that somewhere?

 Signature 

My Multitouch Blog
My Youtube
Multitouch FAQ - Need Help? Click here!

Profile
 
 
Posted: 14 June 2008 06:52 PM   [ Ignore ]   [ # 2 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  597
Joined  2008-02-12

yeah i have that in my main… i have a total of three class, in my main i’ve initialised TUIO.

 Signature 

My MultiTouch Blog

Profile
 
 
Posted: 15 June 2008 03:37 AM   [ Ignore ]   [ # 3 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  597
Joined  2008-02-12

Nuiman’s helping me out with my problem and fixing the errors i’ve been having. He mentioned somthing about extending it to a surface class, i thought it would be on the svn but i havent been able to find it. In any case i’ll wait for his insight and in the mean time i was wondering if someone could point me into the right direction regarding where i can find this surface class. It would really be helpful.

Taha

 Signature 

My MultiTouch Blog

Profile
 
 
Posted: 15 June 2008 03:06 PM   [ Ignore ]   [ # 4 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  597
Joined  2008-02-12

Thanks for the Help Nuiman!!

 Signature 

My MultiTouch Blog

Profile
 
 
Posted: 26 June 2008 01:04 AM   [ Ignore ]   [ # 5 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  509
Joined  2008-02-22

I believe the class is called mTouchSurface
int\app\demo\nuiSurface
could this be what nuiman is talking about?

 Signature 

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

Profile
 
 
Posted: 26 June 2008 12:04 PM   [ Ignore ]   [ # 6 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  597
Joined  2008-02-12

Nah he was referring to the multitouchable.as class located in AS3\int\app\core\action

Taha

 Signature 

My MultiTouch Blog

Profile
 
 
Posted: 26 June 2008 12:26 PM   [ Ignore ]   [ # 7 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  509
Joined  2008-02-22

Oh ok.  cool hmm

 Signature 

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

Profile