A Flash Developer Resource Site

Results 1 to 12 of 12

Thread: Back button

  1. #1
    Member
    Join Date
    Dec 2003
    Location
    London, England
    Posts
    41

    Back button

    I've no idea where to start with this.

    All I want to create is a back button that will go to the last frame the user viewed, which is not necessarily going to be the last frame within the movie.

    Is there some kind of script I can attach to each frame which is activated by the button? I've tried making something up working on this assumption. But it jumps all round the place and is useless basically.

    Help would be appricated.

    I'm still waiting for the day when everything falls into place and I can start helping people!

    I'm pretty useless really.

    Hope al the above makes sense.

    Thanks for reading this.

    Rebecca_scotty

  2. #2
    Senior Member DrDoom's Avatar
    Join Date
    Apr 2006
    Posts
    144
    put the actioscript:

    _root.LF=_root.CF;
    _root.CF=_root._currentframe;


    On each frame. Then on the back button write:

    _root.gotoAndStop(_root.LF);


    ...hmmmm....there must be a simpler way
    -luke.slashmedia.co.uk(my site)
    (^.^)

  3. #3
    Senior Member
    Join Date
    Apr 2002
    Posts
    174
    on(release) {
    previousFrame = this._currentFrame -1;
    gotoAndStop(previousFrame);
    }

  4. #4
    Member
    Join Date
    Dec 2003
    Location
    London, England
    Posts
    41
    Wicked this seems to work.

    Is there a way to make it remember more than one frame back?

  5. #5
    Senior Member
    Join Date
    Apr 2002
    Posts
    174
    Hey Rebecca,

    Ummmm..... Sure you could script the button to go back to a variable set as previous frame. What are you looking to do exactly?

    -jub-

  6. #6
    Senior Member DrDoom's Avatar
    Join Date
    Apr 2006
    Posts
    144
    What she means is the previous frame the user viewed, not the previous frame on the timeline.

    To store more than one frame you should use an array.

    I'll suggest a method, though there is probably a much easier way.

    So here's my method:


    Create a blank first frame. This should appear only once at the start of the movie and the user should not be able to navigate to this frame. Don't put a stop(); action on it. Then on it put the code:
    code:
    _root.LF=new Array();
    _root.history=20 //change this to the number of steps you want it to record
    function goFrame(frame) {
    _root.gotoAndStop(frame);
    for(i=0; i<_root.history; i++) {
    _root.LF[i]=_root.LF[i+1];
    }
    _root.LF[_root.history]=_root._currentframe;
    }

    function lastFrame() {
    for (i=_root.history; i>0; i--) {
    _root.LF[i] = _root.LF[i-1];
    }
    _root.LF[0] = undefined;
    _root.gotoAndStop(_root.LF[_root.history]);
    }



    Now whenever you want the user to go to a frame, dont use gotoAndStop() - use goFrame().

    On the button which makes flash go to the last frame the user visited, write:
    code:
    on (release) {
    _root.lastFrame();
    }



    Good Luck with it
    Last edited by DrDoom; 04-25-2006 at 01:04 PM.
    -luke.slashmedia.co.uk(my site)
    (^.^)

  7. #7
    Member
    Join Date
    Dec 2003
    Location
    London, England
    Posts
    41
    Thanks guys

    I shall give this a go tomorrow looks like Dr Doom knows what I want to do.
    Thought I might need to create an Array but haven't used one before and found it a little daunting and confusing.

    I'm just scratching the surface really, wish I could get my head round it a bit more.

    Thanks again!

  8. #8
    Member
    Join Date
    Dec 2003
    Location
    London, England
    Posts
    41
    Right flash has developed major problems.

    The back button works when the movie is played in the flash player.

    But as soon as I drop it into a browser t doesn't load any of the external movies in anymore, and when i put it within an html page in dreamweaver it fails to show up at all!!!

    Any ideas.

  9. #9
    Senior Member DrDoom's Avatar
    Join Date
    Apr 2006
    Posts
    144
    How are you dynamically loading the movies. You should use a MovieClipLoader because they make it much easier to identify the problem (as well as a lot of other things).

    Maybe upload some source... need more information.

    It may be that you have an old version of flash player for Firefox (Or IE <shudder>). Check that first.
    -luke.slashmedia.co.uk(my site)
    (^.^)

  10. #10
    Member
    Join Date
    Dec 2003
    Location
    London, England
    Posts
    41
    thanks for getting back so fast

    I am just using this kind of script -

    loadMovie("corporategraphs.swf", _root.graphs);

    on the frame with the movie to load into on it. Is this bad script?

    I'm not really that sure what MovieClipLoader is.

    I might be able to post some sight info a bit later. Have to check.

    Wonder if this is anything to do with it?

    Thanks

  11. #11
    Senior Member DrDoom's Avatar
    Join Date
    Apr 2006
    Posts
    144
    The MovieClipLoader equivalent of that code is:

    MCL=new MovieClipLoader();
    MCL.loadClip("corporategraphs.swf", _root.graphs);

    MovieClipLoaders are useful because they will say if it failed to load and you can keep track of loading progress.

    I doubt that would account for your problem though. Try it and try outputing stuff like MCL.getProgress().bytesTotal for bytes downloaded.

    As I say, check for latest flash player browser version. Other than that without taking a look at the fla theres not much i can do to help.
    -luke.slashmedia.co.uk(my site)
    (^.^)

  12. #12
    Member
    Join Date
    Dec 2003
    Location
    London, England
    Posts
    41
    Well thanks for doing all you can without the actual file , I will try what you've suggested.

    Your help is greatly appricated.

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