Ok this should be easy, but theres 1 thing that confuses me (this is for a scrollbar btw; not the componenet ones) and i got this from a flash 5 source, but i am using MX…
ok there are 3 keyframes. On keyframe 1 there is the code:
[AS]
oldY = 0;
newY = 0;
Y = 0;
[/AS]
so dragY minus itself?!!? ok anyways this doesn’t seem to work :-\i’ll post the fla for you to see. I’m trying to optimize this crappy flash 5 code to flash MX
Well, I would remove those variables, create the MovieClip by using ActionScript and update the content position by using an onEnterFrame handler. I don’t like static event handlers, so I’d remove them too…
Remove the MovieClip script and throw this code in the main timeline:
[AS]dragMC.buttonMC.onPress = function() {
this.startDrag(false, 0, -1010, 0, 0);
};
dragMC.buttonMC.onRelease = function() {
this.stopDrag();
};
dragMC.buttonMC.onReleaseOutside = dragMC.buttonMC.onRelease;
this.createEmptyMovieClip(“controller”, 9876);
controller.onEnterFrame = function() {
mainScroll.scrolledMC._y += (dragMC.buttonMC._y-mainScroll.scrolledMC._y)/8;
};[/AS]
… But I guess that you wanted to somehow automate the process, so you don’t have to hardcode the whole thing (the startDrag parameters, for instance)? :-\
Uhmm… I don’t think I’m explaining myself very well. I’ve never been good at it.
thanks! that looks nice, but what does the createemptymovieclip create?! I know it creates an empty movieclip But what are we going to use it for?
EDIT: ok from what i understand it controls the easing thing right?!but thats only after the user releases the mouse off the dragger :-\ or i think i am wrong actually
It creates the MovieClip which will act as a controller (self explanatory instance name) to move the MovieClip, scrolledMC, to the correct position.
Now that I think about it, you don’t need that either. Remove those lines of the code and assign the onEnterFrame handler to scrolledMC:
[AS]mainScroll.scrolledMC.onEnterFrame = function() {
this._y += (dragMC.buttonMC._y-this._y)/8;
};[/AS]
Much better…