Flasher Archive

[Previous] [Next] - [Index] [Thread Index] - [Previous in Thread] [Next in Thread]


Subject: Re: FLASH: passing variables from asp to flash
From: Matt Wobensmith
Date: Thu, 15 Jun 2000 00:07:35 +0100

Hi Manish -

You wrote:

>i need to pass some variables from an asp file to a flash movie.

Well, this is more involved than I can give complete information on... but
here's the general idea.

When Flash executes Load Variables (or GetURL) and Send using GET or POST,
to the ASP file, those values can be grabbed, evaluated, inserted in a
database, used to extract info from a database, etc. Additionally, any
combination of this information from the server can now be sent back to
Flash using the ASP "Response" object, and the "Write" method. Or, written
into a new page's HTML to be passed to the movie that way.

Here are two simplified examples:

1. Use the Response.Write to send data to the movie

<%
'gets the vars from Flash
myVar = Request.Form ("flashVar")

'makes new var in ASP
newVar = "the value is " & myVar

'sends the new data back to Flash
Response.Write ("flashVar=" & newVar)
%>

To pass more than one name/value, it could look like this:


<%
myVar = Request.Form ("flashVar")
myDate = Date()
myDay = WeekDayName(WeekDay(newdate), False, vbSunday)
flashResponse = "flashDate=" & myDate & "&flashDay=" & myDay)
Response.Write (flashResponse)
%>

Your particular code may vary - this is one way to do the Response.Write
cleanly.

If your ASP script is used to tell the Flash movie which movie to load
via Load Movie action, then there are a few factors here. One, a variable
needs to be defined in the Flash movie that is the name of the file to load.
As in:

Response.Write ("movieToLoad=" & theMovieFileName)

Two, in the Flash movie, the Load Movie statement would be set to
Expression and look something like this:

Load Movie (movieToLoad, "1")

The location is up to you, of course.


2. Pass the data in the HTML.

A different way for the ASP file to pass variable info to the movie is
to write the values to be passed into the HTML page that embeds the movie.
Here's a simple example:

<%
'here is some fake data, just for example
ourData = (the data returned from a database query)
movieName = ourData
%>
<HTML>
<HEAD>
<TITLE>my movie</TITLE>
<BODY bgcolor="#666633" marginwidth="0" marginheight="0" leftmargin="0"
topmargin="0" rightmargin="0">

<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"

codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0
,0"
ID=hello WIDTH=100% HEIGHT=100%>
<PARAM NAME=movie VALUE="hello.swf?movieToLoad=<%=movieName%>"> <PARAM
NAME=quality
VALUE=high> <PARAM NAME=bgcolor VALUE=#666633>
<EMBED src="hello.swf?movieToLoad=<%=movieName%>" quality=high
bgcolor=#666633
WIDTH=100% HEIGHT=100% TYPE="application/x-shockwave-flash"

PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_
Version=ShockwaveFlash"></EMBED>
</OBJECT>
</BODY>
</HTML>

Notice how, in the OBJECT and EMBED tags, there's an ASP placeholder
after the name of the SWF file:

movieToLoad=<%=movieName%>

In these cases, the substitution is done on the server, and when the
finished HTML page is written, the values are written into the HTML and
passed to the movie in the "query string".


I hope that this isn't too confusing... I hesitate to jump fully into this
just due to the complexity and overall massiveness of this; you can achieve
what you are doing in a dozen ways. I don't want you to be limited by my
(simplified) suggestions. However, this is the general way it can be done,
and I encourage you to try it, post to the group if you have any questions
about it.

Matt


ps - also, two great TechNotes:

Flash and databases
http://www.macromedia.com/support/flash/ts/documents/flash_database.htm

Different approaches to setting variables in a Flash movie
http://www.macromedia.com/support/flash/ts/documents/set_variables.htm


---------------
Matt Wobensmith
Macromedia Tech Support
Flash Team Lead

flasher is generously supported by...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
flashforward2000 and the Flash(tm) Film Festival
July 24-26, 2000, NEW YORK CITY, Hammerstein Ballroom
www.flashforward2000.com
Produced by United Digital Artists and lynda.com
Sponsored by Macromedia, Adobe Systems, Fusion, Inc, AtomFilms,
shockwave.com and Electric Rain.
1.877.4.FLASH.4 or (1.805.640.6679 outside the US and Canada)
Register before June 30 and save $200!!-- www.flashforward2000.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe or change your list settings go to
http://www.chinwag.com/flasher or email helpatchinwag [dot] com


[Previous] [Next] - [Index] [Thread Index] - [Next in Thread] [Previous in Thread]