5 Replies Latest reply on Dec 9, 2006 5:08 AM by Newsgroup_User

    Starting AS2

    the_lar
      Hi all,

      I'm struggling with Actionscript 2! I'm quite an experienced Flash(5) developer and have been away from Flash for quite a while. I am trying to get into AS2 but I'm having trouble understanding the principles. Could you recommend some good books or online tutorials to get me going?

      One of the things I can't get my head around is assigning classes to movie clips. As an example, I've written a class which is a timer that I want to assign to several movie clips on stage. The timer object needs to be started when it's movie clip registers an 'onMouseOut' event' and then it does something when a certain time limit is reached without there being a 'onMouseOver' event on the movie clip. What would be the best way to set up this scenario?

      Any help, gratefully received
      Kind regards
      Kevin
        • 1. Re: Starting AS2
          Level 7
          The principles are really very much the same .. only real differences are

          1) there is a 'class' syntax for defining classes, instead of using
          prototypes (end result is the same though)
          2) there are optional types for variables and functions that give the
          compiler hits about what values are stored in the variable (or what value a
          function returns) so it can pick up errors. The types don't really 'do'
          anything.

          There's a few new classes (which are not really part of AS, but part of the
          player object model)
          --
          Jeckyl


          • 2. Re: Starting AS2
            the_lar Level 1
            Thanks Jeckyl,
            It's more annoying little things that don't seem to behave like I want them to that I'm struggling with, for instance:

            My class file -

            class TClocationClasses.PanelTimer extends MovieClip {
            function onPress(){
            this._x += 20;
            }
            }

            This works just fine and the movie clip it's attached to moves to the right by 20px, however if I change it to function onRollOut it doesn't work at all! Why's that?

            Kevin
            • 3. Re: Starting AS2
              shikozel Level 1
              I tried it and it works for me onRollOut. how do you assign your movie clip to the class? do you bring your movie clip to the stage and then assign the class from the properties?
              • 4. Re: Starting AS2
                the_lar Level 1
                Yes, it was me being stupid, I was assigning another onPress to it from somewhere else!

                Another question though, if I assign a listener to a movie clip like this:

                myClip.onMouseUp=function(){
                //do stuff here
                };

                How can I then remove this listener from myClip when I'm done with it?

                Regards
                Kevin
                • 5. Re: Starting AS2
                  Level 7
                  delete myClip.onMouseUp;

                  That 's that same in AS1 or AS2
                  --
                  Jeckyl