actionscript 3 - Leapmotionas3 interaction finger as a mouse -


i'm testing leapmotionas3 library logotype:

https://github.com/logotype/leapmotionas3

i can make gestures work, have 2 apps working gestures, can't finger act "mouse" , interact buttons on screen.

does know how this? advice, tip, tutorials?

to connect device use:

package  {  import flash.display.sprite; import com.leapmotion.leap.controller; import com.leapmotion.leap.events.leapevent; import com.leapmotion.leap.frame; import com.leapmotion.leap.hand; import com.leapmotion.leap.finger; import com.leapmotion.leap.vector3; import com.leapmotion.leap.util.leaputil; import com.leapmotion.leap.gesture; import com.leapmotion.leap.swipegesture; import com.leapmotion.leap.screentapgesture; import com.leapmotion.leap.keytapgesture; import com.leapmotion.leap.screen; import flash.events.event; import com.greensock.tweenlite; import com.greensock.easing.expo; import com.greensock.plugins.*; import com.greensock.easing.back; import flash.display.shape; import flash.text.textfield; import flash.display.stagedisplaystate; import flash.events.timerevent; import flash.utils.timer;  tweenplugin.activate([tintplugin]);    public class controlador extends sprite {     private var leap:controller;     private var cursor:sprite;     private var screenwidth:uint;     private var screenheight:uint;     private var currentvector:vector3;     private var screen:screen;     private var screenlist:vector.<screen>;     private var texto:textfield;     private var texto2:textfield;     private var boton:sprite;      public function controlador() {          stage.displaystate = stagedisplaystate.full_screen;          cursor = new sprite();         cursor.graphics.beginfill( 0xff0000 );         cursor.graphics.drawcircle( -5, -5, 20 );         cursor.graphics.endfill();         this.addchild( cursor );          texto = new textfield();         texto.text = "codigo";           texto.width = 250;           texto.x = 25;           texto.y = 25;           addchild(texto);           texto2 = new textfield();         texto2.text = "codigo";           texto2.width = 250;           texto2.x = 25;           texto2.y = 125;           addchild(texto2);          boton = new sprite();         boton.graphics.beginfill(0xff6600);         boton.graphics.drawcircle(150,150,50);         boton.graphics.endfill();         addchild(boton);         setchildindex(boton,0);          // constructor code         leap = new controller();         leap.addeventlistener(leapevent.leapmotion_connected, alconectar);         leap.addeventlistener(leapevent.leapmotion_frame, enframe);         leap.addeventlistener(leapevent.leapmotion_init, initleap);         }     private function alconectar(event:leapevent):void{         trace("conectado");          screenlist = leap.locatedscreens();         screen = screenlist[ 0 ];         screenwidth = screen.widthpixels();         screenheight = screen.heightpixels();           leap.enablegesture(gesture.type_screen_tap);      }     private function initleap(event:leapevent):void{             trace("init");      }     private function enframe(event:leapevent):void{          texto2.text = "x stage: " + string(mousex)+ "y stage: " + string(mousey);         var frame:frame = event.frame;             if ( frame.hands.length > 0 )         {             var hand:hand = frame.hands[ 0 ];              var fingers:vector.<finger> = hand.fingers;             if ( !fingers.length == 0 )             {              }             var normal:vector3 = hand.palmnormal;             var direction:vector3 = hand.direction;           }         var gestures:vector.<gesture> = frame.gestures();         ( var i:int = 0; < gestures.length; i++ )         {             var gesture:gesture = gestures[ ];              switch ( gesture.type )             {                   case gesture.type_screen_tap:                     var screentap:screentapgesture = screentapgesture ( gesture);                         texto.text = "keytapgesture: x" + math.round(screentap.position.x ) + ", y"+ math.round( screentap.position.y);                     break;                  default:                      trace( "unknown gesture type." );                      break;             }         }         if ( event.frame.pointables.length > 0)         {              currentvector = screen.intersectpointable( event.frame.pointables[ 0 ], true );             cursor.x = screenwidth * currentvector.x - stage.nativewindow.x;             cursor.y = screenheight * ( 1 - currentvector.y ) - stage.nativewindow.y;              if (cursor.hittestobject(boton))         {             var timer:timer = new timer(200, 0);                 timer.addeventlistener(timerevent.timer, timerhandler);                 timer.start();               texto2.text = "colision detectada";          }         else         {             var timer2:timer = new timer(500, 0);                 timer2.addeventlistener(timerevent.timer, timerhandler);                 timer2.start();         texto2.text = "sin colision";             tweenlite.to(boton, 3, {scalex:1, scaley:1, alpha:1, tint:0xff0000, ease:back.easeinout})             }          }      }     private function timerhandler(event:timerevent):void{         //tweenlite.to(boton, 3, {scalex:10, scaley:10, alpha:1, tint:0x33ff00, ease:back.easeinout})         trace("click");     } }     } 

the cursor follows pointable mouse. implemented hittestobject, issue it's called several times. there way once, mouse click example?


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -