Flash - 带有动态加载的影片剪辑的滚动区域

发布于 2024-07-16 16:27:06 字数 297 浏览 6 评论 0原文

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

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

我想我可以在菜单区域上放置一个蒙版,并让加载控件的影片剪辑在蒙版内上下滚动,但动态加载的影片剪辑似乎不会出现在蒙版中。

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

有谁知道这方面的好教程,或者有关于一种优雅的方法的建议,这样我就不必做一堆数学技巧来使其工作?

谢谢

I'm building a Flash project that creates a menu system with dynamically loaded movie clips for the menu items themselves.

I want a scroll bar to appear once the menu has enough items that it's larger than the menu area.

I was thinking that I could just put a mask over the menu area and have the movie clip where the controls where loaded scroll up and down within the mask, but the dynamically loaded movie clips don't seem to appear in the mask.

I have searched around the internet for this, but all the scroll bar tutorials that I can find deal with text areas rather than an area with dynamically loaded movie clips.

Does anyone know of a good tutorial for this or have a suggestion as to an elegant way of doing this so I don't have to make a bunch of math hacks to make it work?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

枫以 2024-07-23 16:27:06

不确定你到底在追求什么。

我刚刚使用 Flash CS3/AS3 进行了快速测试,并加载了可在遮罩(滚动框的底部)内移动的项目。

首先,我创建了一个蒙版层,然后创建一个新层作为蒙版的子层。 我向“蒙版”图层子级添加了一个新的空影片剪辑。 我将此 MovieClip 命名为“mcItems”。

然后我附加了以下框架脚本(当然使用类会更好)。

    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);

现在,Content.swf 只是一个 120x120 像素的灰色框。 我的面具是 240x120。 执行后,3 个 Content.swf 框将被加载并按预期在遮罩区域内滑动。

至于滚动条代码,我不确定你所说的“数学黑客”是什么意思,但基本原则是你正在从一组单位转换为另一组单位。 您正在将“掩模宽度/加载的总项目”单位转换为“滚动手柄宽度/滚动条宽度”单位。

我建议查看相应的手册页以澄清上面使用的代码。

问候,
乔萨姆。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文