<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Blog d'un développeur multi-support &#187; air</title>
	<atom:link href="http://www.oni-ecchi.info/blog/tag/air/feed" rel="self" type="application/rss+xml" />
	<link>http://www.oni-ecchi.info/blog</link>
	<description>[DIM] pour les intimes :)</description>
	<lastBuildDate>Fri, 18 Jun 2010 06:27:38 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>SQlite &amp; Air</title>
		<link>http://www.oni-ecchi.info/blog/decouverte-flex-flash/sqlite-air.html</link>
		<comments>http://www.oni-ecchi.info/blog/decouverte-flex-flash/sqlite-air.html#comments</comments>
		<pubDate>Mon, 02 Feb 2009 07:00:52 +0000</pubDate>
		<dc:creator>Guillaume chave</dc:creator>
				<category><![CDATA[Flex Flash Floush]]></category>
		<category><![CDATA[air]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[tutoriel]]></category>

		<guid isPermaLink="false">http://www.oni-ecchi.info/blog/?p=215</guid>
		<description><![CDATA[Un peu d&#8217;ça fait pas de mal non ?
Je fais que peu de back admin en ce moment &#8230; j&#8217;écrit quasi pas de requêtes .. vive les ORM (object-relational mapping) .. et j&#8217;occupe mon temps libre à /Flash et mon application de suivi de stats sportives.
Je suis en train d&#8217;écrire une nouvelle version de mon [...]]]></description>
			<content:encoded><![CDATA[<p>Un peu d&#8217;<a class="shal" href=" http://www.oni-ecchi.info/blog/sql/ape-project-mysql.html" title=" APE Project - Mysql">SQL </a>ça fait pas de mal non ?</p>
<p>Je fais que peu de back admin en ce moment &#8230; j&#8217;écrit quasi pas de requêtes .. vive les <a rel="nofollow" href="http://fr.wikipedia.org/wiki/ORM" target="_blank">ORM </a>(<strong>object-relational mapping</strong>) .. et j&#8217;occupe mon temps libre à <a class="shal" href=" http://www.oni-ecchi.info/blog/decouverte-flex-flash/flex-cest-cool.html" title=" Flex c'est cool">Flex</a>/Flash et mon application de suivi de stats sportives.</p>
<p>Je suis en train d&#8217;écrire une nouvelle version de mon application, avec un code plus propre, et surtout multi utilisateur afin que chacun inscrive ses statistiques sportives dans la même application. Je pourrais m&#8217;en sortir en utilisant à mort les <a rel="nofollow" href="http://www.flex-tutorial.fr/category/httpservice/" target="_blank">HTTPService</a>, faire un webservice et site dédié à la cause.. mais bon je n&#8217;ai pas vocation (pour l&#8217;instant) de créer un site pour se montrer le nombril &#8230; et imaginer le nombre de requêtes à traiter &#8230;</p>
<p>En sachant que Air embarque nativement un moteur <a rel="nofollow" href="http://www.sqlite.org/" target="_blank">SQLite</a>, pourquoi ne pas garder sur le poste du client toutes ses stats ? Quitte à faire par la suite un bouton &laquo;&nbsp;synchroniser sur le web&nbsp;&raquo; :) Ca peut le faire non ?</p>
<p><span id="more-215"></span></p>
<h3>I ) Easy mode</h3>
<p>Voyons voir, tapons &laquo;&nbsp;air sqlite&nbsp;&raquo; dans google et regardons un peu l&#8217;existant</p>
<ul>
<li>Rien ne vaut les exemples adobe : <a rel="nofollow" href="http://www.adobe.com/devnet/air/flex/quickstart/simple_sql_database.html" target="_blank">http://www.adobe.com/devnet/air/flex/quickstart/simple_sql_database.html</a></li>
<li>Mais bon, en francais c&#8217;est mieux : <a rel="nofollow" href="http://www.progs.fr/air-sqlite-exemple   " target="_blank">http://www.progs.fr/air-sqlite-exemple</a></li>
</ul>
<p>On se rend compte que le principe est assez simple au final :</p>
<ol>
<li>Je crée un fichier from scratch via la classe File</li>
<li>Je l&#8217;ouvre à travers une SQLConnection</li>
<li>Je crée un SQLStatement à partir de mon objet SQLConnection</li>
<li>J&#8217;exécute ma requête pour obtenir un SQLResult et j&#8217;en extrait les données sous forme de tableau</li>
<li>Simple non ?</li>
</ol>
<p>Mais bon, même si c&#8217;est l&#8217;affaire d&#8217;une quinzaine de ligne, c&#8217;est quand même un peu relou de tout faut tout se retapper à chaque requete .. autant avoir une classe bien sympa qui gère la BDD dans son coin non ?</p>
<h3>II ) Moi, j&#8217;ai la classe</h3>
<p>J&#8217;aime découper mes applications en MVC quand je le peux. Une classe qui gère ma BDD et qui centralise les appels, c&#8217;est cool. On appelle ça le &laquo;&nbsp;Model&nbsp;&raquo; :) Voici, sans prétention, ma chtite classe qui va bien :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p215code5'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2155"><td class="line_numbers"><pre>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
81
82
83
84
85
86
87
88
89
</pre></td><td class="code" id="p215code5"><pre class="actionscript" style="font-family:monospace;">package bdd
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> flash.<span style="color: #0066CC;">data</span>.<span style="color: #006600;">SQLConnection</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #0066CC;">data</span>.<span style="color: #006600;">SQLResult</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #0066CC;">data</span>.<span style="color: #006600;">SQLStatement</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">filesystem</span>.<span style="color: #006600;">File</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MySqlLite <span style="color: #0066CC;">extends</span> SQLConnection
	<span style="color: #66cc66;">&#123;</span>
		protected <span style="color: #000000; font-weight: bold;">var</span> fichier:File;
&nbsp;
		<span style="color: #808080; font-style: italic;">// Pattern Singleton c'est mieux.</span>
		<span style="color: #0066CC;">private</span> <span style="color: #0066CC;">static</span> <span style="color: #000000; font-weight: bold;">var</span> instance:MySqlLite
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> MySqlLite<span style="color: #66cc66;">&#40;</span>access:Singleton<span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">super</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
			<span style="color: #808080; font-style: italic;">// Initilisation de la base. Création des tables si besoin est.</span>
			init<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #808080; font-style: italic;">// Implémentation du singleton.</span>
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> <span style="color: #000000; font-weight: bold;">function</span> getInstance<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:MySqlLite<span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>instance == <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
				instance = <span style="color: #000000; font-weight: bold;">new</span> MySqlLite<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Singleton<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #66cc66;">&#125;</span>
			<span style="color: #b1b100;">return</span> instance;
		<span style="color: #66cc66;">&#125;</span>		
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> init<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #808080; font-style: italic;">// Autant se créer notre fichier BDD dans le répertoire d'installation de notre Application non ?</span>
			fichier = <span style="color: #000000; font-weight: bold;">new</span> File<span style="color: #66cc66;">&#40;</span>File.<span style="color: #006600;">applicationDirectory</span>.<span style="color: #006600;">nativePath</span> + <span style="color: #ff0000;">&quot;/Sports2009-bdd.bd&quot;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
			<span style="color: #808080; font-style: italic;">// Si le fichier n'existe pas déjà, on crée nos tables !</span>
			<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">!</span>fichier.<span style="color: #006600;">exists</span><span style="color: #66cc66;">&#41;</span>
			<span style="color: #66cc66;">&#123;</span>
				<span style="color: #0066CC;">this</span>.<span style="color: #006600;">open</span><span style="color: #66cc66;">&#40;</span>fichier<span style="color: #66cc66;">&#41;</span>;
				<span style="color: #000000; font-weight: bold;">var</span> stmt:SQLStatement = <span style="color: #000000; font-weight: bold;">new</span> SQLStatement<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
				stmt.<span style="color: #006600;">sqlConnection</span> = <span style="color: #0066CC;">this</span>;
				stmt.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">&quot;CREATE TABLE performances (id INTEGER PRIMARY KEY AUTOINCREMENT, creation_date DateTime, calorie decimal, kilometre decimal, temps decimal)&quot;</span>;
				<span style="color: #808080; font-style: italic;">// Hop insertion de notre 1er table</span>
				stmt.<span style="color: #006600;">execute</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;	
&nbsp;
				<span style="color: #808080; font-style: italic;">// Notre Statement est chaud bouillant pour créer une deuxième table, soyons fou.</span>
				stmt.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">&quot;CREATE TABLE utilisateur (id INTEGER PRIMARY KEY AUTOINCREMENT, nom longvarchar, password longvarchar)&quot;</span>;
				stmt.<span style="color: #006600;">execute</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #66cc66;">&#125;</span>
			<span style="color: #b1b100;">else</span>
			<span style="color: #66cc66;">&#123;</span>
				<span style="color: #808080; font-style: italic;">// Le fichier existe, on ouvre notre bdd :)</span>
				<span style="color: #0066CC;">this</span>.<span style="color: #006600;">open</span><span style="color: #66cc66;">&#40;</span>fichier<span style="color: #66cc66;">&#41;</span>;
			<span style="color: #66cc66;">&#125;</span>
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #808080; font-style: italic;">// On peut explicitement fermer la bdd ..</span>
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> fermer<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">close</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #808080; font-style: italic;">// Exécutons notre requete SQL et retournons le résultat :)</span>
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> requete<span style="color: #66cc66;">&#40;</span>maRequeteSql:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:SQLResult
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">var</span> requete:SQLStatement = <span style="color: #000000; font-weight: bold;">new</span> SQLStatement<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			requete.<span style="color: #006600;">sqlConnection</span> =<span style="color: #0066CC;">this</span>;
			requete.<span style="color: #0066CC;">text</span> = maRequeteSql
			requete.<span style="color: #006600;">execute</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
			<span style="color: #808080; font-style: italic;">// On récupère le résultat de l'execution</span>
			<span style="color: #000000; font-weight: bold;">var</span> r:SQLResult = <span style="color: #000000; font-weight: bold;">new</span> SQLResult<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>		
&nbsp;
			<span style="color: #808080; font-style: italic;">// ATTENTION on ne peut faire qu'un seul getResult()</span>
			<span style="color: #808080; font-style: italic;">// Pourquoi ? car c'est à usage unique</span>
			<span style="color: #808080; font-style: italic;">// une fois que l'on a demandé des infos &quot;pssshhtt ça disparait !&quot;</span>
			r =  requete.<span style="color: #006600;">getResult</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #b1b100;">return</span> r;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> Singleton<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Singleton<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
	<span style="color: #66cc66;">&#123;</span>
&nbsp;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<h3>Utilisation</h3>
<p>Pour la gestion de mes utilisateurs par exemple, voici ma classe &laquo;&nbsp;Utilisateur&nbsp;&raquo; (Waahou je suis original) qui me sert à l&#8217;insertion et la connexion, etc d&#8217;un de mes gugus. Elle est vraiment basique, mais ça marche ;)</p>
<p>On reste encore dans le &laquo;&nbsp;Model&nbsp;&raquo; :)</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p215code6'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2156"><td class="line_numbers"><pre>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
</pre></td><td class="code" id="p215code6"><pre class="actionscript" style="font-family:monospace;">package users
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> bdd.<span style="color: #006600;">MySqlLite</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #0066CC;">data</span>.<span style="color: #006600;">SQLResult</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #0066CC;">data</span>.<span style="color: #006600;">SQLStatement</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Utilisateur <span style="color: #0066CC;">extends</span> <span style="color: #0066CC;">Object</span>
	<span style="color: #66cc66;">&#123;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">name</span>:<span style="color: #0066CC;">String</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">password</span>:<span style="color: #0066CC;">String</span>;
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Utilisateur<span style="color: #66cc66;">&#40;</span>nom:<span style="color: #0066CC;">String</span>,pass:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">super</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #0066CC;">this</span>.<span style="color: #006600;">setName</span><span style="color: #66cc66;">&#40;</span>nom<span style="color: #66cc66;">&#41;</span>;
			<span style="color: #0066CC;">this</span>.<span style="color: #006600;">setPassword</span><span style="color: #66cc66;">&#40;</span>pass<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getName<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">name</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getPassword<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">password</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> setName<span style="color: #66cc66;">&#40;</span>nom:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">name</span>= nom;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> setPassword<span style="color: #66cc66;">&#40;</span>pass:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">password</span> = pass;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #808080; font-style: italic;">// Test voir si le gugus existe</span>
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> existe<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Boolean</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">var</span> test:SQLResult = <span style="color: #000000; font-weight: bold;">new</span> SQLResult<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			test = MySqlLite.<span style="color: #006600;">getInstance</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">requete</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;SELECT * from utilisateur WHERE nom='&quot;</span> + <span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">name</span> +<span style="color: #ff0000;">&quot;' and password='&quot;</span> + <span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">password</span> +<span style="color: #ff0000;">&quot;' &quot;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #b1b100;">return</span> test.<span style="color: #0066CC;">data</span> <span style="color: #66cc66;">!</span>= <span style="color: #000000; font-weight: bold;">null</span>
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #808080; font-style: italic;">// Inscription du gugus</span>
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> inscription<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Boolean</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">!</span>existe<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
			<span style="color: #66cc66;">&#123;</span>
				<span style="color: #000000; font-weight: bold;">var</span> test:SQLResult = <span style="color: #000000; font-weight: bold;">new</span> SQLResult<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
				test = MySqlLite.<span style="color: #006600;">getInstance</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">requete</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;INSERT INTO utilisateur (nom,password) VALUES ('&quot;</span> + <span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">name</span> +<span style="color: #ff0000;">&quot;','&quot;</span> + <span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">password</span> +<span style="color: #ff0000;">&quot;') &quot;</span><span style="color: #66cc66;">&#41;</span>;
				<span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">true</span>;
			<span style="color: #66cc66;">&#125;</span>
			<span style="color: #b1b100;">else</span>
			<span style="color: #66cc66;">&#123;</span>
				<span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">false</span>;
			<span style="color: #66cc66;">&#125;</span>
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>Et le petit contrôleur qui va bien, extrait de mon code :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p215code7'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2157"><td class="line_numbers"><pre>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
</pre></td><td class="code" id="p215code7"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> TestConnexion<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:ConnexionEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">var</span> user:Utilisateur = <span style="color: #000000; font-weight: bold;">new</span> Utilisateur<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #006600;">sLogin</span>,<span style="color: #0066CC;">e</span>.<span style="color: #006600;">sPassword</span><span style="color: #66cc66;">&#41;</span>
	<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>user.<span style="color: #006600;">existe</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
	<span style="color: #66cc66;">&#123;</span>
		pannelConnexion.<span style="color: #006600;">currentState</span> = <span style="color: #ff0000;">&quot;OK&quot;</span>
		<span style="color: #0066CC;">this</span>.<span style="color: #006600;">currentState</span> = <span style="color: #ff0000;">&quot;Dashboard&quot;</span>;
	<span style="color: #66cc66;">&#125;</span>
	<span style="color: #b1b100;">else</span>
	<span style="color: #66cc66;">&#123;</span>
		pannelConnexion.<span style="color: #006600;">currentState</span> = <span style="color: #ff0000;">&quot;Erreur&quot;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Inscription<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:ConnexionEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">var</span> user:Utilisateur = <span style="color: #000000; font-weight: bold;">new</span> Utilisateur<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #006600;">sLogin</span>,<span style="color: #0066CC;">e</span>.<span style="color: #006600;">sPassword</span><span style="color: #66cc66;">&#41;</span>
	<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>user.<span style="color: #006600;">inscription</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;je me suis bien inscrit&quot;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
	<span style="color: #b1b100;">else</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;j'existe déjà ...&quot;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>Vous notez que j&#8217;ai un évènement personnalisé qui contient le login &amp; le password à tester. Voici son code pour ceux que ça intéresse, y a rien de spécial, c&#8217;est tout basique :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p215code8'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2158"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code" id="p215code8"><pre class="actionscript" style="font-family:monospace;">package Event
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">Event</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ConnexionEvent <span style="color: #0066CC;">extends</span> Event
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> sLogin:<span style="color: #0066CC;">String</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> sPassword:<span style="color: #0066CC;">String</span>;
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> ConnexionEvent<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">type</span>:<span style="color: #0066CC;">String</span>,login:<span style="color: #0066CC;">String</span>,<span style="color: #0066CC;">password</span>:<span style="color: #0066CC;">String</span>, bubbles:<span style="color: #0066CC;">Boolean</span>=<span style="color: #000000; font-weight: bold;">false</span>, cancelable:<span style="color: #0066CC;">Boolean</span>=<span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">super</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">type</span>, bubbles, cancelable<span style="color: #66cc66;">&#41;</span>;
			sLogin = login;
			sPassword = <span style="color: #0066CC;">password</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>Voilà, vous avez là un exemple très simpliste d&#8217;utilisation de SQLite dans Air. Pour tout dire, je ne suis pas encore aller très loin avec :)</p>
