|
 |
flash_programming thread: RE: Creating Dynamic Links?
Message #1 by dwhillier@c... on Fri, 12 Oct 2001 22:37:44
|
|
Peter,
Clifford wrote that you could connect to an asp page from your flash page,
which in turn could link you to another flash page with the dynamic data.
This is true, however it is also possible to call an asp page in the
background and have it send dynamic content without reloading the flash
page or going to another Flash Page(Flash 5 only).
To do this you use the loadVariables command in flash and the
Response.write command in asp. Eg.
To request the asp page from flash:
loadVariables ("DynamicLink.asp", "_root", "POST");
- "DynamicLink.asp" = the name of the asp file
- "_root" = the path in flash to load the variables
- "POST" = (or GET) the method to pass variables to the asp file (useful
for passing info to the asp file in order to get specific info back
To recieve info back from the asp page:
Flash can only get info back from asp in one format, using the
Response.write asp command you have to send info as a string like this:
VariableName01=Info01a+Info01b&VariableName02=Info02a+Info02b+Info02c ...
- this is one string passed with the Response.write command
- VariableName##: the name of the variable in flash that the
information will be stored in
- Info##@: the information that will be stored in the flash variable
- +: spaces between pieces of information to be stored in one variable
need to be represented by a plus sign ie. "Hello There" would be
"VariableName01=Hello+There"
- &: While only one string can be passed to flash, more that one
variable can be contained within this string. This is accomplished
with the "&" symbol
In order to get this string you will need to create it with your asp
script before Response.write'ing it.
One problem with doing it this way is that the flash player will not wait
to recieve all the data before continuing play. To get around this I set a
variable equal to "0" at the beginning of the flash movie,
say "DataLoaded=0". Then I set a 'gotoAndPlay' loop after the frame
containing the loadVariables command (ie. loadVariables(...) on frame 1
and gotoAndPlay (2) on frame 3). On frame "2" use an if statement:
if (DataLoaded > 0) {
gotoAndPlay (4)
}
At the end of the asp variable string use the same variable name
(DataLoaded) but make it equal to "1".
To summarize what happens by doing this - The flash movie plays frame 1
which requests the asp file and the asp file begins to send info back. The
flash movies plays frame 2 without waiting for the end of the asp info,
frame 2 determines if the last variable has loaded by finding the value of
the variable "DataLoaded". Likely the asp information won't be fully
loaded yet so the DataLoaded variable is still equal to 0. Because the
variable is equal to 0, the flash player will play frame 3. Frame 3 will
then send the player back to frame 2 to repeat the process. Once the ASP
data is fully loaded, the variable DataLoaded will be equal to 1 and
therefore the if statement will be true sending the flash player to frame
4 ending the loop.
Long I know, but I don't like getting answers that only answer questions
in an abstract manner. Enjoy.
Dean.
> Peter,
>
> Yes it could be possible if you get your flash page to link to an ASP
page
> to generate the dynamic list of links then the ASP page can forward you
to
> another flash page passing the data as veriables that can then be read in
> the action script of the new page.
> It sounds complex but in practice it's quite simple, I have done this on
an
> intranet site and it works very well, however I have been told that you
can
> also do the same sort of thing with the need of ASP by using Macromedia's
> Generator package, this allows the flash page to get information from
many
> types of databases. I thought of looking into it myself.
>
> Hope I have been of assistance and please feel frr to contact me direct.
>
> Clifford Agius
> Clifford.Agius@b...
>
> -----Original Message-----
> From: bounce-flash_programming-57246@p...
> [mailto:bounce-flash_programming-57246@p...]On Behalf Of peter
> harper
> Sent: 03 February 2001 12:44
> To: Flash Programming
> Subject: [flash_programming] Creating Dynamic Links?
>
>
> Is Flash 5 capable of creating a list of dynamic links, generated from a
> database? Any input on ideas as to how this could be done would be really
> appreciated...Ive never seen it but if there is a way to do it, could
open
> many cool possibilites of integrating flash/Asp/SQL.
>
> thanks in advance,
>
> peter
|
|
 |