Adobe Flash Builder:如何制作带有进度条的 SWF 用于加载自身?

     2023-02-16     176

关键词:

【中文标题】Adobe Flash Builder:如何制作带有进度条的 SWF 用于加载自身?【英文标题】:Adobe Flash Builder: How to make a SWF with a progress bar for loading itself? 【发布时间】:2021-03-03 09:38:48 【问题描述】:

我有一个 AS3 项目,它的所有资产都使用 [Embed] 元数据标签嵌入,因为我希望生成的 SWF 完全独立,以便在 Internet 上移植。

问题: 文件大小相当大,我希望在加载时显示进度条而不是空白屏幕,直到它完全完成。我已经可以使用 Adob​​e Animate (Flash Professional) 实现这一点,方法是使用带有轻帧 1 和重帧 2 的 时间线,其中包含嵌入大量资产的 MovieClip。

我正在尝试切换到没有 IDE 时间线的 Adob​​e Flash Builder,但我不知道如何做与 Flash IDE 相同的事情。有人对如何实现这一点有任何想法吗?

【问题讨论】:

【参考方案1】:

选项№1。我选择了一个,因为它更容易理解:外部加载器。一个轻量级 SWF,其唯一目的是在加载重量级主模块时显示一些预加载信息,例如 % 或进度。

选项№2。有一个特定的 metatag 允许您模拟第 1 帧预加载器的行为。请记住,ASC2.0 编译器(我假设为 AIR SDK)不支持,而只有 ASC1.0 编译器(Flex SDK)。 Flash BuilderFlex Builder 的后代,所以我想这很好,但如果它不适合您,您首先应该检查您的编译器版本Flash Builder 包含在内。

所以,你的主(你在设置中设置为文档类的那个)类应该有那个元标记

package

    import flash.events.Event;
    import flash.display.Sprite;
    
    // Brace for the magic impact.
    [Frame(factoryClass="Preloader")]
    public class Main extends Sprite
    
        public function Main()
        
            // This is important, because at the moment of creation
            // the instance is not attached to the stage.
            if (stage) onStage(null);
            else addEventListener(flash.events.Event.ADDED_TO_STAGE, onStage);
        
        
        private function onStage(e:Event):void
        
            removeEventListener(flash.events.Event.ADDED_TO_STAGE, onStage);
            
            // This is the entry point of your actual application.
            // The rest of the class goes normally from this point on.

然后,提到的预加载器类。它的名称应完全符合上述元标记中所述。

package

    import flash.display.DisplayObject;
    import flash.display.MovieClip;
    
    import flash.events.Event;
    
    import flash.events.IOErrorEvent;
    import flash.events.ProgressEvent;
    
    import flash.utils.getDefinitionByName;
    
    // This class represents the multi-framed main timeline
    // thus it should subclass the basic MovieClip.
    public class Preloader extends MovieClip
    
        public function Preloader()
        
            // Subscribe to all necessary points to monitor the loading.
            addEventListener(Event.ENTER_FRAME, onFrame);
            
            loaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);
            loaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgress);
        
        
        private function ioError(e:IOErrorEvent):void
        
            // Handle loading errors here.
        
        
        private function onProgress(e:ProgressEvent):void
        
            // Display loading progress here.
            // Use e.bytesLoaded and e.bytesTotal values
            // to calculate the % loaded and the overall loading progress.
        
        
        private function onFrame(e:Event):void
        
            // When the loading is finished, the main timeline,
            // represented by Preloader class moves to the frame 2.
            if (currentFrame == totalFrames)
            
                stop();
                
                onComplete();
            
        
        
        // This method concludes the loading,
        // cleans up the preloader itself
        // and instantiates the Main class.
        private function onComplete():void
        
            removeEventListener(Event.ENTER_FRAME, onFrame);
            
            loaderInfo.removeEventListener(IOErrorEvent.IO_ERROR, ioError);
            loaderInfo.removeEventListener(ProgressEvent.PROGRESS, onProgress);
            
            // So, here's the thing. You don't import the Main class
            // because if you import it, then it will be embedded into
            // the Preloader, then it must be loaded before Preloader
            // can be initialized, which kind of fails the whole idea.
            
            // Thus, you don't import the Main class but obtain it
            // via the other means, like the "getDefinitionByName" method.
            // Again, the fully qualified class name is to be provided.
            
            var aMain:Class = getDefinitionByName("Main") as Class;
            stage.addChild(new aMain as DisplayObject);
            
            // Remove this instance as it no longer needed for anything.
            parent.removeChild(this);
        
    

