The final hurdle

Avatar

A New Media developers online playground - Alex Wilcox

Flash to Max communication

Post Categories: Major Projecti-DAT

For my project i have had to write an class that will handle all the communication with max/msp, in max the connection is handled by the flashserver external by Olaf Matthes which is available from:

http://www.nullmedium.de/dev/flashserver/

The connection works over an xml socket and the class i have written (basically a conversion of the as2 example to as3) handles the connection and dispatches events depending on the status of the connection. so that’s when its opened,closed or data is received ect..

you can send messages to max as strings or specify a receive object in max to receive the object (if flashserver has remote mode turned on).

i’ve also implemented a function to send file paths to max (as my app will be loading sounds into max but using flash for the gui).
this takes a string and formats it so that the file path remains intact as blackslashes are used as escape characters in both programs so i had to use a regular expression to ensure that the slashes in the path remained the same by the time the path got to max/msp.

i.e.

e:\dir\folder\blah.mp3
you need to send this (in quotes in case there are spaces in the string as max doesn’t like that either!
“e\:\\\\\\dir\\\\\\folder\\\\\\my sound file.mp3″

so a little regex can do this for us,

maxlocation.replace(/\\/g, “\\\\\\”);

I will be releasing this class once I’ve tidied it up a bit and made it suitable for others to use.

also i would like to thank fellow student Alex Riley(http://www.alexryley.net/) for his input into this class as it was built on top of something he created for a similar purpose.

Tags :

,