Skip to main content
texjgc
Known Participant
October 18, 2007
Answered

Lock movie clips Y pos

  • October 18, 2007
  • 13 replies
  • 933 views
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!
This topic has been closed for replies.
Correct answer Newsgroup_User
comment out the line that updates bluecar_mc's _y property.

13 replies

kglad
Community Expert
Community Expert
October 19, 2007
you're welcome.
texjgc
texjgcAuthor
Known Participant
October 19, 2007
Worked!

Thanks again kglad. Your good.

My regards, Jgc
Newsgroup_UserCorrect answer
Inspiring
October 19, 2007
comment out the line that updates bluecar_mc's _y property.
kglad
Community Expert
Community Expert
October 19, 2007
comment out the line that updates bluecar_mc's _y property.
Inspiring
October 18, 2007
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.

texjgc
texjgcAuthor
Known Participant
October 18, 2007
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.
clbeech
Inspiring
October 18, 2007
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 ;)
kglad
Community Expert
Community Expert
October 18, 2007
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).
texjgc
texjgcAuthor
Known Participant
October 18, 2007
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. :)
October 18, 2007
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