Hi,
You can send data from a servlet to a Flash movie using 4 methods :
1) Passing data as parmaters in the html form containing the link to the
flash movie. Data has to be in url-encoded format (although Flash is very
loosy on this format and will accept any character, even returns and
linefeeds. You can take advantage of this, but it can also leads to
problems.) Here is an example of parameters send to a Falsh movie
representing an invoice. Data is extracted from a database by the servlet :
<HTML><HEAD><TITLE>Facture</TITLE></HEAD><BODY bgcolor='#FFFFFF'><OBJECT
classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'
codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.ca
b#version=5,0,0,0' WIDTH='558' HEIGHT='805'> <PARAM NAME='movie'
VALUE='../images/Facture.swf?numéroFacture=980-10-901255&adresse=Mr Martin
3 place Vendome
75000 PARIS&date=2001-04-25&commande=Fax&numéroCommande=988209413235 ... '>
<PARAM NAME=quality VALUE=high>
<PARAM NAME=bgcolor VALUE=#FFFFFF>
<EMBED src='Facture.swf?numéroFacture=980-10-901255&adresse=Mr Martin
3 place Vendome
75000 PARIS&date=2001-04-25&commande=Fax&numéroCommande=988209413235 ... '
quality=high bgcolor=#FFFFFF WIDTH=558 HEIGHT=805
TYPE='application/x-shockwave-flash'
PLUGINSPAGE='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_
Version=ShockwaveFlash'></EMBED></OBJECT></BODY></HTML>
Do not forget that you have to put the parameters twice (once for IE an once
for Netscape).
The only problem with this approach is that the data is visible in the
source of the page. The data type is simply text/html.
2) You can use loadVariables in ActionScript to load data from a URL in the
domain the movie came from. This URL might be a servlet. It might send data
in url encoded form. This servlet (the one that sends the data) must use
content type "application-x/www-urlformencoded".
3) You can use XML.load or XML.sendAndLoad in ActionScript to load XML data
from a URL in the domain where the movie originated. It might also be a
servlet and content-type must be text/plain. Beware that ActionScript is not
XML compliant so there are many problems with this approach. (I already
described some in a former thread - in short, leading and trailing spaces
are considered separate text elements.)
For method 2 and 3, beware of a bug : wether you call for post or get, you
will get post (ie, the doPost method will be called !)
4) You can use XMLSocket to communicate with whatever you want wherever you
want.
If you need more information, you can find several examples of each solution
in the book "Flash et ActionScript" (OEM publisher) at the following link :
http://www.eyrolles.com/php.informatique/Ouvrages/ouvrage.php3?ouv_ean13=978
2746402713&xd=39699aa23dffa5698bd3bc7d10258198
but beware : it's written in french !
Pierre-Yves
-----Message d'origine-----
De : A mailing list for discussion about Sun Microsystem's Java Servlet
API Technology. [mailto:[EMAIL PROTECTED]]De la part de
Frauke Nonnenmacher
Envoyé : jeudi 26 avril 2001 11:58
À : [EMAIL PROTECTED]
Objet : Servlet communication with embedded applications (FLASH etc)
Hi!
Is it possible for a servlet to communicate with applications embedded in an
HTML page? For example, I need a FLASH movie to send some data to a servlet,
e.g. a student name (that's the easy bit, I got that ;). Thing is, the FLASH
movie also needs some information back from the servlet, e.g. if the student
is registered for a certain course.
I know how to get the information I need to send back, but how do I actually
pass it back to the FLASH movie? Is there a special value I can use for the
content type of the HttpServletResponse object to get the HTML page to pass
the information in the response on to the embedded movie? Or can I use the
response to only modify the HTML page so that maybe the FLASH movie can use
javascript to read some variable I set?
So far I've only used HttpServletResponse objects to write entirely new HTML
pages, but that's no good in this situation.
Cheers,
Frauke
Frauke Nonnenmacher
Fat Cat Cartoons
www.fatcatoons.com <http://www.fatcatoons.com>
___________________________________________________
The statements and opinions expressed here are my own
and do not necessarily represent those of the VEGA Group.
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html