【问题标题】:AIR application works inside IDE but not on the deviceAIR 应用程序在 IDE 内工作,但不在设备上
【发布时间】:2017-01-22 09:52:29
【问题描述】:

我正在使用 AIR for android 和 Starling 框架开发游戏。我使用 Flash CC 作为 IDE。当我在 Flash 中测试 i 时它工作正常,但是当我将它发布到 android 时它不能正常工作。

我有一个屏幕管理器类,它隐藏和显示菜单、关卡选择和游戏屏幕。为此,我有一个自定义事件类。下面的函数在屏幕管理器类中。它适用于每个目标值,但 不适用于 TO_GAME。

    private function onNavigate(e: NavEvent)
    {
        if (e.destination == Destination.TO_HOME)
        {
            menuScreen.wake();
        }
        else if (e.destination == Destination.TO_LEVELS)
        {
            levelScreen.wake();
        }
        else if (e.destination == Destination.TO_GAME)
        {
            gameScreen.wake();
        }
        else if (e.destination == Destination.TO_HELP)
        {
            helpScreen.wake();
        }
        else if (e.destination == Destination.TO_ABOUT)
        {
            aboutScreen.wake();
        }
    }

当用户点击一个关卡按钮时触发he事件。见其他部分

var btn:Button = e.target as Button;
        if (btn == backBtn)
        {
            this.dispatchEvent(new NavEvent(NavEvent.NAVIGATE , Destination.TO_HOME));
            this.sleep();
        }
        else
        {
            //just testing if I can get the level number from the position of the level button
            trace(this.getLevelNumber(btn.x,btn.y));
            this.dispatchEvent(new NavEvent(NavEvent.NAVIGATE , Destination.TO_GAME));
            this.sleep();
        }

我从不同的按钮触发了这个事件,但到目前为止还没有运气。它在他的 IDE 中工作,但设备内部没有任何反应。所有其他事件都在工作。事件上述函数中的第一个条件工作正常。

【问题讨论】:

    标签: android actionscript-3 flash events air


    【解决方案1】:

    在 AIR for Android 平台上发布时,您应该记住文件名区分大小写。

    例如,我有一个名为“LevelData.json”的文件。注意大写的“D”。

    我正在将该文件加载到如下所示的 starling 资产管理器中

    assets.enqueue(dir.resolvePath("Data/Levels/leveldata.json"));
    

    请注意,我使用小写字母表示“d”。由于 windows 的文件名不区分大小写,所以它没有引起任何问题,但是当我在实际的 Android 设备上运行该应用程序时。它不起作用。所以我将原始文件名更改为“leveldata.json”,瞧!该应用程序现在运行良好。

    【讨论】:

    • 恭喜您通过 +1 对可能难倒其他人的问题发表了有价值的答案。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-01-29
    • 2017-11-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-23
    • 2014-02-13
    相关资源
    最近更新 更多