13.08.2012 Views

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>ACTIONSCRIPT</strong> 3.0 DEVELOPER’S GUIDE<br />

Working with local SQL databases in AIR<br />

}<br />

conn.op<strong>en</strong>Async(dbFile, SQLMode.CREATE, null, false, 1024, <strong>en</strong>cryptionKey);<br />

private function op<strong>en</strong>Handler(ev<strong>en</strong>t:SQLEv<strong>en</strong>t):void<br />

{<br />

conn.removeEv<strong>en</strong>tList<strong>en</strong>er(SQLEv<strong>en</strong>t.OPEN, op<strong>en</strong>Handler);<br />

conn.removeEv<strong>en</strong>tList<strong>en</strong>er(SQLErrorEv<strong>en</strong>t.ERROR, op<strong>en</strong>Error);<br />

}<br />

statusMsg.setStyle("color", 0x009900);<br />

if (createNewDB)<br />

{<br />

statusMsg.text = "The <strong>en</strong>crypted database was created successfully.";<br />

}<br />

else<br />

{<br />

statusMsg.text = "The <strong>en</strong>crypted database was op<strong>en</strong>ed successfully.";<br />

}<br />

private function op<strong>en</strong>Error(ev<strong>en</strong>t:SQLErrorEv<strong>en</strong>t):void<br />

{<br />

conn.removeEv<strong>en</strong>tList<strong>en</strong>er(SQLEv<strong>en</strong>t.OPEN, op<strong>en</strong>Handler);<br />

conn.removeEv<strong>en</strong>tList<strong>en</strong>er(SQLErrorEv<strong>en</strong>t.ERROR, op<strong>en</strong>Error);<br />

if (!createNewDB && ev<strong>en</strong>t.error.errorID ==<br />

EncryptionKeyG<strong>en</strong>erator.ENCRYPTED_DB_PASSWORD_ERROR_ID)<br />

{<br />

statusMsg.text = "Incorrect password!";<br />

}<br />

else<br />

{<br />

statusMsg.text = "Error creating or op<strong>en</strong>ing database.";<br />

}<br />

}<br />

]]><br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

Flash Professional example<br />

The application FLA file contains the source code for a simple application that creates or op<strong>en</strong>s a connection to an<br />

<strong>en</strong>crypted database. The FLA file has four compon<strong>en</strong>ts placed on the stage:<br />

Last updated 6/6/2012<br />

766

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!