Flex:包是意外错误

时间:2010-05-20 14:58:50

标签: flex actionscript-3 air

import mx.controls.Alert;

package dbconfig // error line here
{
    public class DBConn
    {
        private var dbConn:SQLConnection;
        private var dbFile:File;

        public function DBConn()
        {
            this.openConnection(); 
        }

        public function openConnection(){
            dbFile = File.applicationStorageDirectory.resolvePath("accounting.sqlite");
            dbConn = new SQLConnection();

            try 
            {
                dbConn.open(dbFile);
                Alert.show("asdf");
            }
            catch(e:SQLError)
            {
                Alert.show("SQL Error Occured: ", e.message);
            }
        }
    }
}

3 个答案:

答案 0 :(得分:2)

您需要将导入放在包定义中:

package dbconfig
{
    import mx.controls.Alert;

    public class DBConn
    {
        private var dbConn:SQLConnection;
        private var dbFile:File;

        public function DBConn()
        {
            this.openConnection(); 
        }

        public function openConnection(){
            dbFile = File.applicationStorageDirectory.resolvePath("accounting.sqlite");
            dbConn = new SQLConnection();

            try 
            {
                dbConn.open(dbFile);
                Alert.show("asdf");
            }
            catch(e:SQLError)
            {
                Alert.show("SQL Error Occured: ", e.message);
            }
        }
    }
}

答案 1 :(得分:0)

是的,与Java不同,您必须导入所有要使用的类,即使您完全符合它们的要求。根据标签来判断我认为你知道这一点,但是SQLConnection和File只是Air,所以不能在普通的flash播放器中运行。

答案 2 :(得分:0)