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 › processing in processing
Page Index Toggle Pages: 1
processing in processing (Read 1217 times)
processing in processing
Mar 25th, 2006, 6:53am
 
dear all,

i begin to enjoy processing Smiley

how possible for processing to actually call another processing file into current file.

i tends to use flash as the reference of development.

in flash we can call external .swf file into 1 main .swf file.

so that the main .swf file is not as heavy as it is. so i m just wondering if this is possible in processing.

i see some of the expert out there actually have some "loading...xx%" in their processing file. can some body show me how to do that too?? thanks in advance. processing rock!


sooon
Re: processing in processing
Reply #1 - Mar 25th, 2006, 1:21pm
 
You can load images etc after the sketch has started, but not another sketch itself.

Technically however you can, but it's probably really complex and won't do quite what you'd expect.
Re: processing in processing
Reply #2 - Mar 28th, 2006, 2:06am
 
If you know OOP well, you can write all your programs in such a way so as to code processing as if you were doing flash, having multiple "movie files" in this case, processing code, and be able to execute them at will. It's a bit tricky, but here's how it's done.


Create a master template class from which all other "programs" will inherit. In this case, let's name it "client":

Code:

class Client(){
Client(){}
void draw(){}
void mousePressed(){}
//callbacks etc
}


Next, create an array space for these clients

Code:

Vector clients;


You can add clients via Vector method add()

Code:

clients.add(MyClient());



And in your draw(), cycle through your clients:

Code:

for(int i=0;i<clients.size();i++){
Client currentClient = (Client)clients.get(i));
currentClient.draw();
}



You can also use the same technique to implement callbacks, such as:

Code:

void mousePressed(){
for(int i=0;i<clients.size();i++){
Client currentClient = (Client) currentClient.get(i);
currentClient.mousePressed();
}
}



Now that you have this framework set-up, you can write any type of processing code within this framework, and you can run everything simultaneously, selectively, however you wish. For example:

Code:

class Flux extends Client{
Flux(){
}
void draw(){
ellipse(50,50,100,100);
}
}


Now I just made a class that is share-able between all others. In fact, I can copy and paste entire processing sketches to fit within this framework, then run them concurrently.

Enjoy!!
Re: processing in processing
Reply #3 - May 1st, 2006, 8:03pm
 
Excellent framework !
...not so far from a "loadmovie"  ^^
Pretty handy, thank you so much !
Page Index Toggle Pages: 1