5 Replies Latest reply on May 22, 2007 10:56 AM by kglad

    Writing Code on Timeline

    smazr123 Level 1
      I look and I look and I can't find an explanation for this. Basically, what is the difference between writing code in a document class and writing it in the timeline. I understand all this about classes, but I cant understand how writing code in the timeline then gets translated into the whole class orientation of things. For example, when I make a function in the main timeline, how is that written into the class. Does that become a function of the document class?? Then when I add another movie to the stage, does that become a child of the other movie? I seem to be able to access movies and there properties from timelines above it, but not the other way around. Shouldn't variables instantiated in the root timeline become global? This was the basis for how I used to write actionscript and im finding it incredibly frustrating that this dynamic is not explained anywhere.

      Basically Can anyone give an explanation of how code on the timeline now works. Isnt there any documentation on this?
        • 1. Re: Writing Code on Timeline
          Level 7
          Variables created on a timeline are local to that timeline only, they are
          not global. You can reference any timeline from any other through the clip
          hierarchy. A clip you place within another clip is a child of the parent
          clip, yes. From the child you can reference the parent using
          this._parent.property or this._parent.variable
          I'm not sure what you mean by 'document class'. A class is simple an
          external actionscript file, containing methods (functions) related to that
          class. Unless you create a class, functions you create on the timeline are
          just functions on that timeline... methods within a class are no different
          really, it's just they are external and easily reused.
          --
          Dave -
          Head Developer
          http://www.blurredistinction.com
          Adobe Community Expert
          http://www.adobe.com/communities/experts/


          • 2. Re: Writing Code on Timeline
            Level 7
            > I'm not sure what you mean by 'document class'. A class is simple
            > an external actionscript file, containing methods (functions) related
            > to that class.

            This must refer to the new Document class feature (AS3-only) in Flash
            CS3. This is a new field in the Property inspector (when the Stage is
            selected) that essentially allows the developer to bypass the usual "main"
            instantiation in the first keyframe. In AS2, an OOP purist may want to keep
            every last shred of ActionScript outside of any keyframe of any timeline.
            The closest you can get in AS2 is to bundle up everything into a single
            "main" class -- call it Main.as, Start.as, what have you -- and instantiate
            it in frame 1. The Document class feature bypasses even that. It's just a
            way to let a FLA be literally code free, yet completely programmed in AS3.


            David Stiller
            Adobe Community Expert
            Dev blog, http://www.quip.net/blog/
            "Luck is the residue of good design."


            • 3. Re: Writing Code on Timeline
              Level 7
              Thanks for the clarification David. I have yet to see CS3, so didn't
              recognize that...

              --
              Dave -
              Head Developer
              http://www.blurredistinction.com
              Adobe Community Expert
              http://www.adobe.com/communities/experts/


              • 4. Re: Writing Code on Timeline
                Level 7
                > Thanks for the clarification David. I have yet to see CS3, so didn't
                > recognize that...

                Sure thing. :) CS3 is pretty sweet, I must say. The new UI rocks, and
                obviously code-heads will love the ability to publish AS3 SWFs. (Most of
                those code-heads will almost certainly keep coding outside the IDE, though,
                that's my hunch, though the Actions panel has some nice new improvements.)


                David Stiller
                Adobe Community Expert
                Dev blog, http://www.quip.net/blog/
                "Luck is the residue of good design."


                • 5. Re: Writing Code on Timeline
                  kglad Adobe Community Professional & MVP
                  yes, the as3 compiler reeks. i'm going to test flashdevelop 3.0 alpha tomorrow.