Delphi/WebServers
Including Flash Movies
I use
Flash movies
to provide interactive graphs (and other interactive content) in web pages.
This provides the advantages that
- When I update the software in one place (on the server)
all the users are automatically updated the next time they use the application
- The software will "run" on any computer that supports Flash - Delphi won't
Note: |
| I use the terms Flash movie,
Flash form, and Flash application interchangeably.
Adobe prefers the term movie -
However, in my mind, a movie runs from the beginning to the end
with minimal human interaction.
By design, applications and forms are designed specifically for
human interaction.
As a result, I tend to use the term movie to refer to the file and
the other terms when discussing what the program does.
|
Automatic Update
| HTML code
| Pretend Directories
| Passing Parameters
| Drawbacks
Automatic Update
One of the advantages of writing applications in Flash is that
each time the user accesses it, the current .. updated .. copy is
executed ... well, that was the theory anyway.
In practice, the web server caches the Delphi executables ...
making debug a real pain. It is possible that the same is happening
with Flash movie files. I have not seen this yet, but it is possible.
In my graphing applications
- A Delphi application is called from the web server
- The returned web page has code to include a Flash application
- The Flash application is read from the web server
- The Flash application reads an ini-file from the web server
- The Flash application calls another Delphi application on the web server
to get the data to plot
As you can see, there are a lot of places for a server cache to cause problems.
This scenario has 2 Delphi programs, a Flash movie, and a configuration file on the server.
Using
IIS
as the web server, I have had problems with caching.
One way to get around this is to manually add some random text
to the query string.
http://computer/path/Delphi_CGI.exe/action?param1=value1&d=random_here
|
HTML code
To add a Flash movie to a web page,
some html code needs to be added to the page and
a JavaScript file - AC_RunActiveContent.js -
needs to be placed on the server.
The Flash IDE will generate the code for you (so I won't repeat it here)
via
While this code works fine in normal html files,
the Delphi Pretend Directories (next section)
will require you to modify it.
Pretend Directories
When cgi applications are written in Delphi,
it is possible to pass an action parameter by using a slash.
http://computer/path/Delphi_CGI.exe/action?param1=value1&d=random_here
|
Unfortunately, this confuses the browsers who now think that the
exe-name is actually a directory name.
As a result, all relative URI's used by the Flash application
will have the fake directory automatically prepended.
For example,
becomes
http://computer/path/Delphi_CGI.exe/Graph_ini.txt
|
when what I really wanted was
http://computer/path/Graph_ini.txt
|
In addition, this problem causes the html generated by the Flash IDE to fail.
For instance, the following code is not able to locate
AC_RunActiveContent.js (required to use Flash movies).
<script language="javascript">AC_FL_RunContent = 0;</script>
<script src="AC_RunActiveContent.js" language="javascript"></script>
|
There is also a problem with the html code that references the Flash movie itself.
Text similar to the following
'Filename', 'MyGraph',
<param name="movie" value="MyGraph.swf" />
|
needs to be changed to
'Filename', '../MyGraph',
<param name="movie" value="../MyGraph.swf" />
|
This is a super pain - I suggest NOT using action's
in any code that uses Flash movies.
(Unfortunately, I was adding graphs to an existing application.)
Passing Parameters
I have a separate page on
Passing Parameters
from the web page to the Flash movie.
Drawbacks
In every way (except being able to make a web page interactive),
Delphi is greatly superior to Adobe Flash.
For example
- Slow ... very slow
- This is very noticeable
- If the program takes more than 15 seconds to execute ... it just quits
- This is a real problem when plotting a lot of data
(like more than 1,000 points ... not much really).
There is a place to change the timeout value.
- File reads are non-blocking
- When you tell the program to read a file (or get external data by calling a program),
the ActionScript code just keeps going.
Apparently, it won't even start the read until the current subroutine terminates.
Eventually, an event will be triggered
when the data is received. This means that lots of events, and the subroutines
they call, need to be used.
- Mouse cursors
- You have to roll your own for this ... and it is a real problem keeping
the motion smooth because .. Flash is soooo slow.
I could go on ...
I have written some pages
on developing Flash applications using ActionScript 3.0
- the Flash development language.
At any rate, I have used Flash to develop web based applications that could not
have been done with Delphi alone.
Author: Robert Clemenzi -
clemenzi@cpcug.org