PDA

View Full Version : slider problem



iceman
January 6th, 2004, 07:10 PM
Hey everyone,

I'm making a slider which will eventually control the alpha levels of a movieclip of mine but I'm having trouble controlling the parameters in the startDrag() function. Here is the code:
borderBottom = 0;
borderSide = 0;
sliderMC.onPress = function(){
this.startDrag(true,borderSide,borderMC._height, borderMC._width, borderBottom);
}
sliderMC.onRelease = function(){
this.stopDrag();
}
This seems to work ok, however, the problem is encountered when I go to drag the MC...for some unknown reason it ventures off its slider bar and goes to the left. I will attach the .fla and if anyone could help me it would be great!

Thanks A Lot

Kyle:p:

claudio
January 6th, 2004, 07:50 PM
You want to drag the ball "inside" the rectangle?


Yea i think thats what you want. It all depends on how you've set up the registration points of the movie clips. I prefer to have them on the upper left corner, but in your case, here it is:
top = borderMC._y-borderMC._height/2+sliderMC._height/2;
bottom = borderMC._y+borderMC._height/2-sliderMC._height/2;
side = borderMC._x;
sliderMC.onPress = function() {
this.startDrag(false, side, top, side, bottom);
};
sliderMC.onRelease = function() {
this.stopDrag();
};

iceman
January 6th, 2004, 10:50 PM
Thanks Claudio...your code worked perfectly! I couldn't logically think of how to accomplish that. I questions however. I'm having trouble conceptualizing this part of the code: top = borderMC._y-borderMC._height/2+sliderMC._height/2;
bottom = borderMC._y+borderMC._height/2-sliderMC._height/2;
side = borderMC._x;

Why divide by 2? and why do you add the sliderMC into the equation? Also, why the - for the top variable and + for the bottom?

Your code works perfect and I'm envious(lol) ..trying to get it clear in my head.

Thanks A Lot

Kyle:p: