A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: [RESOLVED] sharedObject woes....

  1. #1
    Ryan Thomson EvolveDesigns's Avatar
    Join Date
    Oct 2001
    Location
    British Columbia
    Posts
    3,338

    [RESOLVED] sharedObject woes....

    I've set these up before no problems.. for some reason this one just won't work. Basically I want it to send my navigations clips to specific frames when the page is reloaded depending on what link was clicked. Everything seems to work except the shared object isn't being saved.. here's my code:

    Code:
    var cookie:SharedObject = SharedObject.getLocal("jrs" );
    
    
    ///send header to biography link upon first visit
    if(cookie.data.pageID == undefined){
       cookie.data.pageID = bio; 
       cookie.flush();
    }
    ///button controls
    
    bio.onRelease = function() {
        cookie.data.pageID = bio; 
        cookie.flush();
        getURL("index.html", "_self");
    }
    
    gal.onRelease = function() {
        cookie.data.pageID = gal; 
        cookie.flush();
        getURL("galleries.html", "_self");
    }
    
    sample.onRelease = function() {
        cookie.data.pageID = sample;
        cookie.flush();
    }
    
    contact.onRelease = function() {
        cookie.data.pageID = contact;
        cookie.flush();
    }
    
    
    //sets link depending on what link was clicked
    	
    if (cookie.data.pageID == _level0.bio) {
        bio.gotoAndPlay(2);
        }else(bio.gotoAndStop("tab"));		
    	
    if (cookie.data.pageID == _level0.gal) {
        gal.gotoAndPlay(2);
        }else(gal.gotoAndStop("tab"));
    
    if (cookie.data.pageID == _level0.sample) {
        sample.gotoAndPlay(2);
        }else(sample.gotoAndStop("tab"));
    
    if (cookie.data.pageID == _level0.contact) {
        contact.gotoAndPlay(2);
        }else(contact.gotoAndStop("tab"));
    sorry if it's a bit confused.. any insights welcome! thx all
    Evolve Designs Interactive Media
    the natural selection

  2. #2
    Senior Member
    Join Date
    Oct 2005
    Posts
    148
    Try setting cookie.data.pageID as string references instead of movieClips, by using quotes. I think what's happening is that the sharedObject is saving your information (or atleast trying to), but when trying to read them back in, it doesn't recognize that bio is a movieClip object reference, and not a string. So to save the confusion, just save your variables as strings, like so:

    cookie.data.pageID = "bio"

    not:

    cookie.data.pageID = bio

    And don't forget to change your if statements as well:

    if (cookie.data.pageID == "bio") {

    not:

    if (cookie.data.pageID == _level0.bio) {

  3. #3
    Ryan Thomson EvolveDesigns's Avatar
    Join Date
    Oct 2001
    Location
    British Columbia
    Posts
    3,338
    always nice to have an extra set up eyes... thanks pigpen32, works great now
    Evolve Designs Interactive Media
    the natural selection

  4. #4
    Senior Member
    Join Date
    Oct 2005
    Posts
    148
    Your welcome. Glad that fixed it.

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