1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
| <?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication
xmlns:TestSQL="*"
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:fl="http://code.google.com/p/flexlib/"
xmlns:views="com.views.*"
title="CalliMarco"
splashScreenImage="SplashScreen"
creationComplete="init()">
<!-- xmlns:com="components.*" -->
<fx:Script>
<![CDATA[
import flash.data.SQLStatement;
import flash.errors.SQLError;
import flash.events.Event;
import flash.events.SQLErrorEvent;
import flash.events.SQLEvent;
import flash.events.TimerEvent;
import flash.filesystem.File;
import flash.utils.ByteArray;
import flash.utils.Timer;
import mx.collections.ArrayCollection;
import mx.events.DropdownEvent;
// -- PROPERTIES ------------------------------------------------------------- /
private var dbFile:File;
private var conn:SQLConnection;
private var sqlFile:File;
public var CMDBAC:ArrayCollection;
// -- AUTO INIT FUNCTIONS --------------------------------------------------- /
private function init():void {
// Create a File Reference to the Included DB
dbFile = File.applicationDirectory.resolvePath( "CMDB.db" );
// Create SQL Connection
conn = new SQLConnection();
conn.openAsync( dbFile );
}
public function getCouleurs():void
{
trace('TOTO');
var sql:SQLStatement = new SQLStatement();
sql.sqlConnection = conn;
sql.text = "SELECT id_Couleurs as data, Couleur as label FROM Couleurs";
sql.addEventListener( SQLEvent.RESULT, resultHandler );
sql.addEventListener( SQLErrorEvent.ERROR, queryError );
sql.execute();
}
private function resultHandler( event:SQLEvent ):void {
var r:SQLResult = SQLStatement(event.currentTarget).getResult();
cb.dataProvider = r.data;
}
]]>
</fx:Script>
<mx:TextInput id="searchString" x="92" y="92" change="callQuery()" enabled="true"/>
<mx:ComboBox id="cb" initialize="getCouleurs()" width="150" />
</s:WindowedApplication> |
Partager