Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 307
  • Last Modified:

Run Flash movie only once

Hi,
How can I make flash  page run only once.
I have a flash  page that stops at the end of the movie and I have some navigation buttons.
when I click to go on different  page and then I want to go back to the flash page the movie runs again.
I want it to run only once and not over and over again when I press the Back Key.
Thanks Maya
0
mayajhon1
Asked:
mayajhon1
1 Solution
 
radnorCommented:
Can you test a variable in the 1st key frame for a value of 1.  If it is TRUE, STOP.  On the LAST keyframe of your movis set this to a value of 1.

Not sure what it will do on a page reload.  If that does not work, how about a cookie?
0
 
mayajhon1Author Commented:
Thanks,
for some reason the variable always setup to 1 and it doesn't play even once always stops at the last frame.

on the last frame:
set (test1,1);

stop();

on the first frame:

if (test1=1) {
      gotoAndStop(100);

}

Thank you,
Maya
0
 
disentropyCommented:
The only way to do this is set a non-persisent (session) cookie that gets set to "1" or "true" when the website visitor first hits the page. Then on subsequent reloads of that page, check the cookie and if it's set to "1" or "true" (however you choose to do it), load a different flash movie that only displays the last frame.

Short version:
make 2 flash movies, 1 that is the whole thing, another with just the last frame and then load the appropriate movie based on wehter the user has been to the page before.

You can use asp, php, javascript for such functionality.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
mayajhon1Author Commented:
Thanks disentropy,
Do you have any code exampe example?
0
 
disentropyCommented:
For what language?
0
 
mayajhon1Author Commented:
If I understand correctly I will add this code the the html that has the flash movie and to the home.html page.
so any language that I can add to my html(s) pages.
I tryed something like that:
in the home.html head section
<CFCOOKIE NAME="TEST" VALUE="Y">

on the .html that the flash is in I added (I put images insted of flash for testing)

<cfif cookie.TEST EQ 'Y'>
    <img src="first.jpg" width="75" height="120">
<CFELSE>
 <img src="second.JPG">
     <CFCOOKIE NAME="TEST" VALUE="Y">
</CFIF>

for some reason this didn't work It showed both images at once so I'm not sure what I'm doing wrong.
0
 
disentropyCommented:
Looks like you are using Cold Fusion in your HTML page. If so, then this will have to have the cold fusion extension (.cfm) instead of the .html extension in order for tha page to process the Cold Fusion Code that tests for the cookie.

If you are familiar with javascript, you can take a look at the following for creating cookies with javascript:

http://www.quirksmode.org/js/cookies.html

You will need to add the logic for testing the cookie and then using document.write('<img src="first.jpg" width="75" height="120">') as then javascript for outputing your img or object tag.
0
 
mayajhon1Author Commented:
thanks, I'll study it over the weekend.
I guess I didn't know what I'm doing with this CF just tried an example without any background...
I'll let you know over the weekend and I'll raise the point value as well.
Have a nice weekend
 Maya
0
 
disentropyCommented:
Your welcome. Sounds good...
0
 
mayajhon1Author Commented:
Hi Disentropy,
I came across this code:

// this script might go in index.html
var cookies = new Object();
// immediately set a cookie to see if they are enabled
document.cookie = "cookiesenabled=yes";
 
extractCookies();                              

if (cookies["cookiesenabled"] == "yes")
 {            
   if (cookies["returninguser"] == "true")
    {
      location.href = "/content.html";
    }
   else
    {                                        
      var expiration = new Date();
      expiration.setYear(expiration.getYear() + 2);                            
      // cookie expires in 2 years
      document.cookie = "returninguser=true; expires=" +                  
                           expiration.toGMTString();
       location.href = "/introduction.html";
    }
}

I think this is what I need but I don't know how to put all of this to the .html page.
Thanks
Maya
0
 
WautersArneCommented:
Hi Maya,
You would need something like this:
This will put either myMovie.swf or myMovie2.swf in a DIV element. If the user has been on the page allready
it will put the code for myMovie2.swf. Don't forget to change the parameters for the flash movie (like width and height).
So you need to make two seperate movies.


<html>
<head>
<title>Test</title>
<script language="JavaScript">

var objectString=’’;
var cookies = new Object();
document.cookie = "cookiesenabled=yes";      
extractCookies();    

objectString=objectString + ’<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="585" height="135">’;
objectString=objectString + ’<PARAM NAME="quality" value="high">’;
                           
if (cookies["cookiesenabled"] == "yes" && !cookies["has_seen_before"])
{  
   document.cookie = "has_seen_before=true";
   
   objectString=objectString + ’<PARAM NAME="movie" value="../swf/myMovie.swf">’;
   objectString=objectString + ’<embed src="../swf/myMovie.swf" ’;
} else
{
   objectString=objectString + ’<PARAM NAME="movie" value="../swf/myMovie2.swf">’;
   objectString=objectString + ’<embed src="../swf/myMovie2.swf" ’;
}
objectString=objectString + ’quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="585" height="135"></embed>’;
objectString=objectString + ’</OBJECT>’;

document.getElementById('myDiv').innerHTML=objectString;
</script>
</head>
<body>
<div id="myDiv">One of the two flash movies will display here.</div>
</body>
</html>
0
 
mayajhon1Author Commented:
Thank You,
Maya
0

Featured Post

NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now