import java.io.OutputStream;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class MingTest extends HttpServlet{
private static final String FONTDIR =
"/usr/local/ming/ming-fonts-1.00/fdb";
private static final String FONT =
"Bitstream Vera Serif-B.fdb";
private static final String FS =
System.getProperty("file.separator");
public void doGet(
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException{
try{
SWFMovie movie = new SWFMovie();
movie.setDimension(300, 300);
movie.setBackground(0, 0, 0);
movie.setRate(20);
SWFFont font = new SWFFont(FONTDIR + FS + FONT);
SWFText text = new SWFText();
text.setFont(font);
text.setHeight(20);
text.setColor(0, 255, 0, 0);
text.addString("Hello world");
SWFDisplayItemI item = movie.add(text);
item.move(100, 100);
movie.nextFrame();
for (int i=0; i < 255; i++){
item.setAlpha(i);
movie.nextFrame();
}
movie.add(new SWFAction("stop();"));
movie.nextFrame();
response.setContentType("application/x-shockwave-flash");
OutputStream os = response.getOutputStream();
os.write(movie.output());
os.close();
}
catch(SWFException e){
log("", e);
throw new ServletException(e);
}
}
}
|