SQL in Air

trace-flash

New Member
سلام
ما که یه بار پست دادیم کسی جواب نداد :)mad: :cry: )
اینجا دوستان تا به حال با قابلیتهای SQL در air کار کردن اگه کار کردن میشه یه توضیحی در مورد SQL بدن و اینکه میشه در این مورد البته به صورت فارسی چه برای SQL یا اون یکی پیدا کرد من خودم اصلا به SQL کار نکردم
خواهش میکنم کمک کنین
 

Avang2005

مدیر انجمن
سلام دوست من

خوب شما مي خواي چيكار كني با sql ؟؟؟

يه توضيحي در موردش ميدادي

موفق باشيد
 

trace-flash

New Member
با سلام
فکر کنم اشتباهی اومدی،نه؟

نه خیر دوست عزیز شما اشتباه گرفتین :sad:

نمیدونم شما قبلا برای کارهایی که با فلش داشتین و توی پروژه تون اگه دیتابیس داشتین از چی استفاده میکردین
من خودم برای برنامه های سیستمی (اونایی که تو browser کار نمیکردن از Zinc استفاده میکردم که با اکسس راحت بود) ولی توی ورژن جدید فلش 9 و 10 اومدن از SQL به عنوان پیش فرض استفاده میکنن :
این عکس رو ببینین تا باورتون بشه
sqlclass.jpg

من میخواستم بدونم کسی با این کلاسها کار کرده و میدونه SQL در اینجا مربوط به سروره یا میشه تحت desktop ازش استفاده کرد
تو رو خدا شوخی نکنین :)cry:)
 

trace-flash

New Member
سلام دوست من

خوب شما مي خواي چيكار كني با sql ؟؟؟

يه توضيحي در موردش ميدادي

موفق باشيد

البته اینو نگفتم میخوام چیکار کنم
راستیتش برای یکی از کارام که باید 3 الی 4 ماه دیگه تحویل بدم میخواستم (البته اگه نتونم با Zinc باید بدم )
 

arjmand200

Member
دوست عزیز اومدنت به این انجمن رو تبریک میگم اما راجب سوالتون ، من تازه خوب نفهمیدم که شما میخواین چیکار کنین من خودم از این قابلیت فلش و air استفاده نکردم چون فلش اصلا کلا با air مشکل داره و هنگام کامپایل پروژه قاطی میکنه، این گونه پروژه ها رو باید تو flex builder کار کنی چون خیلی مناسبه واسه این کارها اما اینکه تو این انجمن تا به حال چنین سوالی پرسیده شده باشه من زیاد مطمئن نیستم ولی اگه سایتهای خارجی (اونور ابی ) رو جستجو کنی به نتیجه میرسی اینم چند تا مثال :


البته صرفا با SQL نیست با SQLite میتونی کار کنی من یه کتاب خوبو واست معرفی میکنم که شخصا adobe air رو با این کتاب شروع کردم البته اینو بگم که امرجع فارسی واسه air نیست و باید از اجانب یاد بگیری :wink:


اینم کتا خوبیه که تازه اومده (ولی متاسفانه واسه فلشه که دلیلشو بالا عرض کردم )


(راستی اینقدر هم گریه نکن واسه چشمات ضرر داره ) شوخی کردم !:lol:
 
آخرین ویرایش:

apolon_021

Member
من خودم امتحان کردم بعد گزاشتم .
PHP:
stop();
//create a new sql connection
var conn:SQLConnection= new SQLConnection();
//add an event handeler for the open event
conn.addEventListener(SQLEvent.OPEN, openHandler);
//create the database if it doesn't exist, otherwise just opens it
var dbFile:File =File.applicationDirectory.resolvePath ("exemplu.db");
conn.openAsync(dbFile);

p2-230x125.jpg


