This actionscript for a flash image slider works reasonably well, but I am wondering if it can be slowed down. At the moment it positively races the image across the screen on load. Which part controls the speed?:
Code:
mouseX = _xmouse;
menuX = menu._x;
if (mouseX>480) {
diff = (mouseX-480)/15;
}
if (mouseX<420) {
diff = (420-mouseX)/15;
}
if (mouseX<=450 && menuX<=850) {
setProperty("menu", _x, menuX+diff);
}
if (mouseX>=450 && menuX>=-600) {
setProperty("menu", _x, menuX-diff);
}
if (menu._x>=850) {
menu._x = 850;
} else if (menu._x<=-600) {
menu._x = -600;
}
gotoAndPlay(2);
Also, can it be made to slide the image back and forth perpetually until a hover?
have you tried messing with the Frames Per Second (fps) setting?
It should be in your properties toolbar somewhere. It could be in the high 30's or something and that could be part of the reason it is going so rapidly.
As far as a perpetual thing. You could use an EnterFrame event and keep looking for a mouse hover or you can place all your images in a container (like a sprite), add a mouseover listener and then use a boolean or something to stop it. Not terribly difficult and a few ways to do it, it just takes some expirementation.
yeah, sorry. It's highly possible that I'm confused (it happens )
but for example -->
//you have your imagecontainer or whatever, add a boolean and some listeners..
Code:
var currentlyHovering:Boolean = false;
imageContainer.addEventListener(MouseEvent.MOUSE_OVER, function(){
currentlyHovering = true;
});
imageContainer.addEventListener(MouseEvent.MOUSE_OUT, function(){
currentlyHovering = false;
});
//and you can have an enter frame event on the app...
this.stage.addEventListener(Event.ENTER_FRAME, onEnterFrame);
function onEnterFrame(event:Event):void
{
while(!currentlyHovering)
{
//do your thing and call your perpetual hover code
perpetuallyHover();
}
}
something like that maybe, I'm just going off the top of my head here and trying to help out is all.
Again, all apologies if I'm not fully understanding what you're trying to do.
take this post if you can and bring it to the guys on Actionscript.org and put it in the AS2 forums.
I'm not as well versed in AS2 as I am AS3 and they've got some swedes over there that've been doing this for years and will probably have your solution up to you in no time (and may give you a few AS2 pointers that I certainly don't know about).
I thought I had more time to look at this but I won't be able to get to it for awhile. They have guys over there that are on all night lol