ZakG wrote on May 30th, 2010, 1:00pm:Yes, but as I said the time it takes setup() to complete is not the issue here. My intro animation is all within draw(), and often the applet skips it.
Quote:I wondered if setup() was taking a long time, and had my millis() variable (m) add a variable called setupTime, which measures how long it takes for setup() to run. Yet this always ends up being around 70 ms, so clearly what's happening is setup() has run but the applet does not show up until well after draw() has started running.
When does it take 70ms When you test it locally or online Looking at your source you assign "m = millis();" before a bunch of loadImage() calls. It's not inconceivable that when you test locally, when presumably the images are being loaded from a local source, this happens very quickly; but that when the images are being loaded online it takes much longer...
Have you tried just assigning "setupTime = millis();" at the end of setup and seeing how it behaves online Alternatively you could use a boolean to assign millis() to setupTime at the beginning of draw when it is first run... i.e.:
Code:void draw() {
if(firstRun) {
setupTime = millis();
firstRun = false;
}
// your code here...
}
On an unrelated note. I notice you declare and assign a bunch of variables at the beginning of draw. This isn't particularly efficient as they appear to be constants based on width/height. You should declare the variables before setup, to make them global, and then assign the values from within setup:
Code:float smscale = 0.10;
float smwidth;
float smheight;
int transposX;
int transposY;
void setup() {
// fit <object> to size of browser window
int w = int(param("width"));
// int() will return 0 if param("width") doesn't exist
if (w <= 0)
w = 960;
int h = int(param("height"));
if (h <= 0)
h = 720;
size(w, h); // BTW this looks a little suspect to me - certainly goes against the advice that size() should ALWAYS be the first call in setup()...
// Anyway, now width/height are defined you can assign the values to these variables
smwidth = width*smscale;
smheight = height*smscale;
transposX = round(width);
transposY = round((height-navheight + navheight/6) / smscale);
}