0

I am working on a music player and I have a working playlist, but I need the playlist to be short so that if a lot of songs are added it doesn't go off-screen. To do that I created a mask and a scrollbar. The song names are in the playlist, and new ones can be added at any given time.

function startDragging2(MouseEvent)
    {
        Playlistslider.playlistSliderHandle.startDrag(false,rectangle2);
        dragging = true;
    }

    function stopDragging2(MouseEvent)
    {
        if(dragging)
        {
            dragging = false;
            Playlistslider.playlistSliderHandle.stopDrag();
        }
    }

    function adjustY(Event)
    {
        var myY:Number = Playlistslider.playlistSliderHandle.y;
        CollectionMC.y = (myY * -CollectionMC.numChildren);  <--------
    }

Now what I want to do is make it so that the scrollbar handle determines the position of the parent movieclip that contains the song names. If I scroll down, I want it to go no further than the amount of songs that are in the list. Right now it scrolls, but not enough so not the whole list shows.

What I need is a simple formula that decides the y position of the parent movieclip relative to the y position of the slider handle.

Thanks in advance,

Milan.

EDIT: I forgot to add, the first name is at Y:20. Second at Y:40. Third at Y:60, and so forth

EDIT 2: With this formula I'm close, but I can always scroll a space of 6 names (120 Y) too far.

var myY:Number = Playlistslider.playlistSliderHandle.y;
CollectionMC.y = -(myY * (CollectionMC.numChildren / 6));

EDIT 3: I have changed the height of the mask and the scrollbar to 100 to make it easier. Now 5 names can show inside the mask. When I add 5 songs the scrollbar appears, but it's not supposed to scroll down when I use it because all songs fit inside the mask. But when I add another one I want it to scroll down enough to show the 6th name and not see the first name. But instead it scrolls the size of the mask(100) further down than it's supposed to, no matter how many songs I add.

EDIT 4: I have found the solution. The right formula is this:

CollectionMC.y = (((CollectionMC.numChildren - 5) * -0.2) * myY);
4

1 回答 1

0

为什么不直接使用 fl 或 flex 的滚动条?我知道有些人讨厌我的建议,但他想做的很简单,可以忽略……不愉快。您甚至可以按照自己喜欢的方式对其进行剥皮!

于 2013-05-15T13:56:24.740 回答