7 Replies Latest reply on Jun 10, 2016 3:50 AM by Ned Murphy

    last view frame

    alia9955927

      hello guys i am trying to create a button in flash the has the function " gotoAndStop " on the last-viewd-frame

      so i don't want it to go one frame back or a specific frame

      for example

      from frame 3 i moved to frame 9 then to frame 28

      so when i press the button there in frame 28 it take me to frame 9 the i press it to take me to frame 3 :l

      i hope it is clear

      thanks

        • 1. Re: last view frame
          Ned Murphy Adobe Community Professional & MVP

          It sounds like you need to be building an array that keeps track of the frames you visit for the gotoAndStop function to utilize.  So in each frame where you stop you add the frame number to that array, and when you click the button it uses the next to last value added in the array.  You will have to reason out the logic for yourself as far as what happens when you then advance to a frame without using that button.

          1 person found this helpful
          • 2. Re: last view frame
            alia9955927 Level 1

            hi Ned,

            thanks for the answer but i am new to adobe flash

            can you give me the basic of writing "array"?

            • 3. Re: last view frame
              alia9955927 Level 1

              hi Ned,

              thanks for the answer but i am new to adobe flash

              can you give me the basic of writing "array"?

              • 4. Re: last view frame
                Ned Murphy Adobe Community Professional & MVP

                I don't give programming lessons, so if that's where you come up short you will need to find somewhere to learn the basics at least.  If you have some experience with programming then your best friends for getting help will be the Help option in the menu bar (select a command in your code and choose Help to get right to the topic)  and Google.

                 

                To use Google to find AS3 help you could use "AS3 Array tutorial" to find some useful stuff to get you going.  Of the many results you get, one of them leads to the documentation you would find using the Help option mentioned above...

                 

                Array - Adobe ActionScript® 3 (AS3 ) API Reference - use this page to help you learn

                 

                To create an array, choose a name for it and declare it....  I chose framesArray in this case but you could choose anything that doesn't violate naming rules

                 

                     var framesArray:Array = new Array();

                 

                To add something to the end of the array you can use the push() method of the Array class...

                 

                    framesArray.push(frameNumber);

                 

                To remove something from the Array you can use the following methods...

                     pop();      (removes from the end) 

                     shift();     (removes from the start)

                     splice();   (removes (or adds) from where you tell it to)

                1 person found this helpful
                • 5. Re: last view frame
                  ClayUUID Adobe Community Professional

                  It would help if you mentioned exactly how users are hopping around the frames.

                  • 6. Re: last view frame
                    alia9955927 Level 1

                    thanks guys

                    i figure out another way to do it

                    by using "Conditions"

                    example:

                    if (MovieClip(parent).currentFrame  == 8){

                      MovieClip(parent).gotoAndStop(2);

                    • 7. Re: last view frame
                      Ned Murphy Adobe Community Professional & MVP

                      If you have fixed locations for how one moves along the timeline rather than the option to move freely then that could work.  You didn't need to ask the question it would seem if that is the case since the answer was the question you asked.  A simpler approach would be to assign a value to a 'previous_frame' variable in each frame you visit and just use that variable in a shared event listener for the button.

                       

                      // in frame 1

                       

                      var previous_frame:int = 1;

                       

                      btn.addEventListener(MouseEvent.CLICK, moveback);

                       

                      function moveback(evt:MouseEvent):void {

                           gotoAndStop(previouse_frame);

                      }

                       

                      // in each frame you stop in...

                      previous_frame = ... // whatever number was the previous frame

                      1 person found this helpful