Groups | Blog | Home
all groups > flash actionscript > june 2004 >

flash actionscript : Button down-state help!


Joe Farquharson
6/20/2004 10:59:55 PM
Trying to set up a nav system but having problems coding the down-state. I'm
using a movieclip (button_mc) which advances the animation when the button (b1)
is rolled over and reverses when it is rolled out. When the button (b1) is
pressed I want the movieclip (button_mc) to stop on the last frame (5) and for
the rollover actions to stop working so it just sits as static text.

Can anyone help? I think I need to clear the rollover/rollout actions but I'm
not sure of the best way to go about it.

http://www.stimuli.co.uk/theflash/


___________________


// frame actions

button_mc.onEnterFrame = function() {
if (b1over) {
button_mc.nextFrame();
} else if (!b1over) {
button_mc.prevFrame();
} else if (b1down) {
button_mc.gotoAndStop(5);
}
};

______________________

// button actions

on (rollOver) {
b1over = true;
}

on (rollOut, dragOut) {
b1over = false;
}

on (release, releaseOutside) {
b1down = true;
}
kglad
6/20/2004 11:17:15 PM
button_mc.onRollOver = function() {
playI = setInterval(playF, 70, this, 1);
};
button_mc.onRollOut = button_mc.onDragOut=function () {
clearInterval(playI);
playI = setInterval(playF, 70, this, -1);
};
button_mc.onPress = function() {
clearInterval(playI);
this.gotoAndStop(5);
};
function playF(mc, arg) {
if (arg) {
mc.nextFrame();
} else {
mc.prevFrame();
}
}

Joe Farquharson
6/21/2004 12:10:16 AM
Thanks kglad. Tried out your suggestion (modified it a little) and it works
(final code attached)

http://www.stimuli.co.uk/theflash/

Do you think this is the most efficient solution? I'll need to do this (in
some cases) for about 20 or so buttons and when another button is pressed it
will need to reset whichever button is pressed previously.

var btnDown;

b1.onRollOver = function() {
if (btnDown == undefined || false) {
clearInterval(playI);
playI = setInterval(playF, 30, button_mc, 1);
} else {
continue;
}
};

b1.onRollOut = b1.onDragOut = function () {
if (btnDown == undefined || false) {
clearInterval(playI);
playI = setInterval(playF, 30, button_mc, 0);
} else {
continue;
}
};

b1.onPress = function() {
clearInterval(playI);
button_mc.gotoAndStop(5);
btnDown = true;
};

function playF(mc, arg) {
trace(arg);
if (arg) {
mc.nextFrame();
} else {
mc.prevFrame();
}
}
kglad
6/21/2004 1:47:51 AM
Joe Farquharson
6/21/2004 12:53:08 PM
Joe Farquharson
6/21/2004 12:53:08 PM
kglad
6/21/2004 2:09:44 PM
AddThis Social Bookmark Button