dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: In trouble with SharedObject

  1. #1

    In trouble with SharedObject

    Hi everyone, and thank you in advance.

    I have been all over this board, and found many useful solutions to my problem, but ... there is a glitch somewhere, and I cant seem to get it to work.

    I need the header to play once. Thats it .. nothing fancy.

    I have this in the first frame ....

    info = SharedObject.getLocal("previousVisit");
    if (info.data.visitedBefore == undefined) {
    _root.play();
    } else {
    _root.gotoAndStop(200)
    }


    Then I have this in the end frame ....

    stop();
    info = SharedObject.getLocal("previousVisit");
    info.data.visitedBefore = true;
    info.flush();
    _root.stop();

    It DOES work .. but it stops in the middle for some reason .. it doesnt gotoAndStop at the end of the movie.

    Im using MX 2004
    You can download the fla here

    This is a rush "quick" project .. so any help would be greatly appreciated.

    Thanks
    Last edited by Phineasben; 08-16-2006 at 10:59 PM.

  2. #2
    Senior Member
    Join Date
    Apr 2005
    Location
    FL, USA
    Posts
    443
    Ensure that you're allowing enough time to read the cookie with this on the first frame....
    Code:
    stop();
    info = SharedObject.getLocal("history");
    onEnterFrame = function() {
    	if(info.data.visitedBefore != undefined) {
    		if(!info.data.visitedBefore) {
    			play();
    		}
    		else {
    			gotoAndStop("end");
    		}
    		delete onEnterFrame;
    	}
    	else {
    		info.data.visitedBefore = false;
    	}
    }
    ...and this is all you need on the last....
    Code:
    stop();
    info.data.visitedBefore = true;

  3. #3
    Sweet!!!

    Thank You very much .. you just fixed a 4 hour headache.

    I did actually try putting a stop action on the first frame before, but it didnt help with the code I was using.

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