 |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Dreamweaver (all versions) section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|

October 9th, 2004, 10:45 AM
|
Authorized User
|
|
Join Date: Nov 2003
Posts: 85
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
About loading a flash file once in a web page
I use Dreamweaver to construct my pages.
I have a normal index.asp web page which is the home page of my site.
I would like to know if there is any way- without renaming my index.asp page- to load a flash(swf) over this page, only once.
This could be done either before loading the index page, or when it finishes the loading of index page. I am satisfied with both cases, so we can choose to apply the easiest one.
It is important to say that I want the flash to be displayed only once: when the index page loads for the first time, not when it loads in general. This is essential because I just want to display a flash as an intro but I found it silly to be displayed when someone has to return through navigation to the index page.
Is there any way to suggest me doing this flash loading in Dreamweaver only once?
|

October 9th, 2004, 11:23 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Probably the easiest way to do this is to use cookies:
Code:
<%
If Request.Cookies("FlashLoaded") <> "TRUE" Then
' Use Response.Write to send the <object> tag for the movie
Response.Cookies("FlashLoaded") = "TRUE"
End If
%>
This code will see if there is a cookie called FlashLoaded with a value of True. If that's not the case, the <object> tag is written out.
Once the cookie has been set, the movie won't be loaded during the user's visit. Because the cookie has no expiry date, it gets deleted when you close the browse. Set the Expiry property of the cookie to any date in the future if you want to make it stick between browser sessions.
Cheers,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|

October 10th, 2004, 12:01 PM
|
Authorized User
|
|
Join Date: Nov 2003
Posts: 85
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
In order to test it, in addition to the code you wrote above, can you please give me the code of telling the page the filename of the flash file to load, only once?
|

October 10th, 2004, 12:36 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
What do you mean with " telling the page the filename of the flash file to load"?
AFAICS, all you need is the original code for the Flash Animation, just as you would normally add it in a page. Either use Response.Write to write out that block of HTML code, or simply copy the HTML inside the If statement.
Or am I missing something here?
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|

October 11th, 2004, 12:41 AM
|
Authorized User
|
|
Join Date: Nov 2003
Posts: 85
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="115" height="70">
<param name="movie" value="flash.swf">
<param name="quality" value="high">
<embed src="flash.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="115" height="70"></embed>
</object>
Here is the code of flash object.
How does it fits in the above code either with response write or html code?
What is the whole code combined?
|

October 11th, 2004, 01:16 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
If you use direct HTML, it can be as easy as this:
<%
If Request.Cookies("FlashLoaded") <> "TRUE" Then
%>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="115" height="70">
<param name="movie" value="flash.swf">
<param name="quality" value="high">
<embed src="flash.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="115" height="70"></embed>
</object>
<%
End If
%>
I simply closed the ASP block before the HTML object tag, and reopened it again after the closing object tag.
Alternatively, you can do something like this:
<%
If Request.Cookies("FlashLoaded") <> "TRUE" Then
Response.Write("<object classid=""clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"")
Response.Write(rest of the html goes here)
End If
%>
This may be a tiny bit faster as there is no need to switch between ASP and HTML processing, but I wonder wether you'll even notice it.
The second method also allows you a bit more control over the actual object tag.
You could, for instance, make the Flash movie twice as big on Mondays and Wednesdays, if that's what you want..... ;)
Cheers,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|

October 11th, 2004, 01:51 AM
|
Authorized User
|
|
Join Date: Nov 2003
Posts: 85
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
So, i tested the first part of the code you wrote(direct html).
Two problems:
- Most important: the flash is always displayed! Not only once!. I navigate through the site, then I return to the page and the flash is there again.
- Second problem: positioning. Now it is displayed in the top of the page(awful). Can I set it to display over the page, something like a layer? If this is not possible, can we set it to be displayed before the appeating of any other element in the page? First display the flash, after the finish of flash(and dissapearing) display the whole page?
|

October 11th, 2004, 01:30 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Did you include the line that sets the cookie with the Response.Cookies statement I showed you in an earlier post? You need that, otherwise the cookie won't be set, and the code will always display the Flash animation.
And where did you place the If statement? Since you're directly outputting the code for the Flash animation (either with Response.Write or with HTML), the Flash animation appears at the location of the code.
So, simply move the code to the location where you want the banner, and everything should be fine.
Cheers,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|
|
 |