PDA

View Full Version : Autoscroll in Slide Gallery



Mark__G
12-17-2008, 12:01 AM
I have the following code to have a thumbnail gallery scroll left and right when the mouse is hovered over the flash gallery. My question is how do I implement some code that will make the gallery autoscroll from right to left then back even if the user is not hovered over the gallery.



stop();

alphaTween = new mx.transitions.Tween (back_mc, "_alpha",
mx.transitions.easing.Regular.easeInOut, 0, 100, 0.75,
true);

stageWidth = Stage.width;
speed = 40;
mc1Width = back_mc._width;
mc1X = back_mc._x;
lock_scroll = false;
_root.onEnterFrame = function () {

if (!lock_scroll)
scroll_mc();
}

function scroll_mc() {
var xdist = _xmouse-(stageWidth/2);

mc1X += -xdist/speed;
if (mc1X>=0) {
mc1X = 0;
}
if (mc1X<=stageWidth-mc1Width) {
mc1X = stageWidth-mc1Width;
}
setProperty("back_mc", _x, mc1X);
}

//create an empty mc container for content to display
createEmptyMovieClip("content_box", 200);
content_box._x = 195;
content_box._y = 92;