1

我正在构建一个 Flash 项目,该项目创建一个菜单系统,其中包含为菜单项本身动态加载的影片剪辑。

一旦菜单有足够的项目大于菜单区域,我希望出现一个滚动条。

我在想我可以在菜单区域上放置一个遮罩,然后让加载的控件在遮罩内上下滚动的影片剪辑,但动态加载的影片剪辑似乎没有出现在遮罩中。

我已经在互联网上搜索了这个,但我能找到的所有滚动条教程都处理文本区域,而不是动态加载的影片剪辑区域。

有没有人知道一个很好的教程或者有一个关于这样做的优雅方式的建议,所以我不必做一堆数学黑客来让它工作?

谢谢

4

1 回答 1

1

Not sure exactly what you are after.

I just did a quick test with Flash CS3/AS3 and got loaded items to move around inside a mask (the base of a scroll box).

First I created a Mask layer then a new layer as a child of the mask. I added a new empty MovieClip to the Mask layer child. I named this MovieClip 'mcItems'.

I then attached the following frame script (of course using a Class would be preferable).

    for (var i:Number=0; i < 3; ++i)
    {
        var loader:Loader = new Loader();
        loader.load(new URLRequest('Content.swf'));
        mcItems.addChild(loader);
        loader.x = i * 120;
    };
    function update (event:Event)
    {
        mcItems.x = 120*Math.sin(getTimer()/500) - 60;
    };
    addEventListener(Event.ENTER_FRAME, update);

Now, Content.swf is just a 120x120 pixel gray box. My mask is 240x120. Upon execution the 3 Content.swf boxes are loaded and slide around inside the masked area as expected.

As for the scrollbar code, I am not sure what you mean by 'math hacks' but the basic principal is you are converting from one set of units to another. You are converting your "mask width / total items loaded with" units to your "scroll handle width / scroll bar width" units.

I recommend reviewing the appropriate manual pages for clarification of the code used above.

Regards, Jotham.

于 2009-04-13T22:18:43.167 回答