We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpIntegration › connect processing and flash
Page Index Toggle Pages: 1
connect processing and flash (Read 3468 times)
connect processing and flash
May 13th, 2010, 10:17pm
 
How can i code something like, if i press something in flash, then processing run something. like use flash to control processing.
For flash, im using AS3

thanks for helping.
Re: connect processing and flash
Reply #1 - May 13th, 2010, 11:23pm
 
I think you have to use JavaScript in the HTML page hosting both applets to communicate between the two worlds.
Re: connect processing and flash
Reply #2 - May 13th, 2010, 11:27pm
 
but until now, i dont use any html...
Re: connect processing and flash
Reply #3 - May 13th, 2010, 11:37pm
 
if you dont want to upload it but run it in a local network, you can try to use osc to communicate. There is a osc library for processing.
There should be one for flash as well i guess.
i have seen some other people connecting, maxmsp/processing or blender/processing.

http://www.sojamo.de/libraries/oscP5/
Re: connect processing and flash
Reply #4 - May 13th, 2010, 11:43pm
 
How do you run the Flash applet without HTML page? Using a Flash projector?

Do you really need to use Flash for the usage you describe?
Re: connect processing and flash
Reply #5 - May 14th, 2010, 12:01am
 
PhiLho  wrote on May 13th, 2010, 11:43pm:
How do you run the Flash applet without HTML page Using a Flash projector

Do you really need to use Flash for the usage you describe




Im not doing a web project.
the flash just is a swf file
Re: connect processing and flash
Reply #6 - May 14th, 2010, 12:03am
 
Cedric wrote on May 13th, 2010, 11:37pm:
if you dont want to upload it but run it in a local network, you can try to use osc to communicate. There is a osc library for processing.
There should be one for flash as well i guess.
i have seen some other people connecting, maxmsp/processing or blender/processing.

http://www.sojamo.de/libraries/oscP5/


osc can you give me some example code
Thank you for you help
Re: connect processing and flash
Reply #7 - May 14th, 2010, 12:32am
 
To my knowledge, you cannot use a SWF file inside Processing.
Re: connect processing and flash
Reply #8 - May 14th, 2010, 12:34am
 
there are alot of example codes in the library archive on how to use osc and the library to communicate between different sketches.
i never tested it with flash, but seems like there are different ways to use it there too. check out this post
http://www.benchun.net/flosc/

Re: connect processing and flash
Reply #9 - May 14th, 2010, 12:36am
 
PhiLho  wrote on May 14th, 2010, 12:32am:
To my knowledge, you cannot use a SWF file inside Processing.



does he really want to do that as far as i understood. he wants to communicate between flash and processing.
Re: connect processing and flash
Reply #10 - May 14th, 2010, 12:40am
 
Alright, there is what you are probably looking for. I found a tutorial on how to connect processing with flash. its in german though,  These guys used flosc to do so. so my guess was not that bad.

http://ig.hfg-gmuend.de/how-to/kommunikation-zwischen-processing-und-flash


edit:
here is another post about the same question, they used osc as well.
http://processing.org/discourse/yabb2/num_1163423269.html
Re: connect processing and flash
Reply #11 - May 14th, 2010, 12:51am
 
PhiLho  wrote on May 14th, 2010, 12:32am:
To my knowledge, you cannot use a SWF file inside Processing.


I thought it will be something like Ardunio to Processing, not put the SWF file inside processing
Re: connect processing and flash
Reply #12 - May 14th, 2010, 1:30am
 
Open Sound Control looks can solve my problem, im trying now...
Re: connect processing and flash
Reply #13 - May 17th, 2010, 9:17pm
 
use flosc can fix my problem!!!!
but most of the examples are using AS1 or AS2, below is my AS3, hope it can help you guys:

import flash.events.*;
import flash.net.*;

/////////////////////////////////////////////////////////////////////////////
//from here is connected to flosc
var mySocket:XMLSocket;
//mySocket.allowDomain("*");

// *** create a new socket and attempts to connect to the server
function connect() {
     mySocket = new XMLSocket();
     mySocket.addEventListener(Event.CONNECT, handleConnect);
     mySocket.addEventListener(Event.CLOSE, handleClose);
     mySocket.addEventListener(DataEvent.DATA, handleIncoming);
     mySocket.connect("172.21.129.18",3000);
}

function handleConnect(e:Event):void {
     trace("XML Socket connected!");
     gotoAndStop(2);



}

function handleClose(e:Event):void {
     trace("XML Socket closed!");

}



function handleIncoming(e:DataEvent):void {
     trace("Incoming:",e.data);
     a.writeDigitalPin(6, Arduino.HIGH);
     

     var XMLData:XMLList=new XMLList(e.data);
     //XMLData.MESSAGE.(@NAME=="thomas"));

     trace_txt.text=e.data;

     //trace(XMLData.MESSAGE.(@NAME=="thomas"));
}



// *** build and send XML-encoded OSC
//
//THIS IS ANOTHER PLACE TO DO SOMETHING COOL

press_btn.addEventListener(MouseEvent.MOUSE_UP, mUp);

function mUp(e:MouseEvent):void {
     sendOSC("Thomas", "Genius", "172.21.129.18", 2000);
}

function sendOSC(name:String, arg:String, destAddr:String, destPort:int):void {
     var xmlOut:XML =
     <OSCPACKET Address="" PORT="" TIME="0">
     <MESSAGE NAME="">
     <ARGUMENT TYPE="s" VALUE="" />
     </MESSAGE>
     </OSCPACKET>;

     xmlOut.@ADDRESS=destAddr;
     xmlOut.@PORT=destPort;
     xmlOut.MESSAGE.@NAME=name;
     xmlOut.MESSAGE.ARGUMENT.@VALUE=arg;
     //trace("xmlout:",xmlOut);


     if (mySocket&&mySocket.connected) {
           mySocket.send(xmlOut.toString());

     }
}

connect();

Re: connect processing and flash
Reply #14 - May 17th, 2010, 9:54pm
 
nice to see that it worked. and thanks for posting your solution!
Page Index Toggle Pages: 1