|
Author |
Topic: checking online/authoring mode (Read 2224 times) |
|
pollux
|
checking online/authoring mode
« on: Sep 3rd, 2003, 10:15pm » |
|
toxi gave me an idea on how to check on-the-fly if an applet is online or in the processing environment: Code:// general vars boolean authoring = true; void setup() { size(200, 200); background(255); // etc... authoring = authoringMode(); } // checking method boolean authoringMode() { try { String codeBase = getCodeBase().toString(); return false; } catch (Exception e) { return true; } } |
| hope it is useful for other people as it was for me... [edit] on the code posted before, i am just including the chunks of code that are actually involved on the issue...
|
« Last Edit: Sep 3rd, 2003, 10:18pm by pollux » |
|
pollux | www.frwrd.net
|
|
|
pollux
|
Re: checking online/authoring mode
« Reply #1 on: Sep 3rd, 2003, 10:19pm » |
|
can somebody tell me why does getCodeBase() gives an error when called on runtime?
|
pollux | www.frwrd.net
|
|
|
fry
|
Re: checking online/authoring mode
« Reply #2 on: Sep 4th, 2003, 4:00am » |
|
getCodeBase gets passed up to the applet context.. if it's in authoring mode, there is none. if it's in a browser, then the browser is supposed to supply it (and therefore will return something valid for getCodeBase()). p5 actually uses this trick internally to see if it's online or not (soon to be part of the api)
|
|
|
|
|