0
我在嘗試訪問model.connection屬性時出現以下代碼中的語法錯誤1202(訪問包模型中的未定義屬性連接)。我看不出爲什麼會出現這種情況,任何人都可以看到我可能忽略的某些內容?Flex語法錯誤
Model.as
package valueObjects
{
import flash.data.SQLConnection;
import mx.collections.ArrayCollection;
public class Model
{
public var connection:SQLConnection;
public var albums:ArrayCollection = new ArrayCollection();
public var albumItems:ArrayCollection = new ArrayCollection();
public var selectedAlbum:Number = 0;
public var selectedItem:Number = 0;
public function Model()
{
}
}
}
而且在我的默認MXML文件的實際代碼時,init()調用初始化
import model.ModelLocator;
import mx.core.mx_internal;
import valueObjects.Model;
protected var sqlConnection:SQLConnection;
private var model:Model = new Model();
protected function init():void
{
createDb();
navigator.firstViewData = model;
}
protected function createDb():void
{
sqlConnection = new SQLConnection();
sqlConnection.open(File.applicationStorageDirectory.resolvePath("Oxford.db"));
var stmt:SQLStatement = new SQLStatement();
stmt.sqlConnection = sqlConnection;
stmt.text =
"CREATE TABLE IF NOT EXISTS albumItems (" +
"id INTEGER PRIMARY KEY AUTOINCREMENT, " +
"album INTEGER, " +
"name STRING, " +
"dateAdded DATE)";
stmt.execute();
model.connection = sqlConnection;
}
您可以顯示在默認的mxml文件中創建模型的位置嗎? – dtuckernet
我的不好,編輯。 – korymiller