Hi,
There are basically four ways to pass parameters to a flash client, three of
them being well adapted to servlets. (The fourth one is through sockets.)
- Putting parameter on the url of the flash application in the object (IE)
or embed (N) tag of the enclosing html code.
- loading variables in urlencoded format from the flash application through
the loadVariables action.
- loading XML data through the load or sendAndLoad methods of the XML
object.
The first is the simplest. You just add the parameters to the url like this
:
<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=550 HEIGHT=400>
<PARAM NAME=movie VALUE="MyFlashApp.swf?param1=value1¶m2=value2">
<PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#FFFFFF> <EMBED
src="MyFlashApp.swf?param1=value1¶m2=value2" quality=high
bgcolor=#FFFFFF WIDTH=550 HEIGHT=400 TYPE="application/x-shockwave-flash"
PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_
Version=ShockwaveFlash"></EMBED>
</OBJECT>
All parameters are automatically made available in the Flash application as
global variables.
Beware that you have two put the parameters twice : once for the <object>
tag (IE) and once for the <embed> tag (N).
Loading variables through the loadVariable action is also very simple :
loadVariables(url, target, method)
url is a string representing the url of the servlet you are calling. It may
include parameters in urlencoded form.
target is the name of a Flash level or a Flash clip that will be notified
when the response will be received. Notification is made through
onClipEvent(data). As a consequence, you can't load data if you don't define
at least one clip. (The application itself can't be notified).
method is either GET or POST and is to be used only if you want to send data
to the servlet. With GET, the parameters you put in the URL are sent. With
POST, all global variables are sent.
Note that with some versions of Flash, you always get the getPost method of
the servlet called, even if you ask for GET.
On the servlet side, you just send parameters as name=value pairs, separated
with &, after having set the content type to
"application-x/www-urlformencoded". Of course, the data has to be
urlencoded, but Flash is very loosy regarding the format. For example, if
you include a newline in the middle of a parameter value (without encoding
it), Flash will include it in the data.
Sending XML is a bit more complicated. So, I will stop here. Tell me if you
really are interested in sending XML data to Flahs clients.
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
Hamid Mukhtar
Envoy� : samedi 19 mai 2001 06:04
� : [EMAIL PROTECTED]
Objet : Question from Pierre-Yves
Hello
I would like to ask you:
How do we pass parameters to flash and how to recieve that inside
flash.
Thanks
Hamid
___________________________________________________________________________
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