A Flash Developer Resource Site

Results 1 to 12 of 12

Thread: shared object newbie

  1. #1
    Junior Member
    Join Date
    Feb 2010
    Posts
    11

    shared object newbie

    i have a movieclip that play on my webpage, i need to make when i refresh a page a movieclip start whenever frame it last were,

    i know i have to use shared object but dont know how

    is there any exsample of that? or someone can explain me how to do it?

    thx

  2. #2
    Junior Member
    Join Date
    Feb 2010
    Posts
    11
    Anyone?

  3. #3
    :
    Join Date
    Dec 2002
    Posts
    3,518
    What version of Flash / AS are you using?

  4. #4
    Junior Member
    Join Date
    Feb 2010
    Posts
    11
    im using as2 but i can use as3 if is necessary, it is a simple slideshow with 4 images

  5. #5
    :
    Join Date
    Dec 2002
    Posts
    3,518
    Code:
    var shared;
    function check_position() {
    	shared = SharedObject.getLocal("savegame");
    	if (shared.data.current == undefined) {
    		shared.data.current = 1;
    	}
    	shared.close();
    	return shared.data.current;
    }
    function set_position(framenum) {
    	shared = SharedObject.getLocal("savegame");
    	shared.data.current = framenum;
    	shared.close();
    }
    trace(check_position());
    set_position(3);
    trace(check_position());

  6. #6
    Junior Member
    Join Date
    Feb 2010
    Posts
    11
    where i have to add this code?

  7. #7
    Junior Member
    Join Date
    Feb 2010
    Posts
    11
    anyone can help?

  8. #8
    Flash/Flex Developer samac1068's Avatar
    Join Date
    Apr 2007
    Location
    Here, no there
    Posts
    1,813
    You can place the function anywhere, but if you want all movieclips to see it, you should place it on the main timeline.
    Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.

  9. #9
    Junior Member
    Join Date
    Feb 2010
    Posts
    11
    i have tryed to add that cone on my timeline but it wont work, i have upload my movie clip if someone can take a look and tell me what im doing wrong...

    thx
    Attached Files Attached Files

  10. #10
    :
    Join Date
    Dec 2002
    Posts
    3,518
    main timeline fraime 1
    Code:
    var shared;
    function check_position() {
    	shared = SharedObject.getLocal("savegame");
    	if (shared.data.current == undefined) {
    		shared.data.current = 1;
    	}
    	shared.close();
    	return shared.data.current;
    }
    function set_position(framenum) {
    	shared = SharedObject.getLocal("savegame");
    	shared.data.current = framenum;
    	shared.close();
    }
    var lastframe = check_position();
    trace(lastframe);
    gotoAndPlay(lastframe);
    main timeline frames 50, 100, 150, 200
    Code:
    set_position(_currentframe);
    Last edited by dawsonk; 05-25-2010 at 09:59 AM.

  11. #11
    Junior Member
    Join Date
    Feb 2010
    Posts
    11
    that script work perfect, but my movieclip have 2000 frames and i have to put set_position(_currentframe); on each one,

    is there another way to do the same thing?

  12. #12
    :
    Join Date
    Dec 2002
    Posts
    3,518
    Code:
    var shared;
    function check_position() {
    	shared = SharedObject.getLocal("savegame");
    	if (shared.data.current == undefined) {
    		shared.data.current = 1;
    	}
    	shared.close();
    	return shared.data.current;
    }
    function set_position(framenum) {
    	shared = SharedObject.getLocal("savegame");
    	shared.data.current = framenum;
    	shared.close();
    }
    this.onEnterFrame = function() {
    	set_position(_currentframe);
    };
    var lastframe = check_position();
    trace(lastframe);
    gotoAndPlay(lastframe);

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