开发者

Flex Syntax Error

I am getting Syntax Error 1202 (Access of undefined property connection in package model) in the following code while trying to access the model.connection property. I don't see any reason why this would appear, can anyone see something I may be overlooking?

开发者_开发知识库

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()
    {
    }
}

}

And the actual code in my default mxml file, init() is called on initialize

        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;
        }


The issue here is that you have a package and a variable named 'model'. When you try to access the variable named model, it thinks you are referring to the package. If you correct this naming collision, you will see that this issue is fixed.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