A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: back one frame

  1. #1
    Member
    Join Date
    Aug 2001
    Posts
    96
    hi,

    I have made a number of scene in the flash movie.
    In one of the scene, I want to have a button that can allow the user to back one frame, so i use a variable to store the current frame number(_root._currentframe), and the variable is subtracted by 1 before the variable is place in the command 'gotoAndPlay'.
    But why the button cannot take me back the frame before? Do I get something wrong? Would anyone help me?

    thankx all...

  2. #2
    You don't even need a variable. I just tried this code out and it works like a charm.

    on (release) {
    gotoAndPlay (_root._currentFrame - 1);
    }
    Is it possible you were forgetting the upper case F in currentFrame?

    Hope that helps.

    Regards,

    Mike

  3. #3
    Member
    Join Date
    Aug 2001
    Posts
    96
    thx for using your time for giving me reply.
    but it doesn't work.

    When I click that button, it goes to frame 1 of the original scene but not the current scene.

    any help will be appreciated.

  4. #4
    Ooops, sorry, I didn't try that with multiple scenes. Here's one that seems to work. I created a movie with 2 scenes. In Scene 2, I placed a different color circle on each of 8 consecutive frames so I could track the movement and a stop() action on each frame. I made a button with a play() action to move things forward 1 frame at a time, then in another button I placed the following code

    on (release) {
    gotoAndPlay(_root._currentFrame - 2);
    }

    Time after time it took me back 1 frame from where I was. I don't know why this works (and it was quite by accident that I discovered it). BTW, it also worked fine without the _root, but my button was not inside a clip, it was just sitting on Scene 2's main timeline.

    Maybe this will help you???

    Regards,

    Mike

  5. #5
    Member
    Join Date
    Aug 2001
    Posts
    96
    thx very much for your kind reply, mike.

    but it doesn't work. I've put the stop action on the frames. and I made the button as you said. however, the button still went to frame 1 of the scene 1. I've tried to remove the '_root' but the result was the same.
    Do I miss something?

  6. #6
    Oh man, it sounds like you've entered Programming Hell. We all go there, although no one likes it. ;-D When this happens to me (when something isn't working that sure seems like it should), I start a new file and just work on the troublesome piece there. So, maybe start a new file with two scenes, in the second scene put something in so you can track what frame you're in at any given time: either different colored shapes or set a variable that displays in a textbox each time you click your button. Get it working in this test environment, then copy the working code into your real movie. If something worked in test, but fails in the real movie, you can isolate where the problem must be and then figure out why it works in one place but not another. Don't despair - this happens to everyone and it happens all the time. I like to approach it like I'm solving a puzzle - cuts down on my frustration level. I wish you all the best of luck!

    Regards,

    Mike

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