downloading with shockwave


[ Zettels Traum ] [ search / suche ]

von dp am 27.Mai 98 um 04:20:00:

Here is one way to download a file with Shockwave (from within the
browser).

The idea is to use the 'externalEvent' command to trigger a JavaScript
function that tries to link to zip file, or other archive. Since the
archive is not a supported inline file format, the browser will
automatically (in most cases) trigger a save request so you can download
the file. (In some cases, depending on how the site/server is set up,
you'll get text gibberish instead--especially in the case of binhex
archives. This technique can't do anything about that.)

So, if your sole purpose is to downlaod a file, this will work fine, as
long as you put it in an archive. A browser can be configured to
automatically decompress files, if the necessary software is there, or
the archive can even be self-extracting (.exe or .sea) so the end user
doesn't need any software.

If, instead, you want to download the file just so it's available to the
Shockwave movie in the browser, you're better off using 'preloadNetThing'
and then setting 'the fileName of member' property to use the file.

There are two ways to do this. First, you can create a new window and
attempt to load the zip (or other archive) into the new window. You can
even use a 'setTimeout' to close the window behind you after a second or
two. However, this still requires that you see the window during the
process. You can use document.write to populate the window with a
message, but it's still far from seamless.

Instead, I prefer to use a dummy frame, of only 1 pixel, at the bottom of
my page. It's hardly even noticable because it's so small, and you never
have to worry about it because you're never putting anything into it.
Just create an empty HTML document to fill it when the page loads.

NOTE: Originally, I thought I might be able to use this same technique
using goToNetPage because the docs say you can target a frame, and you
wouldn't have to lose your original Shockwave movie and page. However,
allthough the approach is sound, not much happens upon execution. It
looks as though the save is about to happen, but then it appears to
abort. Through testing, I found that only 'externalEvent' worked
reliably.

Presumably, you can write an equivalent in VBScript to compensate for
inadequate JavaScript support. For no JavaScript support, you're just out
of luck. Sorry.

Anyway, here are the components:


Window Document: (frameset containing your Main page and a dummy frame of
1 pixel)


<HTML>

<HEAD>
<TITLE>My Page</TITLE >
</HEAD >

<FRAMESET FRAMESPACING="0" BORDER="false" FRAMEBORDER="0" ROWS="*,1">
<FRAME NAME="main" SRC="exevtest.htm" SCROLLING="auto">
<FRAME NAME="dummy" SRC="null.htm" SCROLLING ="no">
</FRAMESET >

</HTML>

HTML page containing the Shockwave file: (your main content)

<HTML>
<HEAD>
<TITLE>Main Frame Content</TITLE>

<SCRIPT LANGUAGE="JavaScript">
<!--
function myDownload(myURL) {
parent.frames[1].document.location.href = myURL
}
//-->
</SCRIPT>
</HEAD>

<BODY>
<EMBED SRC="myShock.dcr" WIDTH=320 HEIGHT=240>
<!-- any additional content -->
</BODY>

</HTML>

HTML page for dummy frame:

<HTML>
<HEAD>
<TITLE>Dummy Frame Content</TITLE>
</HEAD>

<BODY>
<!-- no content -->
</BODY>

</HTML>

Triggering action within Shockwave Movie (initiated from a button, in
this case):

on mouseUp
externalEvent ("myDownload('http://www.myCompany.com/myArchive.zip')")
end


Good luck,
Rich Shupe




Dazu:























D. Plänitz