6 Replies Latest reply on Apr 16, 2009 5:07 PM by kglad

    movieclip names and coordinates

    Desprez10 Level 1

      Three questions:

      1) Say I have a movieclip instance named myMC, positioned at 0,0 (according to the properties panel) but getting the _x _y values in a script yield 40,40? (apparently the center position)
      How do I reconcile this discrepancy?

      2) Why does this:

      trace(myMC._x);

      yield 40, while this:

      currentmc = "myMC";
      trace(currentmc._x);

      yield undefined?

      3) Why can't movieclip instances be named numbers? Well, technically, I can name them numbers, but trying to then reference them in a script generates errors.

        • 1. Re: movieclip names and coordinates
          kglad Adobe Community Professional & MVP

          1.  your script is not retrieving the same _x and _y properties or they have changed.

           

          2.  currentmc is a string variable and strings don't have _x properties.  flash can coerce strings into objects (including movieclips) using array notation:

           

          currentmc = this["myMC"];

          trace(currentmc._x);

           

          3.  because numbers look like memebers of the number class to flash.  in fact, you shouldn't start the name of any object, in flash, with a number.

          1 person found this helpful
          • 2. Re: movieclip names and coordinates
            Desprez10 Level 1

            Thanks for the reply.

             

            Can you elaborate on point 1? I'm confused how it can have different sets of _x _y coordinates, and the movieclip has not moved.

             

            I place a movieclip instance (myMC) at 0,0 according to the properties pannel, which puts the upper left corner of the clip at the upper left corner of the stage.

            Then I have this in frame one:

             

            trace(myMC._x);

            trace(myMC._y);

             

            And I get 40, 40, not 0, 0.

            Nothing has moved or changed, and there is not much else in the file at this time.

             

            It appears the properties pannel places things by the upper left corner of the clip, where as actionscrip references the center of the clip.

            • 3. Re: movieclip names and coordinates
              kglad Adobe Community Professional & MVP

              change the extension on your fla file to swf and attach it to this forum.

              • 4. Re: movieclip names and coordinates
                MATTANDIE

                Despres,

                 

                Check the registration point of "myClip". It sounds like the graphics inside "myClip" are centered and the registration point of your clip is top left (which is default.

                 

                If this is the case, try adjusting your graphics from inside "myClip" and that should fix your trace issue.

                 

                 

                 

                 

                M.

                1 person found this helpful
                • 5. Re: movieclip names and coordinates
                  Desprez10 Level 1

                  I think that appears to be the case.

                  I don't know how to change the registration or any of that, but the coordinates reading from the center in actionscript is more usefull to me anyway.

                  So I'll probably just leave it as is.

                  • 6. Re: movieclip names and coordinates
                    kglad Adobe Community Professional & MVP

                    the properties panel should reflect the reg pt's location and the trace() function should report the reg pt's location.  because your movieclip's upper left is at the stage upper left when the properties panel reports the x,y to be 0,0, you can infer your movieclip's reg point is the upper left.