Add

Making Things + AS3 – Part 3 Servo Mouse Tracking


Be sure to go to my previous post here so you are up to speed.

For this example we will simply get the servo connected to the board and have it read the mouse position of the screen. When you move your mouse to the left, the servo will turn accordingly and vice versus.

At this point it would also me good for me to point that the way in which we are sending data to flosc might not be ideal. I noticed in the making things AS3 example and source that's to be used specifically with mchelper, they have a communication method for bundling data together. Not sure if this is workable with flosc. While I'm on the topic, I'd also suggest you check that code out. You can find their AS3 examples and library here. I plan on experimenting with the mchelper method of using AS3 and the board shortly.

package com.hydrotik.make {
 
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.utils.Timer;
	import flash.events.Event;
	import flash.events.TimerEvent;
	import flash.net.URLRequest;
	import flash.media.Sound;
	import flash.media.SoundChannel;
	import org.fwiidom.osc.*;
 
	public class MakeServo extends Sprite {
 
		private static const STR_LOCAL_IP:String = "169.254.73.165";
 
		private static const STR_REMOTE_IP:String = "192.168.0.200";
 
		private static const NUM_PORT:Number = 10000;
 
		private var oscConn:OSCConnection;
 
		public function MakeServo() {
			//Initialize connection to the FLOSC server
			oscConn = new OSCConnection(STR_LOCAL_IP, NUM_PORT);
			oscConn.addEventListener(OSCConnectionEvent.ON_CONNECT, onConnect);
			oscConn.addEventListener(OSCConnectionEvent.ON_CONNECT_ERROR, onConnectError);
			oscConn.addEventListener(OSCConnectionEvent.ON_PACKET_IN, onPacketIn);
			oscConn.addEventListener(OSCConnectionEvent.ON_PACKET_OUT, onPacketOut);
			oscConn.addEventListener(OSCConnectionEvent.ON_CLOSE, onClose);
			oscConn.connect();
		}
 
		private function onConnect(evtEvent:OSCConnectionEvent):void {
			trace("FLOSC Connection established");
			this.addEventListener(Event.ENTER_FRAME, trackServo);
		}
 
		private function onConnectError(evtEvent:OSCConnectionEvent):void {
			trace("FLOSC Connection error");
		}
 
		private function onClose(evtEvent:OSCConnectionEvent):void {
			trace("FLOSC Connection closed");
		}
 
 
		private function onPacketIn(evtOSC:OSCConnectionEvent):void {
			trace("\t>> data received: " + evtOSC.data.name + " " + evtOSC.data.data);	
		}
 
		private function onPacketOut(evtOSC:OSCConnectionEvent):void {
			trace("\t>> data sent: " + evtOSC.data.name + " " + evtOSC.data.data);	
		}
 
		private function trackServo(event:Event) {
			var pos:int = (this.mouseX/200) * 1023;
			trace(pos);
			oscConn.sendOSCPacket(
				new OSCPacket("/servo/0/position", [pos], STR_REMOTE_IP, NUM_PORT)
			);
		}
 
 
	}
 
}

Making Things Servo Source

No comments yet.

Respond

get in on the action.

* Required

bottega veneta deep coffee pocket bag deep weight loss pills bingo and game casino gambling online virtual how to win at slots versace deep coffee venus bag women does viagra work online bingo uk discount drugstore where to get viagra or cialis diazepam cheap without rx bingo and slots does cialis really work bingo gaming chanel yellow shoulder bag bingo for cash slot machine buy meds online without presciption lancel pearl premier flirt prada white shoulder bag prescriptions pain killers without a prescription viagra product information cialis generic levitra viagra cialis male enhancement online gambling offers manolo blahnik beige hangisi valium indications anya hindmarch beige hobo how does diazepam work who has the cheapest cialis price for tramadol levitra website price for generic viagra top anti depressants pharmacy zolpidem marc jacobs antique gold keylock messenger bag pill for acne casino gambling buy carisoprodol cheap create poker website zyban tablet jimmy choo purple wells shoes valtrex medication counseling for erectile dysfunction hey bingo louis vuitton patent beige sandals louis vuitton monogram idylle pink tote power bingo slot games gucci black evening bag xanax fedex oral jelly viagra new casino slots discount erectile dysfunction medication christian louboutin white ambrosina pumps poker machine games buy no phentermine prescription high stakes poker buy tory burch golden reva ballerina flats casino locations roulette casinos play online casinos bingo and slots viagra effect on women louis vuitton damier graphite keepall bandouliere marc jacobs royal blue keylock shoulder bag play roulette online casino mania online buy compazine buy gucci black trainers online casinos en internet how to win slots christian louboutin blush barcelona sandals prescription diet drugs us only mobile casino games natural clomid buy overseas viagra online casino canada online xanax fedex norvasc generic erectile dysfunction products zoloft canada uk viagra supplier casino bonus tory burch deep blue tory logo rain boots poker for money prescription drugs online adipex no prescription needed pharmacies geniune cialis no prescription ambien dosing how do muscle relaxants work valentino beige snakeskin clutch what is tadalafil ativan dosages sales viagra ysl white muse bag cialis to buy online gambling strategy cheapest phentermine pills christian dior biege medium saddle handbag alprazolam brand cheap viagra new zealand low cost adipex bally patent patent red jana tote ambien pharmacy manolo blahnik bow booties what is viagra used for dosage viagra new diet pill fda approved play slots online now cialis best price las vegas bingo cialis generic tabs versace purple venita bow satchel chloe patent purple cyndi tote fendi apricot snake peekaboo handbag discount lipitor prescription ambien ambien 10mg poker us levitra free samples do meridia phentermine work the same order celine black shoulder bag louis vuitton patent black sandals over the counter medication cheap 37 5 phentermine safe effective diet pills loewe white handbag dolce gabbana black trainers buying phentermine alprazolam generic for xanax ativan 2mg prada beige fairy l bag generic cialis canadian diet phentermine viagra online cheap europe cialis platinum play bingo levitra info prescription drugs migraines levitra alternative phentermine ingredient how does cialis work louis vuitton damier azure canvas galliera gm order amoxicillin new arthritis and psoriasis drug lipitor online pharmacy professional blackjack how does cialis ultram ingredients