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.
Page Index Toggle Pages: 1
Matt cartoon (Read 596 times)
Matt cartoon
Apr 15th, 2007, 6:58pm
 
I am stumped, this works fine when I run it from the Processing application, it works fine when I run it as an exported application. Yet in neither firefox or IE will it run as an applet.

http://iain.hillock.googlepages.com/index.html

Quote:


PImage a;
int y = year();
int m = month();
int d = day();
String ds;
String ms;

void setup(){
 size (200,300);
}
void draw(){
 ms = str(m);
 ds = str(d);
 datecheck();
 loadimage();
 image (a,0,0);
}

void datecheck(){
 if (d<10){
   ds = ("0" + str(d));
 }
 if (m<10){
   ms = ("0" + str(m));
 }
}

void loadimage(){
 a = loadImage("http://www.telegraph.co.uk/news/graphics/"+y+"/"+ms+"/"+ds+"/matt.gif");
}


Re: Matt cartoon
Reply #1 - Apr 15th, 2007, 7:50pm
 
It's cross-site security that's tripping you up - running from google, loading from telegraph.  To make it work, you'd need to either have both applet and images in the same domain, or use some sort of server-side script (asp, php, etc) to fetch the offsite image for you and feed it back to your applet so that it *looks* like it came from the same domain.  Something like:

loadImage("http://mydomain.com/fetch.asp?http://offsite.com/image.jpg");
Re: Matt cartoon
Reply #2 - Apr 15th, 2007, 8:04pm
 
Thanks for the reply I'll have a look into it
Any help on the redirecting would be much appreciated
Re: Matt cartoon
Reply #3 - Apr 15th, 2007, 8:48pm
 
http://www.phpfreaks.com/quickcode/URL-Redirect-Script/584.php

This seems to be what I am looking for but I am incapable of getting it to work
Re: Matt cartoon
Reply #4 - Apr 15th, 2007, 10:32pm
 
no. sending a header(location: .. ) will tell java to redirect it's call to the other location and this will fail again. what you need to do is "tunnel" the image thru php:

php
Code:

<?php
echo @readfile( $_GET['url'] );
?>


processing
Code:

PImage img;

void setup ()
{
   img = loadImage("readfile.php?url=http://processing.org/img/processing_beta_cover.gif");
}

void draw()
{
   image( img, 0,0 );  
}


F
Page Index Toggle Pages: 1