向 fla 添加加载栏的简单方法是什么?

发布于 2024-12-03 19:33:45 字数 79 浏览 4 评论 0原文

我在网站上使用了 .swf,但加载需要几秒钟。加载时有点眼疼,所以我想添加一个加载栏。我想知道在 .fla 文件中执行此操作的最简单方法是什么。

I have a .swf that I'm using on my website but it takes a few seconds to load. Its kind of an eye sore while its loading so I want to add a loading bar. I was wondering what the easiest way to do this in the .fla file is.

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

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

发布评论

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

评论(2

夜灵血窟げ 2024-12-10 19:33:45

1) 在主时间轴上创建三层。

2) 在第 1 层(顶部)上,在第 1 帧、第 2 帧和第 3 帧上制作两个空白关键帧。

3) 在第 1 层第 1 帧上,输入此代码:

    bytes_loaded = Math.round(this.getBytesLoaded());
    bytes_total = Math.round(this.getBytesTotal());
    //
    this.loadBar._width = getPercent*200;
    if (bytes_loaded == bytes_total) {
        this.gotoAndPlay(3);
    }
    ;

4) 在第 1 层第 2 帧上,输入此代码:

    this.gotoAndPlay(1);

5) 在第 2 层(中),在第 1 帧和第 3 帧上创建一个空白关键帧。

6) 在第 2 层第 1 帧上绘制一个没有边框的矩形(假设为 100x10)。现在,将其设为红色。

7) 将该形状转换为影片剪辑并将实例命名为“loadBar”。

8) 在第 3 层(底部)上,在第 1 帧和第 3 帧上创建一个空白关键帧。

9) 在第 3 层第 1 帧上绘制一个没有边框的矩形(假设为 100x10)。现在,将其设为黑色。这将是加载栏的背景。将其直接与第 2 层的矩形影片剪辑后面对齐。

10) 双击第 2 层第 1 帧的名为“loadBar”的影片剪辑。

11)制作2层。

12) 在第 1 层(顶部)上绘制一个没有边框的矩形(假设为 100x10)。使它成为任何你想要的颜色。

13) 在第 2 层(底部)上绘制一个没有边框的矩形(假设为 100x10)。将其设为灰色。这将是条形填满时的颜色。将其直接与第 1 层的矩形后面对齐。

14) 现在,右键单击时间轴区域中的图层 1,然后选择“蒙版”。

15) 现在,一切准备就绪!文件加载后,它将跳转到第 3 帧并开始播放!根据需要更改加载栏图形的颜色、大小和位置!

1) Make three layers on your Main Timeline.

2) On Layer 1 (top), make two blank keyframes on Frame 1 and 2 and 3.

3) On Layer 1, Frame 1, enter this code:

    bytes_loaded = Math.round(this.getBytesLoaded());
    bytes_total = Math.round(this.getBytesTotal());
    //
    this.loadBar._width = getPercent*200;
    if (bytes_loaded == bytes_total) {
        this.gotoAndPlay(3);
    }
    ;

4) On Layer 1, Frame 2, enter this code:

    this.gotoAndPlay(1);

5) On Layer 2 (Middle), make a blank keyframe on Frame 1 and Frame 3.

6) Draw a rectangle (let's say 100x10) with no border on Layer 2, Frame 1. For now, make it red.

7) Convert that shape to a Movie Clip and name the instance "loadBar".

8) On Layer 3 (Bottom), make a blank keyframe on Frame 1 and Frame 3.

9) Draw a rectangle (let's say 100x10) with no border on Layer 3, Frame 1. For now, make it black. This will be the background of your loading bar. Align it directly behind Layer 2's rectangle movie clip.

10) Double-click Layer 2 Frame 1's movie clip called "loadBar".

11) Make 2 layers.

12) On Layer 1 (Top) draw a rectangle (let's say 100x10) with no border. Make it any color you want.

13) On Layer 2 (Bottom) draw a rectangle (let's say 100x10) with no border. Make it Gray. This will be the color of the bar as it fills up. Align it directly behind Layer 1's rectangle shape.

14) Now, right-click on Layer 1 in the Timeline area and select "Mask."

15) Now, you're all set! Once the file has loaded it will jump to Frame 3 and start playing! Change the colors and sizes and positions of the loading bar graphics as needed!

℡寂寞咖啡 2024-12-10 19:33:45
this.stop();
this.loaderInfo.addEventListener(Event.COMPLETE, action);
this.loaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressAction);
function onProgressAction (e:ProgressEvent):void
{
    var total:Number = e.bytesTotal;
    var loaded:Number = e.bytesLoaded;
    if(total == loaded) {
        gotoAndStop(2);
    }   
}
function action (e:Event):void 
{
    this.loaderInfo.removeEventListener(ProgressEvent.PROGRESS, onProgressAction);
}
this.stop();
this.loaderInfo.addEventListener(Event.COMPLETE, action);
this.loaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressAction);
function onProgressAction (e:ProgressEvent):void
{
    var total:Number = e.bytesTotal;
    var loaded:Number = e.bytesLoaded;
    if(total == loaded) {
        gotoAndStop(2);
    }   
}
function action (e:Event):void 
{
    this.loaderInfo.removeEventListener(ProgressEvent.PROGRESS, onProgressAction);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文