10 Replies Latest reply on May 27, 2009 7:20 AM by kglad

    Need name for 'top'

    SvingXD

      Sorry for bothering the forum for the 3rd time today, dont worry I have saved it to my favourites by now, I need to know how you would name the 'top' of an object when scripting so that even when it rotates you can describe the top of it. All I can find atm is the axis names: 'y' and 'x' please help.

        • 1. Re: Need name for 'top'
          kglad Adobe Community Professional & MVP

          what do you mean by "..describe the top of it"?

          • 2. Re: Need name for 'top'
            SvingXD Level 1

            I mean in a script I want to name the top of the object seeing as this object will rotate I cannot give it a axis name such as 'y' which is a correct name when scripting in AS2.

            • 3. Re: Need name for 'top'
              kglad Adobe Community Professional & MVP

              you can't "name" part of an object.  you could create an child object of your current object of interest and name the child.

               

              for example, say you're interested in tracking one side of a movieclip (say squareMC) that consists of 4 connected equal length line segments that are parallel to the stage boundaries and that intersect at right angles . you could convert one line segment (say the one with the least y property that's parallel to the stage's top and bottom) to a movieclip and name that topMC.  you could then use squareMC.topMC to determine properties of what was originally the square's topmost line segment.

              1 person found this helpful
              • 4. Re: Need name for 'top'
                Ned Murphy Adobe Community Professional & MVP

                You can identify the top of the object by its _rotation value.  When the object is not rotated at all, its _rotation is 0 degrees and its top is on top.  If the _rotation is 90 degrees, the top is off to the right. etc...

                1 person found this helpful
                • 5. Re: Need name for 'top'
                  SvingXD Level 1

                  I understand I will need to use functions 'this' 'test' '_rotation' 'speed' and 'plane_mc' the name of my movie clip but I am not sure how to code them so that when 'up arrow' is pressed it tests the rotation value of 'plane_mc' and then move the object in that direction, as you can tell Im very new to the scripting and am not sure how to change the lines in my original y axis movement script:

                   

                  var speed:Number = 4;
                  plane_mc.onEnterFrame = function() {

                  if (Key.isDown(Key.UP)) {
                  this._y = this._y+speed;
                  } else if (Key.isDown(Key.DOWN)) {
                  this._y = this._y+speed;
                  }
                  };

                   

                  I hope I can stop bothering you all soon. Thanks for all the help.

                  • 6. Re: Need name for 'top'
                    SvingXD Level 1

                    var speed:Number = 4;
                    plane_mc.onEnterFrame = function() {

                    if (Key.isDown(Key.UP)) {
                    this._y = this._y+speed;            //this line needs editing
                    } else if (Key.isDown(Key.DOWN)) {
                    this._y = this._y+speed;            //and this line also needs editing
                    }
                    };

                    • 7. Re: Need name for 'top'
                      SvingXD Level 1

                      How do I make it a child of the original object because when I tried adding a addChild script it didnt work or didnt work properly as when I tried testing the movie the child didnt move with the parent. Thanks for all the help.

                      • 8. Re: Need name for 'top'
                        kglad Adobe Community Professional & MVP

                        a child moves if its parent moves.  show and explain your code that failed.

                        • 9. Re: Need name for 'top'
                          SvingXD Level 1

                          I am not sure of the script to add a child in AS2 i tried using 'plane_mc.addChild (top_mc)' but then realised that only works in AS3 then I tried 'plane_mc.attachMovie (top_mc)' but that doesnt work either, I do not know the commmands for AS2 and the AS2 documentation is too long to read and find out what each one does.

                          • 10. Re: Need name for 'top'
                            kglad Adobe Community Professional & MVP

                            are you creating the parent movieclip dynamically (then use attachMovie() after adding a linkage id to topMC) or are you creating the parent movieclip in the authoring environment (then add topMC to the parent's timeline).