A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: passing a cookie in through the query string

  1. #1
    Senior Member
    Join Date
    Sep 2000
    Posts
    199

    Cow Icon

    Hi,

    When one uses javascript to write the value of a cookie into the object/embed tags I have found that this prohibits a flash movie from being properly cached.

    The same movie will appear in the cache as many times as the value of the cookie was different.

    e.g.

    loader.swf?cookie=9287492
    loader.swf?cookie=2536256

    So as long as the value of a cookie is changed the browser will always go to the server for the same old flash movie even though its in the cache. Its name is just a little different.

    I've got around this by passing the cookie value to a very small swf (69 bytes) which can then load in the main movie from the cache.

    I was wondering if there's another way around this?

    Thanks,

    I.

  2. #2
    Junior Member
    Join Date
    Oct 2000
    Posts
    16
    CaptainNeeder,

    When you load the smaller .swf files into your flash movie can you make them check the value of a cookie file whenever you bring them in?

    What I am trying to do without server-side scripting and database work is pass a value of a cookie into a flash .swf file WITHOUT having to refresh the .swf every time, as you would have to do using the Object and Embed method of passing variables.

    What I would like to do is create a small SWF file that basically is one frame that loads the text from a cookie when it plays. I can use this to set a variable in the flash movie and if the cookie changes the information would change when that small .swf file loads again into the main movie.

    I am trying to make a navbar that resides in a seperate frame from html content. I would like the navbar to reflect clicked links in the frame containing standard html information that take you to other parts of the site.

    I am thinking that I could keep re-loading a small SWF file (using LoadMovie) in the navbar file that simply loads the information from a cookie into itself when the movie loads so if the cookie changes (as it would when someone clicks a link in the html frame to go to another section) then when the navbar swf file hits the LoadMovie command (I would set this in a loop of some sort) and re-loads the smaller SWF file the variables can change.

    It would be even BETTER if I could just set a loop in the navbar file that just continously loads the data from the cookie file over and over on a set interval and can read the changes when the cookie file gets changed.

    I have never seen an example of this and I have been scouring the web for weeks and weeks to find an answer to this so I am not hopefull that it can be done at this point.

    When we tried making flash read the data from the cookie file, even when we set that on a loop it would not reflect changes made to the cookie file once it was initially loaded. We could make flash read the variables from the cookie easily one time but then if the cookie changed it would not change the variable in flash even though it was set on a loop to check for such changes. This is why I am curious to if loading a small swf using load movie would force flash to re-load the cookie data into itself every time it loads.

    If anyone out there can answer this one I know a ****load of designers who would kill for it :-)

  3. #3
    Senior Member
    Join Date
    Sep 2000
    Posts
    199

    Exclamation

    Hi there,

    Its the other way around.

    The small swf is the first swf to load and it is only loaded once.

    When it is loaded, it then loads the main swfs.

    As for continuously checking for a new cookie value...

    You can load a cookie into flash using getURL and some javascript. (In fact, that's what I would have used for the project that I'm currently working on if it had worked on the Mac platform.)

    I don't see why you couldn't have a loop which just runs getURL every other frame. Maybe you've tried this?

    Using getURL, its possible to write a cookie in a swf, load it back into the same swf, update the cookie from the swf and then load it back into the swf again without having to refresh the swf.


    Hope that helps.

    I.

  4. #4
    Junior Member
    Join Date
    Oct 2000
    Posts
    16
    Actually I figured out a better solution using ColdFusion to generate a session variable and then output a text file saying basically variable=x x being a number of some sort. It works perfectly except for the fact that ColdFusion leaves a space before the variable name in the text file making the variable load into flash with a space before it.

    I am able to load the variable into a text field in Flash because the variable name can begin with a space whern you type it into that panel where the text field options are. The problem is when you try accessing it via actionscript which is what I need to do. Since actionscript ignores spaces in the variable name (especially when the name begins with a space) flash jtst ignores the variable when you try and access it with an actionscript.

    Now the problem I have is trying to figure out why the hell ColdFusion is leaving a space as the first character in the text file it generates even though I did not specify it to do so.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center