3 Replies Latest reply on Sep 4, 2007 6:08 PM by gajtguy

    Basic 1st steps for Actionscripts

      So, I'm wondering what the basic 1st steps are for Actionscripts in Flash applications? Being new and making no assumptions, I'd say that the file starts with Frame1 of the main timeline. Does that actionscript ever get 'processed' or 'run' again? Or do you need everything else to be in 'functions' and event driven by using listeners?

      Can someone clue me in to more of an overall flash way of programming?

      Some questions are:
      - If there is code in frame1 of the 'actions' layer, and code in frame1 of 'mylayer' (both on the main stage), does one run before the other? If so, based on what? Which one is on top?
      - Also, I've tried a 'GotoandPlay' command from my initial actionscript in Frame1 of 'actions' layer, but since it's outside of a function it only seems to advance the frame of the object to the proper frame lablel. But it doesn't run from that point on. So what's the thinking here?
        • 1. Re: Basic 1st steps for Actionscripts
          Action script is loaded top down, you can see this by putting 2 layers in your file and adding a line of AS to each layer
          on layer 1 put trace("layer 1")
          on layer 2 put trace("layer 2")
          control - enter to preview the movie and you will see in the output that the layer 1 text is traced before the layer 2 text.

          AS3 application development has moved more towards using external AS in packages and classes that load from .as files although you can still do your AS in frames of the actual FLA if thats what you are used to/prefer.

          target.gotoAndStop() will advance to the targets frame specified by number or label and then stop
          target.gotoAndPlay() will advance to the targets frame specified by number or label and then play from that point

          so if you are on the main time line and want to go play starting at the 5th frame of the main timeline you can just say

          and if you have a movieclip on the main timeline with the instance name "movie1" you can tell it to go play it's 5th frame by saying

          and if you are inside movie1 and want to tell the main timeline to go to and play at the 5th frame you can say

          Best thing I can suggest if starting to work through some tutorials...there are a bunch in flash, and lots more on the web. Get to know the basics then come back here when you have some specific questions about getting someting to work. Hlepful in that case if you can post your code :)

          • 2. Re: Basic 1st steps for Actionscripts
            gajtguy Level 1
            wow, I actually understood everything you just said. Thank you very much.

            Having a better understanding of these basics is very important as I move forward with my flash learning. Thanks again. (Me likey the forums)
            • 3. Re: Basic 1st steps for Actionscripts
              gajtguy Level 1
              An additional question regarding the 'program' flow: Are functions initially processed, even before the event takes place?

              I have several functions listed in my main Actionscript program. These are all processed with 'Click' or 'onRollover' events. But it would seem that upon the initial 'test movie' that some, if not all, of the functions are being processed.

              What's the truth to this? And is there a way to prevent this?