<p>A vous de jouer !</p>
]]></content:encoded>
			<wfw:commentRss>http://www.oni-ecchi.info/blog/decouverte-flex-flash/sqlite-air.html/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Flex c&#8217;est cool</title>
		<link>http://www.oni-ecchi.info/blog/decouverte-flex-flash/flex-cest-cool.html</link>
		<comments>http://www.oni-ecchi.info/blog/decouverte-flex-flash/flex-cest-cool.html#comments</comments>
		<pubDate>Tue, 06 Jan 2009 10:17:57 +0000</pubDate>
		<dc:creator>Guillaume chave</dc:creator>
				<category><![CDATA[Flex Flash Floush]]></category>
		<category><![CDATA[3615 ma vie]]></category>
		<category><![CDATA[air]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[moi]]></category>

		<guid isPermaLink="false">http://www.oni-ecchi.info/blog/?p=122</guid>
		<description><![CDATA[Ouaip avec le rameur que j&#8217;ai eu ce noel, j&#8217;en fais des flex&#8230; Bon passons ce jeux de mot pourri. En fait je me suis remis à Flex et plus particulierement à air ce week end en vue de prendre un peu d&#8217;avance sur le cours gobelins que j&#8217;allais avoir.
L&#8217;idée était de créer une application [...]]]></description>
			<content:encoded><![CDATA[<p>Ouaip avec le rameur que j&#8217;ai eu ce noel, j&#8217;en fais des flex&#8230; Bon passons ce jeux de mot pourri. En fait je me suis remis à Flex et plus particulierement à air ce week end en vue de prendre un peu d&#8217;avance sur le cours gobelins que j&#8217;allais avoir.</p>
<p>L&#8217;idée était de créer une application toute simple qui me permette de suivre l&#8217;évolution de mon entrainement au rameur. Donc en gros, affichage de graphique, modification d&#8217;un XML via datagrid puis passage à PHP pour la manipulation de l&#8217;XML..</p>
<p>Vous pouvez la tester via <a href="http://oni-ecchi.info/labo/TrainingFlex/" target="_blank">http://oni-ecchi.info/labo/TrainingFlex/</a> et c&#8217;est app2.air qu&#8217;il vous faudra installer.</p>
<p>Au final, j&#8217;ai utilisé ces adresses internet <a href="http://delicious.com/onishinji/flex" target="_blank">http://delicious.com/onishinji/flex</a> et le dvd de video2brain de Flex par Herve Girolet (mon ancien prof de Flash à l&#8217;IUT).</p>
<p>Je reviendrais peut etre plus en détail sur cette réalisation vu qu&#8217;actuellement le code source est moche :)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.oni-ecchi.info/blog/decouverte-flex-flash/flex-cest-cool.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
