i meant you're testing for a number:

visit == 1

but passing a string via flashvars.

trace(_root.visit === "1");
trace(_root.visit === 1);

if you want to look for a number in your conditional statements, you should
convert the string to a proper number.

your swfobject code looks ok.  i see your getcookie function is a bit
complex and could possibly return a null. a null flashvars value could cause
an error in swfobject. try changing the flashvars to this and see if it
works:

var flashvars= {
   visits: getCookie('counter') || 1
};

this way if getcookie has problems you'll pass a 1 instead.

- philip


On Wed, Dec 30, 2009 at 9:30 AM, ryan <[email protected]> wrote:

> Hi Philip,
> Thanks again, but I am still getting the same result. Im not sure what
> the problem is, but this is the embed tag as I have it now. I took
> your advice and ammended visits to capvisits- but I need to make it to
> a point where the swf is showing up in order to test that. In your
> reply you mentioned casting the numbers in the string, do you mean
> declaring var visits:String = "1,2,3,4"? and if so, would I place that
> in the Flash file or the javascript?
>
> Thanks for all your help on this,
> Ryan
>
> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/
> libs/swfobject/2.2/swfobject.js"></script>
> <script type="text/javascript">
> var flashvars= { visits: getCookie('counter') };
> swfobject.embedSWF("main_banner.swf", "myContent", "189", "151",
> "9.0.0", false, flashvars);
> </script>
> </head>
>
> On Dec 30, 11:53 am, Philip Hutchison <[email protected]> wrote:
> > Your SWFObject statement is malformed. Sorry I didn't notice that
> earlier.
> >
> > This:
> > swfobject.embedSWF("main_banner.swf", "myContent", "189", "151","9.0.0",
> > flashvars);
> >
> > Should be this:
> > swfobject.embedSWF("main_banner.swf", "myContent", "189", "151","9.0.0",
> > false, flashvars);
> >
> > (You're missing the required Express Install argument before the
> flashvars
> > argument)
> >
> > Here are some other thoughts:
> >
> > *  You might want to look at how the data is being passed to the SWF...
> > values passed via flashvars are all strings. Your SWF's conditional
> > statements are looking for numbers. Maybe you need to cast them.
> >
> > * Your "visits" variable is listed as _root.visit in one place but simply
> as
> > "visit" in another.  Perhaps there's a scope issue because of this?
> >
> > * Are your "visits" conditional statements supposed to be using
> "capvisits"?
> >
> > Here's what I assume you're trying to do:
> >
> > var capvisits:Number  = Number(_root.visits) || 1;
> >
> > if (capvisits == 1) {
> > this.gotoAndPlay("investment_focus");
> >
> > }
> >
> > if (capvisits == 2) {
> > this.gotoAndPlay("white_papers");
> >
> > }
> >
> > - philip
> >
> >
> >
> > On Wed, Dec 30, 2009 at 8:39 AM, ryan <[email protected]>
> wrote:
> > > Hi Philip,
> > > Thanks for your reply. I made the code change you suggested and
> > > unfortunately I am getting the same result (the alternative content
> > > displays). I feel like this is really close though. If anyone has a
> > > little extra insight I would love it and thanks again Philip.
> > > Ryan
> >
> > > On Dec 30, 11:28 am, Philip Hutchison <[email protected]> wrote:
> > > > this:
> > > > var flashvars = {"visits=' + getCookie('counter')+'"};
> >
> > > > should be this:
> > > > var flashvars = { visits: getCookie('counter') };
> >
> > > > - philip
> >
> > > > On Wed, Dec 30, 2009 at 7:51 AM, ryan <[email protected]>
> > > wrote:
> > > > > Thanks in advance for looking at this. I am trying to set/ retrieve
> a
> > > > > cookie which counts a users visits to a page and then returns the
> > > > > value using flashvars and swfobject2. The cookie and the swf work
> > > > > independantly, the swfobject embed works fine until i try to ad the
> > > > > vars... The examples I dowloaded all use a conditional statement to
> > > > > apphend the vars in the html file itself. I have code within the
> root
> > > > > of my swf telling the file what to do with the cookie. IE;
> >
> > > > > var capvisits:String  = _root.visits;
> > > > > if (capvisits == null) {
> > > > >    capvisits = 1;
> > > > > }
> >
> > > > > if (visits == 1) {
> > > > > this.gotoAndPlay("investment_focus");
> > > > > }
> >
> > > > > if (visits == 2) {
> > > > > this.gotoAndPlay("white_papers");
> > > > > }
> >
> > > > > etc. - but if it would be better to write this into the flashvars I
> am
> > > > > perfectly open to that as well. Following is the entire file.
> Thanks
> > > > > again, 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 type="text/javascript" src="
> > > > >http://ajax.googleapis.com/ajax/
> > > > > libs/swfobject/2.2/swfobject.js<
> > >http://ajax.googleapis.com/ajax/%0Alibs/swfobject/2.2/swfobject.js>
> > > > > "></script>
> > > > >                <script type="text/javascript">
> > > > >                var flashvars = {"visits=' +
> getCookie('counter')+'"};
> > > > >                swfobject.embedSWF("main_banner.swf", "myContent",
> > > "189",
> > > > > "151",
> > > > > "9.0.0", 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<
> > >http://www.adobe.com/images/shared/download_buttons/%0Aget_flash_play..
> .>"
> > > > > alt="Get Adobe Flash player" /></a></p>
> > > > >                </div>
> > > > >        </body>
> >
> > > > > <SCRIPT LANGUAGE="JavaScript">
> > > > > <!--
> > > > > // Boolean variable specified if alert should be displayed if
> cookie
> > > > > exceeds 4KB
> > > > > var caution = false
> >
> > > > > function setCookie( jscookie, value, expires, path, domain, secure)
> {
> > > > >        var curCookie =  jscookie + "=" + escape(value) +
> > > > >                ((expires) ? "; expires=" + expires.toGMTString() :
> > > > > "") +
> > > > >                ((path) ? "; path=" + path : "") +
> > > > >                ((domain) ? "; domain=" + domain : "") +
> > > > >                ((secure) ? "; secure" : "")
> > > > >        if (!caution || (name + "=" + escape(value)).length <= 4000)
> > > > >                document.cookie = curCookie
> > > > >        else
> > > > >                if (confirm("Cookie exceeds 4KB and will be cut!"))
> > > > >                        document.cookie = curCookie
> > > > > }
> >
> > > > > // name - name of the desired cookie
> > > > > // * return string containing value of specified cookie or null if
> > > > > cookie does not exist
> > > > > function getCookie(name) {
> > > > >        var prefix = name + "="
> > > > >        var cookieStartIndex = document.cookie.indexOf(prefix)
> > > > >        if (cookieStartIndex == -1)
> > > > >                return null
> > > > >        var cookieEndIndex = document.cookie.indexOf(";",
> > > > > cookieStartIndex + prefix.length)
> > > > >        if (cookieEndIndex == -1)
> > > > >                cookieEndIndex = document.cookie.length
> > > > >        return unescape(document.cookie.substring(cookieStartIndex +
> > > > > prefix.length, cookieEndIndex))
> > > > > }
> >
> > > > > // date - any instance of the Date object
> > > > > // * you should hand all instances of the Date object to this
> function
> > > > > for "repairs"
> > > > > // * this function is taken from Chapter 14, "Time and Date in
> > > > > JavaScript", in "Learn Advanced JavaScript Programming"
> > > > > function fixDate(date) {
> > > > >        var base = new Date(0)
> > > > >        var skew = base.getTime()
> > > > >        if (skew > 0)
> > > > >                date.setTime(date.getTime() - skew)
> > > > > }
> >
> > > > > var now = new Date()
> > > > > fixDate(now)
> > > > > now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000)
> > > > > var visits = getCookie("counter")
> > > > > if (!visits)
> > > > >        visits = 1
> > > > > else
> > > > >        visits = parseInt(visits) + 1
> > > > > setCookie("counter", visits, now)
> >
> > > > > //if (visits == 1)
> > > > > //document.write("Thank you for what appears to be your first visit
> to
> > > > > the Curious Cat Cookie Center")
> > > > > //else
> > > > > //document.write("Thank you for returning for what appears to be
> your
> > > > > visit number " + visits + " to the Curious Cat Cookie Center." )
> >
> > > > > // -->
> >
> > > > > </body>
> > > > > </html>
> >
> > > > > --
> >
> > > > > You received this message because you are subscribed to the Google
> > > Groups
> > > > > "SWFObject" group.
> > > > > To post to this group, send email to [email protected].
> > > > > To unsubscribe from this group, send email to
> > > > > [email protected]<swfobject%[email protected]>
> <swfobject%2bunsubscr...@googlegroups­.com>
> > > <swfobject%2bunsubscr...@googlegroups­.com>
> > > > > .
> > > > > For more options, visit this group at
> > > > >http://groups.google.com/group/swfobject?hl=en.-Hide quoted text -
> >
> > > > - Show quoted text -
> >
> > > --
> >
> > > You received this message because you are subscribed to the Google
> Groups
> > > "SWFObject" group.
> > > To post to this group, send email to [email protected].
> > > To unsubscribe from this group, send email to
> > > [email protected]<swfobject%[email protected]>
> <swfobject%2bunsubscr...@googlegroups­.com>
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/swfobject?hl=en.- Hide quoted text -
> >
> > - Show quoted text -
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "SWFObject" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<swfobject%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/swfobject?hl=en.
>
>
>

--

You received this message because you are subscribed to the Google Groups 
"SWFObject" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/swfobject?hl=en.


Reply via email to