HTML-based Adobe Air Application for Playbook - Cannot read property of "SQLConnection" of undefined
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.copy开发者_JS百科To(dbFile, true);
} //
try {
db.open(dbFile);
}
catch (error) {
air.trace("DB error:", error.message);
air.trace("Details:", error.details);
}
}
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.
精彩评论