A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: remember frame on reload (browser refresh) using LSO

  1. #1
    Junior Member
    Join Date
    Jun 2007
    Posts
    5

    remember frame on reload (browser refresh) using LSO

    Hi,
    I"m not an expert in AS (by far), but i have a thing i need to get solved.

    I have a site, which has a flash banner. The whole website is based
    on PHP en MySQL. Everytime the user clicks somewhere, the site
    reloads (doh) but the thing is, i need the banner to remember which
    frame it was located so it returns and plays to the saved frame, and not
    from the start.

    I have 5 banners, and each banner calls another banner at the end
    randomly, so it looks like it never ends.

    I have already googled alot, also this forum and a lot of tuts on shared objects, but most of the tutorials are specified to saving text, score or
    how many times a user has accessed the site, the only thing i need is
    the frame it's playing, save it to the so, and after reload, access the so,
    and play from that particular frame again .. so it does'nt start from the beginning all the time.

    Perhaps someone knows how to get the current frame? is there some kind of command for?

    Tnx,
    F

  2. #2
    Senior Member Speed85's Avatar
    Join Date
    Apr 2007
    Posts
    291
    _currentframe gives you the current frame, I'd imagine the best thing to do would be save the _currrentframe as you would to save a score then when the banner loads have it pull that and gotoAndPlay.
    Whoever taught EVERYONE to put all their code on movie clips needs to be shot...

  3. #3
    Junior Member
    Join Date
    Jun 2007
    Posts
    5
    Yer already figured out _currentframe ..

    I'm testing the stuff now, i saw a few other posts with the same question,
    if i have solved it i will post it here for others to use ..

    Cheers

  4. #4
    Junior Member
    Join Date
    Jun 2007
    Posts
    5
    Ok, gheghe .. done it, AS is pretty cool .. never worked with it ..

    So shortcut version, i didn't want to reload the flash movie everytime
    the user clicked somewhere in the menu.

    So this is the code (based on my envirement).

    I've put this at the first frame.
    Code:
    // function for saving the current frame
    function saveCurrentframe() {
    	LSO.data.currentframe = this._currentframe;
    	//trace(LSO.data.currentframe);
    }
    
    //create the Local Shared Object
    LSO = SharedObject.getLocal("pacman" );
    
    //check content currentframe and do something
    if(LSO.data.currentframe != null && LSO.data.currentframe != 350)
      gotoAndPlay(LSO.data.currentframe);
    else
       LSO.data.currentframe = 1;
    
    gotoAndPlay(LSO.data.currentframe);
    So... I check if the currentframe is empty (not set) or at the end of my movie (frame 350), set it to 1 (so it starts at the beginning) and play the frame, if it's not true, play the saved frame.

    The function saveCurrentframe(), has been put on every frame left (counting from 2), copy paste it

    Well if someone has a better solution or has some modifications, please reply ..

    (Used Flash CS3)

    Cheers

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