The following bit of javascript writes and retrieves a cookie which counts a users visits to the page. Then using swfobject it both embeds main_banner.swf and passes the cookie value "visits" to it via flashvars. The trouble is in the actionscript below; the vallue has been passed (this is certain, because the .swf shows up rather than the alternative content)- but the .swf is stuck on the first frame rather than processing the cookie and sending the user to the appropriate frame label. If anyone has any suggestion on how to write the receiving code, I would definitely appreciate it.



Thanks, Ryan





<!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" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>

<script>

function createCookie(name,value,days) {
var expires = "";
if(days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
expires = "; expires="+date.toGMTString();
}
document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0) === ' '){
c = c.substring(1,c.length);
}
if (c.indexOf(nameEQ) === 0){
return c.substring(nameEQ.length,c.length);
}
}
return null;
}

var counter = readCookie("counter");
var prior_visits = (counter !== null) ? parseInt(counter, 10) : 0;
var current_visit = prior_visits +1;

createCookie("counter", current_visit, 365);

//if(prior_visits === 0){
// alert("This is your first visit");
//} else {
// alert("This is visit #" + current_visit);
//}

var flashvars = {
visits: current_visit
};

swfobject.embedSWF("main_banner.swf", "myContent", "189", "151", "9.0.0", false, flashvars);

</script>


</head>
<body>

<div id="myContent">
<h1>Alternative content</h1>
<p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>
</div>
</body>
</html>



ACTIONSCRIPT STARTS HERE - This is on the first frame of a 5-frame FLA file. The following 4 frames are labeled (see below) and have a singular function of loading an external .swf

EX. -- loadMovie("white_papers_banner.swf", "myContainer_mc");
-- this._lockroot = true;

-- stop();



var visits: String ="0,1,2,3";



if (visits == 0) {
this.gotoAndPlay("investment_focus");
}

if (visits == 1) {
this.gotoAndPlay("white_papers");
}

if (visits == 2) {
this.gotoAndPlay("portfolio_strategy");
}

if (visits == 3) {
this.gotoAndPlay("third_thursday");
}

stop();