PHP:
Now add a new function that creates a table in the database. To do so, write the following code in the first frame of your application:
function openHandler(event:SQLEvent):void {
//create a new sql statement
var sql:SQLStatement=new SQLStatement();
//set the statement to connect to our database
sql.sqlConnection=conn;
//parse the sql command that creates the table if it doesn't exist
sql.text= "CREATE TABLE IF NOT EXISTS contacte(" +
"id INTEGER PRIMARY KEY AUTOINCREMENT, " +
"nume TEXT, " +
"telefon INTEGER)";
//add a new event listener to the sql when it completes creating the table
sql.addEventListener(SQLEvent.RESULT,retrieveData);
//call the execute function to execute our statement
sql.execute();
}

p3-230x147.jpg


PHP:
The next step is to create the function that retrieves the data from the table in the database. Just write the following code in the first frame of your application:
function retrieveData(event:SQLEvent = null):void {
//create a new sql statemant
var sql:SQLStatement = new SQLStatement();
sql.sqlConnection=conn;
//this sql command retrieves all the fields from our
//table in the database and orders it by name
sql.text =  "SELECT id, nume, " +
"telefon " +
"FROM contacte ORDER BY nume";
//add a new event listener if there is data
//to display it
sql.addEventListener(SQLEvent.RESULT, selectHandler);
sql.execute();
}
p4-230x177.jpg


PHP:
Now it is time to create the function that shows the contacts in the list component. To create it just insert in the first frame of your file the following code:
function selectHandler(event:SQLEvent):void {
//first we clear our list
lister.removeAll();
//the we create a result variable that holds
//all our contacts
var result:SQLResult=event.target.getResult();
//we check if results is not empty
if (result!=null&&result.data!=null) {
//and we add a new item to our list for
//each contact in our database
for (var i:Number = 0; i < result.data.length; i++) {
lister.addItem ({ label:result.data[i].nume + "-" +result.data[i].telefon
, nr:result.data[i].id });
}
}
}

p5-230x145.jpg


PHP:
Now to add some code to our buttons :
plus.addEventListener(MouseEvent.CLICK,adder);
xu.addEventListener(MouseEvent.CLICK,closeapp);
back.addEventListener(MouseEvent.MOUSE_DOWN,drag);
//because my buttons are not real buttons
//but movieclips i need to set the
//buttonMode property to true
plus.buttonMode=true;
xu.buttonMode=true;
function adder(e:MouseEvent):void{
//remove the eventlistener and move to the
//next frame
plus.removeEventListener(MouseEvent.CLICK,adder);
nextFrame();
}
function closeapp(e:MouseEvent):void {
//close the application
NativeApplication.nativeApplication.exit();
}
function drag(e:MouseEvent):void {
//drag the application
this.stage.nativeWindow.startMove();
}

PHP:
You’ve finished the first frame, it’s time to go to the second frame where we add the contacts. Start by adding the next code:
//this line restricts the user input
//to just numbers in the phone input box
tel.restrict="0-9";
//add a new event listener to our plus button
plus.addEventListener(MouseEvent.CLICK,adder2);

PHP:
Now create the final function that adds a new contact in the database:
function adder2(e:MouseEvent):void {
//create a new sql statement variable
var sql:SQLStatement=new SQLStatement();
sql.sqlConnection=conn;
//the next sql command creates a new entry
//in the table contacte from our database
sql.text =  "INSERT INTO contacte(nume, " +
"telefon)" +
"VALUES(@nume, " +
"@telefon)";
//to insert variables into sql commnads
//we use the parameters definition
sql.parameters["@nume"]=nume.text;
sql.parameters["@telefon"]=tel.text;
//add a new event listener that calls the
//function that retrieves the data
sql.addEventListener(SQLEvent.RESULT,retrieveData);
sql.execute();
//go to frame no. 1
prevFrame();
//remove the eventlistener from our plus button
plus.removeEventListener(MouseEvent.CLICK,adder2);
}
 
آخرین ویرایش:

جدیدترین ارسال ها

بالا