Jump to content

[SOLVED] php site, help getting flash banner to play only once per sesion


Xtreeme

Recommended Posts

Sorry if in wrong place. IT would fit in few categories I guess.

 

My problem is, I have a header (not a seperate frame!) that is used for each page on site. I want it to play once per visit or per hour whatever is easiest. Right now its doing the typical replay on each page link which is annoying. I could use jpeg for other pages however if you return to home it will play again still, frustraiting. I do have loop off already. I found some diff fixes none worked for me. I found playoncelogo but it is having issues (messing image up no matter size I set). SO I tried a session cookie method, which didnt work at all for me. I must be doing something simple wrong. Most instructions are really generic and lack details needed to folks like me (new to flash). I have heavily modded phpbb forums many times so I can code. Just not create it (dont laugh please haha). Can someone please guide me I really appreciate it- I have tried for 3 days and just about to give up on my animated header all together.

 

 

To recap I would like header to load once per session (visit). Per hour would work aswell if easier to do.

 

I have these two programs to work with

Dreamweaver CS3

Adobe Flash CS3

 

 

Help me stay partially saine please. Thanks in advance. :)

Link to comment
Share on other sites

you want to use sessions, if they navigate away it might replay but oh well right.

 

to the top of every page before any output (This is key)

<?php
session_start();
if($_SESSION['header'] == "yes"){
$show_header = "no";
}
else{
$_SESSION['header'] = "yes";
}
?>

 

Now when it comes to outputting the header do this in its container

<?php
if($show_header == "no"){
echo "<img src=\"header.jpg"\" alt=\"\" />";
}
else{
echo "<img src=\"flashy_header.jpg\" alt=\"\" />";
}
?>

so if you have the session set it will make $show_header = no and make it display  the low quality header, else it displays the "Flashy Header", just mod the tags above to fit your images/flash docs and it will work, but it needs to be on every page

Link to comment
Share on other sites

Im doing something wrong still I guess.

 

This is being tested on uniform server. When I try the new code I get this error

 

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in W:\www\index2.php on line 37

 

This is line 37 in dreamweaver

echo "<img src=\"logo.jpg"" alt=\"\" />";

 

Here is the top portion of the homepage, I didnt include all the code, but I will include it if needed.

 

