As3预加载器问题

发布于 2024-11-06 18:53:57 字数 1690 浏览 1 评论 0原文

你好,我正在尝试在 flash builder 中制作预加载器。我想在加载所有项目时缩放我的加载栏。但是当我开始游戏时,它只是在白屏上等待并跳过加载屏幕。谁能帮我解决这个问题

public class OYLoadManager extends Sprite
{
    private var main:CagryInside;
    //////////////////Load Manager Items///////////////////////////// 
    [Embed(source="../Resources/loadImages/loadBackground.png")]
    private var loadBackgroundClass:Class;
    private var loadBackground:Bitmap = new loadBackgroundClass() ;

    [Embed(source="../Resources/loadImages/loadBar.png")]
    private var loadBarClass:Class ;
    private var loadBar : Bitmap = new loadBarClass() ;

    private static const loadBarWidth:Number = 612;

    private var loadManager:Loader = new Loader();

    public function OYLoadManager(getMain:CagryInside)
    {
        main = getMain;
        // Initializing Load Manager 
        loadBar.x = 226; 
        loadBar.y = 396; 
        loadBar.width = 0 ;

        //Load Screen images
        main.addChild(loadBackground);
        main.addChild(loadBar);
        //main.gameStateManager.selectGameStates(1);


        loadManager.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,loadScreen);
        loadManager.contentLoaderInfo.addEventListener(Event.COMPLETE, finishProcess);
        loadManager.load(new URLRequest("playerProductInstall.swf"));


    }

    public function finishProcess(event:Event):void{
    //  removeLoadManagerMenu();
        main.gameStateManager.selectGameStates(1);
    }

    public function loadScreen(event:ProgressEvent):void{

        var ratio:Number = event.bytesLoaded / event.bytesTotal;
        //loadBar.width += loadBarWidth/loadedObjectNumber ;    
        loadBar.scaleX = ratio;
    }

Hi i am trying to make preloader in flash builder. I wanna scale my load bar while all of items loading . But when i start my game its just waiting on white screen and skips load screen. Can anyone help me to fix this problem

public class OYLoadManager extends Sprite
{
    private var main:CagryInside;
    //////////////////Load Manager Items///////////////////////////// 
    [Embed(source="../Resources/loadImages/loadBackground.png")]
    private var loadBackgroundClass:Class;
    private var loadBackground:Bitmap = new loadBackgroundClass() ;

    [Embed(source="../Resources/loadImages/loadBar.png")]
    private var loadBarClass:Class ;
    private var loadBar : Bitmap = new loadBarClass() ;

    private static const loadBarWidth:Number = 612;

    private var loadManager:Loader = new Loader();

    public function OYLoadManager(getMain:CagryInside)
    {
        main = getMain;
        // Initializing Load Manager 
        loadBar.x = 226; 
        loadBar.y = 396; 
        loadBar.width = 0 ;

        //Load Screen images
        main.addChild(loadBackground);
        main.addChild(loadBar);
        //main.gameStateManager.selectGameStates(1);


        loadManager.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,loadScreen);
        loadManager.contentLoaderInfo.addEventListener(Event.COMPLETE, finishProcess);
        loadManager.load(new URLRequest("playerProductInstall.swf"));


    }

    public function finishProcess(event:Event):void{
    //  removeLoadManagerMenu();
        main.gameStateManager.selectGameStates(1);
    }

    public function loadScreen(event:ProgressEvent):void{

        var ratio:Number = event.bytesLoaded / event.bytesTotal;
        //loadBar.width += loadBarWidth/loadedObjectNumber ;    
        loadBar.scaleX = ratio;
    }

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

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

发布评论

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

评论(1

一笑百媚生 2024-11-13 18:53:57

我在任何地方都看不到 stop()

否则:请确保在导出 ActionScript 类时在第 1 帧中取消选择导出。否则,在 Flash 事件加载预加载器之前,您将加载大量资源。

确保您的第一帧很小的一个非常有用的工具是带宽分析器。用这个。它位于“查看”->“当您从 Flash 测试应用程序/电影时使用带宽分析器。它显示每个帧的大小 - 尝试将第 1 帧保持在 30kb 以下。简单的预加载器比大而精美的图像更好,无论如何加载都需要 10-20 秒。或者至少从一个简单的预加载器开始,然后在资源加载时更改它的外观。

I can't see a stop() there anywhere.

Otherwise: Make sure when you export your classes for ActionScript that you deselect export in frame 1. Otherwise you'll have a bunch of your assets loading before flash events gets to loading your preloader.

A really useful tool for making sure your first frame is tiny is the bandwidth profiler. Use this. It's at View -> Bandwidth Profiler when you're testing your application/movie from flash. It displays the size of each frame - try keep frame 1 under say 30kb. Simple preloaders are better than big fancy images and such that take 10-20 seconds to load anyway. Or at least start with a simple preloader and then change the appearance of it as assets load.

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