View Full Version : Scrolling with buttons
asianmoths
September 18th, 2002, 11:05 PM
I am using buttons with the following code to move another movie clip:
on (press, release, keyPress "<Down>") {
dragTree._y += 20;
}
This works fine, but I was hoping that I could make is so if you keep the mouse button pressed, it would repeat the change in location so that you do not need to continuously click the button.
This seems like it should be simple, but I could not find a thread that talked about it.
Could someone help me out.
Thanks as always!
upuaut
September 19th, 2002, 02:47 AM
sure can.
on the movie clip you're moving.. place this (movie clip code is placed on movie clips just like button code is placed on buttons)
onClipEvent(load){
move=0;
}
onClipEvent(enterFrame){
this._y+=move;
}
the onClipEvent(load) isn't really even necessary.. but it's cleaner scripting to declare that at the beginning. The enterFrame event just says every time this movie clip's playhead enters a new frame do whatever is inside the {} in this case add the value of move to the y location of 'this' (this being the movie clip that the code is attached to)
then on the button that scrolls it down you can use this
on (press) {
dragTree.move = 20;
}
on(release){
dragTree.move = 0;
}
on the button that scrolls it up you can use this
on (press) {
dragTree.move = -20;
}
on(release){
dragTree.move = 0;
}
These buttons will set the value of the variable 'move' which will be added to the _y location in the onClipEvent code.
upuaut
September 19th, 2002, 02:48 AM
ooo.. mind you.. if you're movie clip has a stop action in it's timeline anywhere it will stop the enterFrame event. If that's the case let me know and I'll come up with a work around for it.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.