<?php
session_start();
if($_SESSION['header'] == "yes"){
$show_header = "no";
}
else{
$_SESSION['header'] = "yes";
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- TemplateBeginEditable name="doctitle" -->
<title>Home</title>
<!-- TemplateEndEditable -->
<!-- TemplateBeginEditable name="head" --><!-- TemplateEndEditable -->
<link href="index.css" rel="stylesheet" type="text/css" />
<!--[if IE 5]>
<style type="text/css"> 
/* place css box model fixes for IE 5* in this conditional comment */
.thrColAbsHdr #sidebar1 { width: 180px; }
.thrColAbsHdr #sidebar2 { width: 190px; }
</style>
<![endif]-->
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
</head>

<body class="thrColAbsHdr">

<div id="container">
  <div id="header">
   
   <?php
if($show_header == "no"){
echo "<img src=\"logo.jpg"" alt=\"\" />";
}
else{
echo "<img src=\"logo.swf\" alt=\"\" />";
}
?>

    <div id="tabsH">
                                <ul>
                                        <!-- CSS Tabs -->
<li id="current"><a href="/index.php"><span>Home</span></a></li>
<li><a href="http://forums.pctech-support.com"><span>Forums</span></a></li>
<li><a href="/news/news_index.php"><span>News</span></a></li>
<li><a href="/software.php"><span>Software</span></a></li>
<li><a href="/links.php"><span>Links</span></a></li>
<li><a href="/About.html"><span>About</span></a></li>

                                </ul>
                        </div>
  <!-- end #header --></div>

 

Any advice? Thanks for all the help so far I really appreciate it.

Link to comment
Share on other sites

Also if you know how to code in flash you can get it to read the session and just just straight to the last frame of the flash movie...

Not a flash coder but have seen it around do a quick search on google.

 

Ya that was the flash trick I found but I got no where with it. The code had to be put in first frame of flash which I did (prob wrong though). I used windows > actions and put the code there while having first frame selected.

 

replay = SharedObject.getLocal("save");

if (replay.data.name == undefined){
gotoAndPlay(2);
replay.data.name = "played";
} else {
gotoAndStop(424);
}

 

424 is last frame (its 30fps). But the end result was no change at all. Im totally new to flash so......illustrator and dreamweaver is all I have experience with from adobe.

Link to comment
Share on other sites

once last bump before I give up!

 

definatly something wrong in that code I entered just as instructed. EVEN just that data in a .php file with no webpage info cause same error-syntax error. Either something is out of order, typo'ed, etc. Anyone that doesnt believe me enter this into notepad and save as .php (watch the results "syntax error")

 

<?php
session_start();
if($_SESSION['header'] == "yes"){
$show_header = "no";
}
else{
$_SESSION['header'] = "yes";
}
?>

<?php
if($show_header == "no"){
echo "<img src=\"header.jpg"" alt=\"\" />";
}
else{
echo "<img src=\"flashy_header.jpg\" alt=\"\" />";
}
?>

Link to comment
Share on other sites

You've got a duplicate double quote. Change this line:

echo "<img src=\"header.jpg"" alt=\"\" />";

to:

echo "<img src=\"header.jpg\" alt=\"\" />";

 

Edit: Or better yet, change the whole lot to:

 

<?php
if($show_header == "no"){
echo '<img src="header.jpg" alt="" />';
}
else{
echo '<img src="flashy_header.jpg" alt="" />';
}
?>

 

We don't need the double quotes to surround the string, since we're not echoing any variables. So lets use single quotes and make things a bit easier to read.

 

 

Link to comment
Share on other sites

O.K. that code works! yah! I have one issue Im sure is my fault.

 

First visit not showing flash file just a x in a box (file not found?)

When I refresh it DOES show the jpg now which is exactly what I want.

 

My files are all in root which is drive w: (w:/logo.swf etc. etc.)

flash file is named logo.swf

jpg is named logo.jpg       

 

Here is the code Im using for test page- is it a flash thing now or a html/php thing Im overlooking here.

 

<?php
session_start();
if($_SESSION['header'] == "yes"){
$show_header = "no";
}
else{
$_SESSION['header'] = "yes";
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

<?php
if($show_header == "no"){
echo '<img src="logo.jpg" alt="" />';
}
else{
echo '<img src="logo.swf" alt="" />';
}
?>
</head>

<body>
</body>
</html>

 

 

Link to comment
Share on other sites

that makes sense in fact was first thing that came to mind cause its not a image at all (but google just confused me lol).

 

I put the flash in just as before BUT it gave me two headers heh. The static one above and the flash one playing below it. I just removed the img source line, in dreamweaver put in the flash file as before, and then saved it to get that result. Maybe dreamweaver is putting too much code into that line (wrong code). Which appears to be the case. What is the best way to embed the flash file. It swf with actionscript in root of site aswell.

 

Here is the mess of code Dreamweaver CS3 outputs when importing the flash file. Anything look fishy to you guys?

 

<script type="text/javascript">
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','600','height','100','title','Flash Header','src','logo','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie','logo' ); //end AC code
</script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="600" height="100" title="Flash Header">
  <param name="movie" value="logo.swf" />
  <param name="quality" value="high" />
  <embed src="logo.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="600" height="100"></embed>
</object></noscript>

 

 

Thanks again guys Id be totally lost without your guidance (and this site gets a link on front page from mine LOL)

 

 

Link to comment
Share on other sites

Alright this makes it work

<?php
if($show_header == "no"){
echo '<img src="logo.jpg" alt="" />';
}
else{
echo '<embed src="logo.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="600" height="100">
</embed>';
}
?>

 

 

One last question.........how do I include parameters like this? I need the no loop param for the flash. It seems to ignore it, if I just put it in before /embed

 

This is the what Im trying to add to the embed part

<param name="LOOP" value="false" />

 

So its 99% solved. Just that one nagging issue left, the no loop parameter.

 

Sorry for being such a pain. My first .php site. Ive done phpbb but this is little diff, never used flash in php before. LOL.

Link to comment
Share on other sites

I've never used EMBED, I would only guess its either

 

echo '<embed src="logo.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="600" height="100" LOOP="false">

</embed>';

 

or

 

echo '<embed src="logo.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="600" height="100">

<param name="LOOP" value="false" />

</embed>';

 

 

Link to comment
Share on other sites

OK after messing a bit more with it I got some code to work. I tried what you said and no go. The last one I actually had already tried just on a guess. But this code here works great.

 

At begining

 

<?php
session_start();
if($_SESSION['header'] == "yes"){
$show_header = "no";
}
else{
$_SESSION['header'] = "yes";
}
?>

 

where banner goes

 

<?php
if($show_header == "no"){
echo '<img src="logo.jpg" alt="flash header" />';
}
else{
echo  
'<EMBED SRC="logo.swf" WIDTH="600" HEIGHT="100" PLAY="true" 
LOOP="false" QUALITY="high" MENU="false"
PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"> 
</EMBED> ';
}
?>

 

works great and no loop. I even got rid of that right click menu (play, rewind, loop, etc.)

Wanted to let others know in case they have similar problem (BTW works in IE6 and Opera)

Link to comment
Share on other sites

thanks I used that in the actionscript as you said and it saved me from having to deal with it in this new method.

Well, didnt want active content warning with flash header. So.....I kicked it up a notch (Emril Lagossi voice). LOL.

 

I used a .js file to put the flash code in. Saved that to site root following this guide http://www.adobe.com/devnet/activecontent/articles/devletter.html

 

Then put this code at top of page

 

<?php
session_start();
if($_SESSION['header'] == "yes"){
$show_header = "no";
}
else{
$_SESSION['header'] = "yes";
}
?>

<script src="header.js" type="text/javascript"></script>

 

 

And where I want the flash to show I used

 

<?php
if($show_header == "no"){
echo '<img src="logo.jpg" alt="flash header" />';
}
else{
echo  
'<script type="text/javascript">Runheader();</script>';
}
?>

 

 

So thanks to all who replied since theres a bit of each of your contributions in there, with a dab of adobe tutrial aswell. haha. LoL its like code soup. Dunno if its "proper" code but it does work. If you see anything wrong with it, please let me know.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.