• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 308
  • Last Modified:

Run Flash movie only once

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
1 Solution
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?
mayajhon1Author Commented:
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);


on the first frame:

if (test1=1) {


Thank you,
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.
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

mayajhon1Author Commented:
Thanks disentropy,
Do you have any code exampe example?
For what language?
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

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">
 <img src="second.JPG">

for some reason this didn't work It showed both images at once so I'm not sure what I'm doing wrong.
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:


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.
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
Your welcome. Sounds good...
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";

if (cookies["cookiesenabled"] == "yes")
   if (cookies["returninguser"] == "true")
      location.href = "/content.html";
      var expiration = new Date();
      expiration.setYear(expiration.getYear() + 2);                            
      // cookie expires in 2 years
      document.cookie = "returninguser=true; expires=" +                  
       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.
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.

<script language="JavaScript">

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

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>’;

<div id="myDiv">One of the two flash movies will display here.</div>
mayajhon1Author Commented:
Thank You,
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

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