Skip to main content
Known Participant
April 25, 2010
Answered

Scrolling a Pane to the Top of a Flash Movie

  • April 25, 2010
  • 1 reply
  • 953 views

Hi,

I'm working on a site for a customer: <http://home.comcast.net/~richmaxw/tests/kris/>. The problem is that when you click on "About," then "Gear," then scroll down, and then click on another link (like "Photos") the pane does not go back to the top. I know that this is very trivial, but the customer is insisting that I fix it. I can privately send a link to the .fla source file to anyone who replies here. Thank you in advance for any help.

Sincerely,

Richard

This topic has been closed for replies.
Correct answer Ned Murphy

Here is the code inside the scroll button:

onClipEvent (load)
{
oldY = 1;
Y = 1;
vY = 0;
newY = 0;
mouseWheelHitTest = true;
contentHeight = _parent.scrolledMC._height;
scrollSpeed = _parent.speed_content;
scrollStep = _parent.step_content;
viewHeight = _parent.line._height;
buttonSize = _parent.dragMC._height;
buttonY = buttonMC._y;
scrollHeight = _parent.scrolledMC._height + 875;
scrollContent = _parent.scrolledMC._y;
scrollContent1 = _parent.scrolledMC;
newY = _parent.scrolledMC._height;
var mouseListener:Object = new Object();
mouseListener.onMouseWheel = function(delta)
{
  if (!mouseWheelHitTest || scrollContent1.hitTest(_root._xmouse, _root._ymouse, false) || hitTest(_root._xmouse, _root._ymouse, false))
  {
   if (buttonMC._y>=0 && buttonMC._y<=scrollHeight-buttonSize+1)
   {
    buttonMC._y -= (delta)*_parent.mouse_speed;
   }
  }
};
Mouse.addListener(mouseListener);
hiScroll = _parent.line._height-_parent.dragMC._height;
step = ((scrollHeight-buttonSize)-(hiScroll))/(hiScroll);
y = _parent.scrolledMC._y;
}

onClipEvent (enterFrame)
{
if (_parent.drag_but)
{
  if (buttonMC._y>=0)
  {
   buttonMC._y -= scrollStep;
  }
}

if (_parent.down_but)
{
  if (buttonMC._y<=scrollHeight+buttonSize)
  {
   buttonMC._y += scrollStep;
  }
}

if (buttonMC._y<=0)
{
  buttonMC._y = 0;
}

if (buttonMC._y>=viewHeight-buttonSize)
{
  buttonMC._y = viewHeight-buttonSize;
}

level = buttonMC._y-buttonY;
lev = int(y-(level*step));
newY = oldY+(lev-oldY)/scrollSpeed;
_parent.scrolledMC._y = newY;
oldY = newY;
}


And here is code on the top of the frame for the pane:

mouse_speed = 2;
speed_content = 6;
step_content = 10;
step = 5;
scrolledMC.setMask(mask);
stop();


Can you also show the code for one of the links that changes the section?  That is likely where you will be adding some code to reset the positions of things.

I cannot be sure, but my best guess would to offer that the code that changes the sections will need to set the buttonMC._y value and the scrolledMC._y value both to zero (or whatever values they normally start at).

1 reply

Ned Murphy
Legend
April 25, 2010

It appears you need to reset the scroller and the content location anytime one of the subsections is selected.  What code do you currently have relative to that panel and the scroller?

richmaxwAuthor
Known Participant
April 25, 2010

Hi Ned,

Here is the source file for the movie: <http://home.comcast.net/~richmaxw/movie.fla>. The left-hand pane in question is stored in frame 2 of the "action content copy" movie clip. The code for the right-hand pane is stored in the "action sc copy 3" movie clip. I've also noticed some ActionScript in the "action sc copy" movie clip inside the "dragMC" scroll button.

Thanks,

Richard

Ned Murphy
Legend
April 25, 2010

It will be better if you show the code from the file relative to the scroll controls.  I won't be downloading a 50 MB file and other people that help here won't download a file under any circumstances short of being hired.