13 Replies Latest reply on Oct 18, 2007 5:48 PM by kglad

    Lock movie clips Y pos

    texjgc Level 1
      The message title pretty much says it all. I want to lock a movie clips Y pos, so that the user can only move the clip on the X axis.
      Any ideas?

      Thank you!
        • 1. Re: Lock movie clips Y pos
          clbeech Level 3
          you can do so with the parameters in the 'startDrag() method, by setting the 'top' number and 'bottom' number to be the same.
          • 2. Re: Lock movie clips Y pos
            texjgc Level 1
            Not sure what you mean.

            Can you explain a little deeper please?

            Thank you for the reply.
            • 3. Re: Lock movie clips Y pos
              kglad Adobe Community Professional & MVP
              are you using startDrag()? if so, read about the method and you'll see it accepts 5 parameters, 4 of which can be used to restrict the rectangle (including a side of zero length or line) where movement is allowed.
              • 4. Lock movie clips Y pos
                ChrisElmes Level 1
                We are assuming that when you say "the user can only move the clip on the x axis" that you mean by dragging, and hence as CB said instead of using just a straight

                on(press){
                startDrag()
                }

                You actually give the startDrag some properties, if you look in the flash help at startDrag() you'll see it has params of
                lockCenter - wether the center of the clip is attached to the mouse pointer or not
                left limit
                right limit
                top limit
                bottom limit
                (the order may be wrong, you'll have to look!!)

                so as CB suggested by making the top and bottom numbers the same then clip can only be dragged in the x direction

                on (press){
                startDrag(false, 100, 0, 400, 0)
                }

                would allow you to drag between 100 and 400 horizontally (assuming I have the params in the right order) along the 0 Y coord (change the y to the position you want it to remain at), its worth noting that the drag coords are based of the parent timelines coordinate system
                • 5. Re: Lock movie clips Y pos
                  texjgc Level 1
                  Im sorry, my opologies, I should have been more expletive.

                  Heres the lowdown:

                  when the user mouses over the movie the mouse disappears and a movieclip (a car drawing) becomes the users cursor. Its not clickable, the user can only move it. So it moves like a cursor but you cant select anything with it like your regular cursor.

                  Anyway,

                  I want to lock the Y axis of the movie clip so the user can only move the car movie clip (in this case, the new cursor) in the X axis only.

                  So basically, on mouseover lock cursors Y pos and let the user move only on the X.

                  Hope that helps. Thanks for your replies. :)
                  • 6. Re: Lock movie clips Y pos
                    kglad Adobe Community Professional & MVP
                    and what causes the movieclip to move? there must be a loop that repeatedly updates the movieclip's _x and _y (or x and y) properties. in that loop, do what you want: don't update the _y (or y) or don't update either if the mouse changes vertical position (depending on the effect you want).
                    • 7. Lock movie clips Y pos
                      clbeech Level 3
                      well in that case you must be using the mouseover event to detect AND move the car by adjusting it's coordinates to the mouse position. then only adjust the clips _xmouse value, leave the _y value alone.

                      can you post the code your using for this?

                      EDIT: sorry kg, slow fingers ;)
                      • 8. Re: Lock movie clips Y pos
                        texjgc Level 1
                        yes. here is the code im using that moves the clip in place of the default mouse cursor.

                        ****************************************************
                        Mouse.hide();
                        var mouseListener:Object = new Object();
                        mouseListener.onMouseMove = function() {
                        bluecar_mc._x = _xmouse;
                        bluecar_mc._y = _ymouse;
                        updateAfterEvent();
                        };
                        Mouse.addListener(mouseListener);
                        ****************************************************

                        Thanks.
                        • 9. Re: Lock movie clips Y pos
                          Level 7
                          yes. here is the code im using that moves the clip in place of the default
                          mouse cursor.

                          ****************************************************
                          Mouse.hide();
                          var mouseListener:Object = new Object();
                          mouseListener.onMouseMove = function() {
                          bluecar_mc._x = _xmouse;
                          bluecar_mc._y = _ymouse;
                          updateAfterEvent();
                          };
                          Mouse.addListener(mouseListener);
                          ****************************************************

                          Thanks.

                          • 10. Re: Lock movie clips Y pos
                            kglad Adobe Community Professional & MVP
                            comment out the line that updates bluecar_mc's _y property.
                            • 11. Re: Lock movie clips Y pos
                              Level 7
                              comment out the line that updates bluecar_mc's _y property.
                              • 12. Re: Lock movie clips Y pos
                                texjgc Level 1
                                Worked!

                                Thanks again kglad. Your good.

                                My regards, Jgc
                                • 13. Re: Lock movie clips Y pos
                                  kglad Adobe Community Professional & MVP
                                  you're welcome.