【讨论】:

【参考方案2】:

我找到了solution that works with ASC2 / AIR SDK。尽管他的示例预加载器扩展了 Sprite,但我相信您需要扩展 MovieClip 才能使其工作,因为您需要第 2 帧。而且一旦完成加载,您还需要 gotoAndStop(2)。附加信息here。伙计,当您的所有参考链接都通过 web.archive.org 时,这不是一个好兆头!

【讨论】:

Adobe Flash Builder:不显示可视组件

】AdobeFlashBuilder:不显示可视组件【英文标题】:AdobeFlashBuilder:visualcomponentsaren\'tdisplayed【发布时间】:2014-03-2723:07:35【问题描述】:我卡住了。我一直在尝试使用AdobeFlashBuilder开发简单的应用程序,但没有运气。这很简单,我什... 查看详情

如何制作具有透明背景的 Flash 电影

】如何制作具有透明背景的Flash电影【英文标题】:HowtomakeaFlashmoviewithatransparentbackground【发布时间】:2010-09-0515:02:56【问题描述】:Adobe的这个页面说要添加一个“wmode”参数并将其值设置为“透明”:http://kb.adobe.com/selfservice/vie... 查看详情

Adobe flash (AS2):如何制作一个永远重复的循环,并且每 5 秒复制一个影片剪辑?

】Adobeflash(AS2):如何制作一个永远重复的循环,并且每5秒复制一个影片剪辑?【英文标题】:Adobeflash(AS2):Howtomakealoopthatrepeatsforever,andthatduplicatesamovieclipevery5seconds?【发布时间】:2017-08-1204:11:39【问题描述】:我想制作一个永远... 查看详情

Flash Builder、Adobe AIR 和 iOS 开发的包检查失败错误

】FlashBuilder、AdobeAIR和iOS开发的包检查失败错误【英文标题】:PackageInspectionFailedErrorwithFlashBuilder,AdobeAIRandiOSdevelopment【发布时间】:2013-09-2421:09:03【问题描述】:使用FB4.7Premium、Air3.4构建iOS应用。至此,只是一个非常简单的测试... 查看详情

adobe air vs flex vs flash builder ---我需要解释一下

】adobeairvsflexvsflashbuilder---我需要解释一下【英文标题】:adobeairvsflexvsflashbuilder---ineedanexplanationplease【发布时间】:2012-03-2218:17:47【问题描述】:谁能向我解释一下Adob​​eAir、Flex和FlashBuilder之间的区别?我访问了Adob​​e网站... 查看详情

Adobe Flash Builder (flex4):addChild() 在此类中不可用。

】AdobeFlashBuilder(flex4):addChild()在此类中不可用。【英文标题】:AdobeFlashBuilder(flex4):addChild()isnotavailableinthisclass.【发布时间】:2011-01-0216:15:31【问题描述】:我想将一个swf加载到一个flex4应用程序中以便使用它的类。varldr:Loader=new... 查看详情

Flash Builder 不显示桌面应用程序

】FlashBuilder不显示桌面应用程序【英文标题】:FlashBuildernotshowingdesktopApplication【发布时间】:2015-06-2012:48:19【问题描述】:在学习FlashBuilder的过程中,我正在测试一个在浏览器中运行的简单应用程序,代码如下:xmlns:s="library://n... 查看详情

