适用于 Playbook 的基于 HTML 的 Adob​​e Air 应用程序 - 无法读取“SQLConnection”的属性未定义的

发布于 2024-10-27 20:11:23 字数 2860 浏览 4 评论 0原文

我在让基于 HTML 的 Adob​​e Air 应用程序正确运行时遇到一些实际问题。我一直在 Aptana 中开发它,并通过那里执行它是一种享受 - 没有任何错误。当我尝试通过 Chrome、Firefox(或者最重要的)BlackBerry Playbook 模拟器运行相同的文件时,就会出现问题。 当我尝试在任何这些环境中运行我的应用程序时,jquery 看起来好像没有运行。如果我使用 Chrome 检查元素并查看 .js 文件,则会出现两个错误 - “Uncaught TypeError - 无法读取未定义的属性‘SQLConnection’”和“Uncaught TypeError - 无法读取未定义的属性‘File’。

任何知道什么通常会导致这些错误吗? HTML 文件是:

<html>
<head>
    <title>Application Sandbox sample</title>
    <link href="css/styles.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" src="lib/jquery/jquery-1.5.js"></script>
    <script src="lib/air/AIRAliases.js" type="text/javascript"></script>
</head>

<body>
    <div id="container">
        <div id="topBar">
                <h2 class="tripbar_title">Tripbook logo</h2>
                <h2 class="tripbar_subtitle">Travel Tracking Made Simple</h2>
        </div>
        <div id="content">
            <div id="main">
                <ul id="navigation">
                    <a href="pages/menu.html" class="log_on_link"><li class="log_on_text">Log-on as <b class="first_name_text">First_Name</b> <b class="last_name_text">Last_Name</b> of <b class="company_name_text">Company_Name</b></li></a>
                    <a href="pages/register.html" class="register_link"><li class="register_link_text">Register a new user</li></a>
                    <a href="pages/switch_user.html" class="switch_user_link"><li class="switch_user_link_text">Switch Users</li></a>
                    <a href="pages/company.html" class="switch_employer_link"><li class="switch_employer_link_text">Switch Job</li></a>
                </ul>
            </div>
        </div>
        <div id="footer">
        </div>
    </div>
    <script type="text/javascript" src="lib/welcome.js"></script>
  </body>
</html>

并且 javascript 文件(welcome.js)开始:

// Bootstrap
$(document).ready(function(){
    SetupDB();
    displayMenu();
    SuggestUser();
});

var log_in_first;
var log_in_last;
var log_in_company; 
var db = new air.SQLConnection(); 


function SetupDB(){

    var dbFile = air.File.applicationStorageDirectory.resolvePath("tripbook_base.db"); 
    if (!dbFile.exists) { //
        var dbTemplate = air.File.applicationDirectory.resolvePath("tripbook_base.db");
        dbTemplate.copyTo(dbFile, true);
        }  //
        try {
            db.open(dbFile);
        } 
        catch (error) {
            air.trace("DB error:", error.message);
            air.trace("Details:", error.details);
        }
}

I'm having some real problems getting a HTML-based Adobe Air application to run correctly. I've been developing it in Aptana, and executing it through there is working a treat - no errors whatsoever. The problem occurs when I try to run the same file through Chrome, Firefox (or most importantly) the BlackBerry Playbook simulator.
When I try to run my app in any of these environments, it looks as though the jquery isn't running. If I use Chrome to inspect element and view the .js file, it is coming up with two errors - "Uncaught TypeError - Cannot read property 'SQLConnection' of undefined" and "Uncaught TypeError - Cannot read property 'File' of undefined.

Any idea what normally causes these errors? The HTML file is:

<html>
<head>
    <title>Application Sandbox sample</title>
    <link href="css/styles.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" src="lib/jquery/jquery-1.5.js"></script>
    <script src="lib/air/AIRAliases.js" type="text/javascript"></script>
</head>

<body>
    <div id="container">
        <div id="topBar">
                <h2 class="tripbar_title">Tripbook logo</h2>
                <h2 class="tripbar_subtitle">Travel Tracking Made Simple</h2>
        </div>
        <div id="content">
            <div id="main">
                <ul id="navigation">
                    <a href="pages/menu.html" class="log_on_link"><li class="log_on_text">Log-on as <b class="first_name_text">First_Name</b> <b class="last_name_text">Last_Name</b> of <b class="company_name_text">Company_Name</b></li></a>
                    <a href="pages/register.html" class="register_link"><li class="register_link_text">Register a new user</li></a>
                    <a href="pages/switch_user.html" class="switch_user_link"><li class="switch_user_link_text">Switch Users</li></a>
                    <a href="pages/company.html" class="switch_employer_link"><li class="switch_employer_link_text">Switch Job</li></a>
                </ul>
            </div>
        </div>
        <div id="footer">
        </div>
    </div>
    <script type="text/javascript" src="lib/welcome.js"></script>
  </body>
</html>

and the javascript file (welcome.js) starts:

// Bootstrap
$(document).ready(function(){
    SetupDB();
    displayMenu();
    SuggestUser();
});

var log_in_first;
var log_in_last;
var log_in_company; 
var db = new air.SQLConnection(); 


function SetupDB(){

    var dbFile = air.File.applicationStorageDirectory.resolvePath("tripbook_base.db"); 
    if (!dbFile.exists) { //
        var dbTemplate = air.File.applicationDirectory.resolvePath("tripbook_base.db");
        dbTemplate.copyTo(dbFile, true);
        }  //
        try {
            db.open(dbFile);
        } 
        catch (error) {
            air.trace("DB error:", error.message);
            air.trace("Details:", error.details);
        }
}

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

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

发布评论

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

评论(1

一抹微笑 2024-11-03 20:11:23

符号“空气”没有定义。因此声明:

var db = new air.SQLConnection(); 

行不通。我不知道“AIRAliases.js”文件是什么,但如果您希望它为您定义符号“air”,那么它显然不起作用。

编辑 - 好的谷歌搜索“AIRAliases.js”表明它包含一些Air设施的“方便”重命名。因此,这可能不是直接问题。我怀疑问题在于您尝试将 HTML 和 JavaScript 直接加载到浏览器中,期望它能够使用在 Air 中使用的功能。不可以。

The symbol "air" is not defined. Therefore the statement:

var db = new air.SQLConnection(); 

will not work. I don't know what that "AIRAliases.js" file is, but if you expect it to define the symbol "air" for you, it apparently isn't working.

edit — ok googling for "AIRAliases.js" indicates that it contains some "convenience" renaming of some Air facilities. Thus it's probably not the direct problem. I suspect the issue is that you're trying to load your HTML and JavaScript directly into a browser, expecting it to be able to use the facilities that it uses in Air. It can't.

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