Mouse out problem menu

Hello I have a problem.
This is a scolling menu xml menu. That I would like to do is that when I don´t have the mouse over on the menu, the hold menu shall scroll in a speed of 2. I have the code for it, but the problem is when I do the mouse out to the left or to the right. I can’t slow down the speed of the menu, it just add on the speed. When I do the mouse out in center of the menu I get the right speed. So the speed shall always be 2 when I do the mouse out, not that it add on speed of 2. Hope someone understand my bad English. (The function for speed when I do the mouse out is in bold)

Please help!!!

var thumb_spacing = 500;
var numThumb:Number;
 
function GeneratePortfolio(portfolio_xml){
 var portfolioPictures = portfolio_xml.firstChild.childNodes;
 numThumb = portfolioPictures.length;
 
 for (var i = 0; i < numThumb; i++)
 { var currentPicture = portfolioPictures*;
  var currentThumb_mc = this.root_mc.menu_mc.createEmptyMovieClip("thumbnail_mc"+i,i);
  currentThumb_mc._x = i*thumb_spacing;  
  currentThumb_mc.createEmptyMovieClip("thumb_container",0);
  
  currentThumb_mc.thumb_container.loadMovie(currentPicture.attributes.thumb);
  currentThumb_mc.createTextField("description_txt",10,90,0,300,100);
  currentThumb_mc.description_txt.autoSize = "left";
  currentThumb_mc.description_txt.border = false;
  currentThumb_mc.description_txt.multiline = true;
  currentThumb_mc.description_txt.wordWrap = true;
  currentThumb_mc.description_txt.html = true;
  
  currentThumb_mc.textfile = currentPicture.attributes.description;
  currentThumb_mc.link = currentPicture.attributes.url;
  
  loadText(currentThumb_mc);
  createLink(currentThumb_mc);
  
 } 
}
function loadText(mc:MovieClip)
{ var lv:LoadVars = new LoadVars();
 lv.onData = function(src:String):Void {
     if (src != undefined) {mc.description_txt.htmlText = src;}
  else {mc.description_txt.htmlText = "Unable to load text.";}
 }
 lv.load(mc.textfile);
}
function createLink(mc:MovieClip){ 
 mc.onRelease = function(){
 getURL(mc.link,"_blank");
 }
};
// xml object for xml content (defines sources for selections)
var portfolio_xml = new XML();
portfolio_xml.ignoreWhite = true;
portfolio_xml.onLoad = function(success){
 if (success){GeneratePortfolio(this);} 
 else {trace("Error loading XML file");}
}
// load
portfolio_xml.load("bodegashop.xml");
//Start of menu move
root_mc.onRollOver = panelOver;
var b = stroke.getBounds(_root);
**var speed = 2;**
function panelOver() {
 if (numThumb > 1){
   this.onEnterFrame = scrollPanel;
 };//root_mc
 delete this.onRollOver;//Make the onRelease function work
}
function scrollPanel() {
 for (var i=0;i<numThumb;i++){
   var xdist = _root._xmouse-250;
   root_mc.menu_mc["thumbnail_mc"+i]._x += Math.round(-xdist/20); 
   //trace("tmb "+i+" "+root_mc.menu_mc["thumbnail_mc"+i]._x);
   if (root_mc.menu_mc["thumbnail_mc"+i]._x>=450 && xdist<0){
     root_mc.menu_mc["thumbnail_mc"+i]._x -= numThumb*thumb_spacing;
   }else if (root_mc.menu_mc["thumbnail_mc"+i]._x<=-400 && xdist>0){
     root_mc.menu_mc["thumbnail_mc"+i]._x += numThumb*thumb_spacing;
   };
**   if(_ymouse<b.yMin && _xmouse>+250) {
  root_mc.menu_mc["thumbnail_mc"+i]._x -=speed;
 } else if(_ymouse<b.yMin && _xmouse<+250) {
  root_mc.menu_mc["thumbnail_mc"+i]._x +=speed;
 }
 if(_ymouse>b.yMax && _xmouse<+250) {
  root_mc.menu_mc["thumbnail_mc"+i]._x +=speed;
 } else if (_ymouse>b.yMax && _xmouse>+250){
  root_mc.menu_mc["thumbnail_mc"+i]._x -=speed;
 }
 if(_xmouse>b.xMax) {
  root_mc.menu_mc["thumbnail_mc"+i]._x -=speed;
 } else if (_xmouse<b.xMin) {
  root_mc.menu_mc["thumbnail_mc"+i]._x +=speed;
 }
 }
**};

In the scrollpanel function, try replacing this line:

root_mc.menu_mc["thumbnail_mc"+i]._x += Math.round(-xdist/20);

with this:

if ((_xmouse > b.xMin && _xmouse < b.xMax) && (_ymouse > b.yMin && _ymouse < b.yMax)) {
 root_mc.menu_mc["thumbnail_mc" + i]._x += Math.round( -xdist / 20);
} else {
 var panelCentre:Number = (b.xMax - b.xMin) / 2;
 if (_xmouse > panelCentre) {
  root_mc.menu_mc["thumbnail_mc" + i]._x -= speed;
 } else {
  root_mc.menu_mc["thumbnail_mc" + i]._x += speed;
 }
}

and then delete the last 3 IF statements (the 3 you put in bold in the above post)

I tried your code, but it didn’t realy work… It did reduce the speed of the menu, when i did the mouse out to the left or to the right, but it didn’t get to the speed of 2…Like you do the mouse out in center… Maby some code could delete the mouse function when you do the mouse out, so the menu stop and then get the speed of 2. Hope you understud and could help me, I would be so grateful…

I think I understand what you want. Try this:

function scrollPanel() {
 for (var i = 0; i < numThumb; i++){
  var xdist = _root._xmouse - 250;
		
  var newSpeed = Math.round(-xdist / 20);
		
  if (newSpeed < 2 && newSpeed >= 0) {
   newSpeed = 2;
  } else if (newSpeed > -2 && newSpeed <= 0) {
   newSpeed = -2;
  }
		
  if ((_xmouse > b.xMin && _xmouse < b.xMax) && (_ymouse > b.yMin && _ymouse < b.yMax)) {
   root_mc.menu_mc["thumbnail_mc" + i]._x += newSpeed;
  } else {
   var panelCentre:Number = (b.xMax - b.xMin) / 2;
   if (_xmouse > panelCentre) {
    root_mc.menu_mc["thumbnail_mc" + i]._x -= speed;
   } else {
    root_mc.menu_mc["thumbnail_mc" + i]._x += speed;
   }
  }
		
  if (root_mc.menu_mc["thumbnail_mc" + i]._x >= 450 && xdist < 0){
   root_mc.menu_mc["thumbnail_mc" + i]._x -= numThumb * thumb_spacing;
  } else if (root_mc.menu_mc["thumbnail_mc" + i ]._x <= -400 && xdist > 0){
   root_mc.menu_mc["thumbnail_mc" + i]._x += numThumb * thumb_spacing;
  }
 }
};

YEAH that excatly what I mean, tank you SO much =)

Maby you know how to make the menu move in a speed of 2, when you enter the frame. So when the move starts, it starts with a speed of 2 ?

You are the best!!!

well I notice you have this line:

root_mc.onRollOver = panelOver;

if you remove that line and put this at the bottom of all the actions:

this.onEnterFrame = scrollPanel;

rather than having it in the panelOver function it will start straight away.

I don’t know how to tank you…TANK YOU SO MUCH =)