Link to home
Start Free TrialLog in
Avatar of mayajhon1
mayajhon1

asked on

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
Avatar of radnor
radnor
Flag of United States of America image

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?
Avatar of mayajhon1
mayajhon1

ASKER

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
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.
Thanks disentropy,
Do you have any code exampe example?
For what language?
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.
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.
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
Your welcome. Sounds good...
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
ASKER CERTIFIED SOLUTION
Avatar of WautersArne
WautersArne

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank You,
Maya