Adobe Flash/动画静音特定音频

...在只需要它来静音背景音乐,因为它也在静音我的视频!如何更改 查看详情

如何使用 actionscript 在 flash builder 中将背景放在我的 swf 后面?

】如何使用actionscript在flashbuilder中将背景放在我的swf后面?【英文标题】:HowdoIputabackgroundbehindmyswfinflashbuilderusingactionscript?【发布时间】:2015-11-0109:15:25【问题描述】:在FlashBuilder上,我有一个ActionScript移动应用程序和一个swf文... 查看详情

html5/css/js 制作复杂的基于模块的软件平台(脱离Adobe Flash)

】html5/css/js制作复杂的基于模块的软件平台(脱离AdobeFlash)【英文标题】:html5/css/jstomakecomplexmodule-basedsoftwareplatforms(escapingfromAdobeFlash)【发布时间】:2015-10-3018:20:28【问题描述】:最近我开始在一个软件平台项目中工作,像过... 查看详情

如何集成 Flash Professional 和 Flash Builder?

】如何集成FlashProfessional和FlashBuilder?【英文标题】:HowtointegrateFlashProfessionalandFlashBuilder?【发布时间】:2011-08-0318:39:53【问题描述】:我是一名习惯使用FlashBuilder的AS3开发人员。我正在与一位使用FlashProfessional为游戏设计精灵和... 查看详情

如何在 Beamer 上添加 gif/动画(Adobe 停用 Flash)

】如何在Beamer上添加gif/动画(Adobe停用Flash)【英文标题】:Howtoaddagif/animationontoBeamer(postAdoberetiringFlash)【发布时间】:2021-10-1312:25:32【问题描述】:我无法将gif添加到我的Beamer中。我已经搜索过答案,但我没有找到在Adob​​e停... 查看详情

带有 adobe flash player 的 RTMP 流

...ashplayer在rtmp流视频上的作用需求...RTMP和Flash都是Adob​​e制作 查看详情

Adobe XFL Flash 交换格式的文档在哪里?

...题描述】:我在一家动画工作室工作,该工作室使用Flash制作多部作品。新的Adob​​eCS4套件最令人兴奋的功能之一可能是XFL文件格式。最后,我有了一个ascii格式,我可以使用它来收紧我们的Flash到 查看详情

如何在 Flash Builder 中为 Android 开发?

】如何在FlashBuilder中为Android开发?【英文标题】:HowtodevelopforAndroidinFlashBuilder?【发布时间】:2017-01-1102:51:03【问题描述】:我一直在玩用Adob​​eFlash创建游戏,想知道如何在Android上部署它?目前它分布在大约100个actionscriptswf... 查看详情

flash builder无法打开文件

】flashbuilder无法打开文件【英文标题】:flashbuilderunabletoopenfile【发布时间】:2014-03-2916:02:33【问题描述】:我是adobeflashbuilder的新手,我正在制作一个移动flex项目。到目前为止,在我的项目中,我有一个简单的两页布局,带有... 查看详情

将 Adob​​e Air 3.3 SDK 与 Flash Builder 一起使用

】将Adob​​eAir3.3SDK与FlashBuilder一起使用【英文标题】:UseAdobeAir3.3SDKwithFlashBuilder【发布时间】:2012-06-1401:34:38【问题描述】:AdobeAirSDKV3.3终于在2012年6月8日发布,可以在这里下载:http://www.adobe.com/products/air.html现在我试图通过... 查看详情

Flash Builder 如何确定要包含哪些 sdk 库?

】FlashBuilder如何确定要包含哪些sdk库?【英文标题】:HowdoesFlashBuilderdeterminewhichsdklibrariestoinclude?【发布时间】:2011-09-2702:39:24【问题描述】:在FlashBuilder中创建新项目时,它如何确定要在构建路径中包含哪些sdk库?如果我创建... 查看详情