Basically I have code in Processing which is sending out a message using OSC from a heart rate float it receives from an xbee module. The code is as follows:
OscMessage myMessage = new OscMessage("/straps");
myMessage.add(oscHeart[0]);
oscP5.send(myMessage, myRemoteLocation);
Now I have tested receiving the messages in Processing itself using the following code:
void oscEvent(OscMessage theOscMessage) {
println("### received an osc message /test with typetag ifs.");
if(theOscMessage.checkAddrPattern("/straps")==true) {
if(theOscMessage.checkTypetag("f")) {
float firstValue = theOscMessage.get(0).floatValue();
println(" values: "+firstValue);
And it works. It receives the value and displays them in the processing terminal window. However I am trying to send that same message to a Flash file running on ActionScript 3.0 and I am having a very hard time trying to figure it out. I have looked into TUIO and FLOSC and have no idea how they work. Does anyone please have any knowledge on how I can receive my messages as above, but in ActionScript 3.0.
I've used TUIO-AS3's UDPConnector for some minimal OSC interaction with as3 for a few projects and didn't have any problems. Here a minimal snippet to illustrate what I've done:
package
{
import flash.display.Sprite;
import flash.utils.getDefinitionByName;
import org.tuio.connectors.UDPConnector;
import org.tuio.osc.*;
public class BasicOSC extends Sprite implements IOSCConnectorListener
{
private var oscSocket:UDPConnector;
private const OSCSERVER:String = "127.0.0.1";
private const PORT:int = 8082;
public function BasicOSC()
{
try{
oscSocket = new UDPConnector(OSCSERVER,PORT);
oscSocket.addListener(this);
trace(this,"OSC ready");
}catch(e:Error){ trace(e.getStackTrace()); }
}
public function acceptOSCPacket(oscPacket:OSCPacket):void{
//handle OSC here
var message:OSCMessage = oscPacket as OSCMessage;
trace("message from :",message.address,"at",new Date());
for(var i:int = 0; i < message.arguments.length; i++)
trace("\targs["+i+"]",message.arguments[i]);
}
}
}
Update: Notice that I'm casting the OSCPacket as an OSCMessage which behind the scenes deals with the parsing and easily makes the address and arguments available, which is what you're after.
For reference here's the minimal Processing sketch I've used to simulate your setup:
import oscP5.*;
import netP5.*;
OscP5 osc;
NetAddress where;
void setup() {
frameRate(25);text("click to send\nOSC",5,50);
osc = new OscP5(this,12000);
where = new NetAddress("127.0.0.1",8082);
}
void draw() {}
void mousePressed() {
OscMessage what = new OscMessage("/straps");
what.add(193.4509887695313);
osc.send(what, where);
}
HTH