Skip to main content
Participant
June 22, 2006
Answered

Mouse-hold button

Hey guys,

This is such a stupid question to be asking but it's one I've not come across in a while and I'm danged if I can remember how to do it - I basically have a scrollable map I've been building, but the scroll buttons need to be clicked over and over to move around the map - how can I go about having the following iterate indefinitely until the mouse is relased?:

on(release) {
_level0.map._x = _level0.map._x + 20;
}

I know it'll be an onpress do while etc etc - but I don't know the most efficient way of tackling it! Any ideas?

Thanks,
Graham
This topic is closed to new replies. Start a new post to keep the conversation going.
TolkCorrect answer
Inspiring
June 22, 2006
onClipEvent(enterFrame) {
if(move) {
_level0.map._x = _level0.map._x + 20;
}
}

onClipEvent(mouseDown) { move=true; }
onClipEvent(mouseUp) { move=false; }

I think that's what your trying to do, like Sivakanesh said but iv'e done it for you.

4 replies

Participant
June 22, 2006
Got it! Thanks guys - I've been thrown in at the deep end here being a fairly amateur ActionScripter - so much for my boss' theory that a PHP developer will automatically be a Flash guru :P
Translate
Participant
June 22, 2006
Sorry. I'm still bamboozled here - I'm going totally the wrong way about it I think. Here's what I have, which does virtually nothing - it works once on click but no hold-down functionality....

onClipEvent(enterFrame) {
var move=false;
function left() {
if(move==true) { _level0.map._x = _level0.map._x + 20; }
}
setInterval(left, 100);
}

onClipEvent(mouseDown) { move=true; }
onClipEvent(mouseUp) { move=false; }
Translate
TolkCorrect answer
Inspiring
June 22, 2006
onClipEvent(enterFrame) {
if(move) {
_level0.map._x = _level0.map._x + 20;
}
}

onClipEvent(mouseDown) { move=true; }
onClipEvent(mouseUp) { move=false; }

I think that's what your trying to do, like Sivakanesh said but iv'e done it for you.
Translate
Known Participant
June 22, 2006
This should get you on the right tracks.
First setup a variable called Zoom set it to true on onMouseDown and false onMouseUp.
Then
this.onEnterFrame = function() {
if (Zoom) {
//code for zooming;
}

if you wanted to stop the frame looping use this.onEnterFrame = null;
Translate