Javascript, Cookies and Flash

Hello all,

I’m having a problem with getting javascript to work with flash. I basically just want my movie to show once per day and not show on everypage since it is animation for the top navigation of the site.

IF they have seen the animation once that day then i don’t want them too see it again and I want the flash file to go to frame “end”

I tried Shared Objects and got this but it isn’t working. There is some error that I couldn’t figure out.

**ActionScript on Frame 1:

**

onLoad() {
    //This code gets todays date from the PC Clock
    mydate = new date();
    myDay = mydate.getdate();
}
onFrame(1) {
    
    //this code checks if the visitor has already
    //seen this swf today.
    so = sharedobject.getlocal("lastvisit");

    //if they have, it takes them to frame 200
    if (so.data.date==myDay) {
        gotoAndPlay("end");
}
}
onFrame("end"){
    
    //This code writes or rewrites the cookie with todays date
    so = sharedobject.getlocal("lastvisit");
    so.data.date=myDay;
    so.flush();

}

Then I tried Javascript and my NEWBIE brain is not getting it:

Java for saving cookie:

<SCRIPT LANGUAGE="JavaScript">
<!--
function setCookie(name, value)
{
  document.cookie = name+"="+value;
}
//-->
</SCRIPT>

**
java for getting cookie:
**

<SCRIPT LANGUAGE="JavaScript">
<!--
function myGetCookie(name)
{
  if (document.cookie)
  {
    var cookies=document.cookie.split(";");
    for (var i=0; i<cookies.length; i++)
    {
      var varName=(cookies*.split("=")[0]);
      var varValue=(cookies*.split("=")[1]);

      while (varName.charAt(0)==" ")
        varName=varName.substr(1,varName.length);

      // the escape() function will url encode the value				
      if (varName==name)
        return escape(varValue);
    }
  }
  return " ";
}
//-->
</SCRIPT>

HTML webpage with the flash embedded in it:

<SCRIPT LANGUAGE=JavaScript>
<!--
var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
// Handle all the the FSCommand messages in a Flash movie
function getCookie_DoFSCommand(command, args) {
  var getCookieObj = InternetExplorer ? getCookie : document.getCookie ;

  // Place your code here...
  if (command=="getCookie")
  {
        // myGetCookie function is defined above
  	var cookieValue=myGetCookie(args);
  	if (cookieValue==" ")
        {
  	  alert("Cookie not found, please set cookie first");
          cookieValue="[not found]";
        }
	getCookieObj.SetVariable("_root.cookieValue", cookieValue);
  }
}
// Hook for Internet Explorer 
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && 
  navigator.userAgent.indexOf("Windows") != -1 && 
  navigator.userAgent.indexOf("Windows 3.1") == -1) 
{
  document.write('<SCRIPT LANGUAGE=VBScript\> 
');
  document.write('on error resume next 
');
  document.write('Sub getCookie_FSCommand(ByVal command, ByVal args)
');
  document.write('  call getCookie_DoFSCommand(command, args)
');
  document.write('end sub
');
  document.write('</SCRIPT\> 
');
}
//-->
</SCRIPT>
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
 codebase="[edited]"
 ID="getCookie" WIDTH="450" HEIGHT="100" ALIGN="CENTER">
 <PARAM NAME=movie VALUE="getCookie.swf"> 
 <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#0099FF> 
  <EMBED src="getCookie.swf" quality=high bgcolor=#0099FF 
  WIDTH="450" HEIGHT="100" swLiveConnect=true 
  ID="getCookie" NAME="getCookie" ALIGN="CENTER"
  TYPE="application/x-shockwave-flash" 
  PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>
**Flash Action Script:

**

// make sure the variables are valid
  if (_root.cookieName.length>=1 && _root.cookieValue.length>=1)
_root.play()

else{

fscommand("getCookie", _root.cookieName);
    getURL("javascript:setCookie('"+_root.cookieName+"','"+_root.cookieValue+"')");
gotoAndPlay("end");
}

Any help would be great. I’m a really newbie so you have to talk to me like a 5 year old.

Thank you gentlemen for helping this girl out.

Erin