<?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; Flex Flash Floush</title>
	<atom:link href="http://www.oni-ecchi.info/blog/category/decouverte-flex-flash/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>phpFlickr &amp; Flex</title>
		<link>http://www.oni-ecchi.info/blog/decouverte-flex-flash/phpflickr-flex.html</link>
		<comments>http://www.oni-ecchi.info/blog/decouverte-flex-flash/phpflickr-flex.html#comments</comments>
		<pubDate>Fri, 30 Jan 2009 06:00:35 +0000</pubDate>
		<dc:creator>Guillaume chave</dc:creator>
				<category><![CDATA[Découverte PHP]]></category>
		<category><![CDATA[Flex Flash Floush]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[tutoriel]]></category>

		<guid isPermaLink="false">http://www.oni-ecchi.info/blog/?p=200</guid>
		<description><![CDATA[Pour un cours de , il nous avait été demandé de créer une application très simple constitué de deux écrans pour nous apprendre à manipuler les &#171;&#160;states&#160;&#187;, les composants personnalisés, le &#171;&#160;data binding&#160;&#187; etc.
Le sujet de l&#8217;application était d&#8217;afficher des images en fonction d&#8217;une ville &#8211; en vue de faire du data binding sur un [...]]]></description>
			<content:encoded><![CDATA[<p>Pour un cours de <a class="shal" href=" http://www.oni-ecchi.info/blog/decouverte-flex-flash/flex-et-numberformatter.html" title=" Découverte Flex : new NumberFormatter();">Flex</a>, il nous avait été demandé de créer une application très simple constitué de deux écrans pour nous apprendre à manipuler les &laquo;&nbsp;states&nbsp;&raquo;, les composants personnalisés, le &laquo;&nbsp;data binding&nbsp;&raquo; etc.</p>
<p>Le sujet de l&#8217;application était d&#8217;afficher des images en fonction d&#8217;une ville &#8211; en vue de faire du data binding sur un XML &laquo;&nbsp;statique&nbsp;&raquo; de villes &#8211; et de récupérer des images issues d&#8217;un XML dynamique via l&#8217;objet HTTPService.</p>
<p>Alors quitte à faire du dynamique, autant interroger directement un web service existant en vue de récupérer pleins d&#8217;images sans se prendre la tête. Et là j&#8217;ai pensé à FlickR et sa monstrueuse API. Après 5mn montre en main j&#8217;ai eu ma clé pour accèder à l&#8217;API et 4mn après je découvrait <a rel="nofollow" href="http://phpflickr.com/" target="_blank">phpFlickR</a>.</p>
<p>Upload de la librairie et voici mon bout de script qui me renvoit suivant deux paramètres en $_GET un joli XML près à être utilisé en Flex.</p>
<ul>
<li> $_GET['town'] est le terme rechercher dans l&#8217;api FlickR sur les tags et le text qui commente une photo.</li>
<li>$_GET['max'] est le nombre de photos qu&#8217;il faudra retourner.</li>
</ul>

<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('p200code11'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p20011"><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
</pre></td><td class="code" id="p200code11"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;phpFlickr.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$flickR</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> phpFlickr<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ta_cle_de_connection_flickR&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// 10 résultat par défaut ..</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'max'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000088;">$max</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'max'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">else</span> <span style="color: #000088;">$max</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$search</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;tags&quot;</span><span style="color: #339933;">=&gt;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'town'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'per_page'</span><span style="color: #339933;">=&gt;</span><span style="color: #000088;">$max</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;tag_mode&quot;</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">&quot;any&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'text'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'town'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$tab</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$flickR</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">photos_search</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$search</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// On renvoit un XML à Flex</span>
<a href="http://www.php.net/header"><span style="color: #990000;">header</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;content-type: application/xml&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// La balise qui va bien</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;?xml version=&quot;</span><span style="color:#800080;">1.0</span><span style="color: #0000ff;">&quot; encoding=&quot;</span>utf<span style="color: #339933;">-</span><span style="color: #cc66cc;">8</span><span style="color: #0000ff;">&quot; ?&gt;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">!=</span> <span style="color: #000088;">$max</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">// on s'assure d'avoir des photos valides</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$tab</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'photo'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'id'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">// Simple de créer des urls FlickR non ?</span>
	<span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$flickR</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">buildPhotoURL</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$tab</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'photo'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;thumbnail&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$link</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$flickR</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">buildPhotoURL</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$tab</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'photo'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;medium&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;image&gt;&lt;url&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$url</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;/url&gt;&lt;urlLarge&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$link</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;/urlLarge&gt;&lt;/image&gt;&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>La partie Flex est tout aussi simple, voici la partie essentielle qui nous intéresse :</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('p200code12'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p20012"><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
</pre></td><td class="code" id="p200code12"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&lt;</span>?<span style="color: #0066CC;">xml</span> <span style="color: #0066CC;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;</span>mx:Application xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> layout=<span style="color: #ff0000;">&quot;absolute&quot;</span> creationComplete=<span style="color: #ff0000;">&quot;searchPhoto('france',20)&quot;</span><span style="color: #66cc66;">&gt;</span>
&nbsp;
<span style="color: #66cc66;">&lt;</span>mx:Script<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;!</span><span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span>
<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">rpc</span>.<span style="color: #006600;">http</span>.<span style="color: #006600;">HTTPService</span>;
<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">rpc</span>.<span style="color: #006600;">events</span>.<span style="color: #006600;">ResultEvent</span>;
<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">collections</span>.<span style="color: #006600;">ArrayCollection</span>;
&nbsp;
<span style="color: #66cc66;">&#91;</span>Bindable<span style="color: #66cc66;">&#93;</span>
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> servicePhoto:ArrayCollection = <span style="color: #000000; font-weight: bold;">new</span> ArrayCollection<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; 
&nbsp;
&nbsp;
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> searchPhoto<span style="color: #66cc66;">&#40;</span>search:<span style="color: #0066CC;">String</span>,<span style="color: #0066CC;">max</span>:<span style="color: #0066CC;">int</span><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> modService:HTTPService = <span style="color: #000000; font-weight: bold;">new</span> HTTPService<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	modService.<span style="color: #006600;">method</span> = <span style="color: #ff0000;">&quot;get&quot;</span>;
	modService.<span style="color: #0066CC;">url</span> = <span style="color: #ff0000;">&quot;http://oni-ecchi.info/labo/FlexPhotos/service.php&quot;</span>;
&nbsp;
	<span style="color: #000000; font-weight: bold;">var</span> parameters:<span style="color: #0066CC;">Object</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Object</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	parameters.<span style="color: #006600;">town</span> = search;
	parameters.<span style="color: #0066CC;">max</span> = <span style="color: #0066CC;">max</span>;
	modService.<span style="color: #006600;">request</span> = parameters;                
	modService.<span style="color: #0066CC;">send</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	modService.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>ResultEvent.<span style="color: #006600;">RESULT</span>,onDataCharged<span style="color: #66cc66;">&#41;</span>;                
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> onDataCharged<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:ResultEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
	servicePhoto = <span style="color: #000000; font-weight: bold;">new</span> ArrayCollection<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	servicePhoto = <span style="color: #0066CC;">e</span>.<span style="color: #006600;">result</span>.<span style="color: #006600;">root</span>.<span style="color: #006600;">image</span> as ArrayCollection;		
	vignettes.<span style="color: #006600;">dataProvider</span> = <span style="color: #0066CC;">e</span>.<span style="color: #006600;">result</span>.<span style="color: #006600;">root</span>.<span style="color: #006600;">image</span> as ArrayCollection;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;/</span>mx:Script<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;</span>mx:TileList id=<span style="color: #ff0000;">&quot;vignettes&quot;</span> dataProvider=<span style="color: #ff0000;">&quot;{servicePhoto}&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;481&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;279&quot;</span> columnWidth=<span style="color: #ff0000;">&quot;110&quot;</span> rowHeight=<span style="color: #ff0000;">&quot;110&quot;</span> columnCount=<span style="color: #ff0000;">&quot;4&quot;</span> horizontalCenter=<span style="color: #ff0000;">&quot;0&quot;</span> paddingRight=<span style="color: #ff0000;">&quot;5&quot;</span> verticalCenter=<span style="color: #ff0000;">&quot;0&quot;</span><span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:itemRenderer<span style="color: #66cc66;">&gt;</span>
   		<span style="color: #66cc66;">&lt;</span>mx:Component<span style="color: #66cc66;">&gt;</span>
   			<span style="color: #66cc66;">&lt;</span>mx:Image  source=<span style="color: #ff0000;">&quot;{data.url}&quot;</span> verticalAlign=<span style="color: #ff0000;">&quot;middle&quot;</span> horizontalAlign=<span style="color: #ff0000;">&quot;center&quot;</span> <span style="color: #66cc66;">/&gt;</span>
   		<span style="color: #66cc66;">&lt;/</span>mx:Component<span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;/</span>mx:itemRenderer<span style="color: #66cc66;">&gt;</span>       
<span style="color: #66cc66;">&lt;/</span>mx:TileList<span style="color: #66cc66;">&gt;</span>
&nbsp;
&nbsp;
<span style="color: #66cc66;">&lt;/</span>mx:Application<span style="color: #66cc66;">&gt;</span></pre></td></tr></table></div>

<p>Ce n&#8217;est qu&#8217;un exemple très simple. Dans le fichier source qui va suivre, j&#8217;ai un peu plus travaillé la chose en utilisant un composant de chargement d&#8217;image sympathique, un spinner de chargement 2.0 et enfin la gestion des states (très simple).</p>
<ul>
<li><a href="/blog/wp-content/uploads/2009/01/FlexFlickR.zip" target="_blank">Mon Projet Flex (zip)<br />
</a></li>
<li><a href="http://oni-ecchi.info/labo/FlexPhotos/FlexFlickR.html" target="_blank">Le site d&#8217;exemple</a></li>
</ul>
<p>Voilà, c&#8217;est tout pour aujourd&#8217;hui</p>
]]></content:encoded>
			<wfw:commentRss>http://www.oni-ecchi.info/blog/decouverte-flex-flash/phpflickr-flex.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Découverte Flex : new NumberFormatter();</title>
		<link>http://www.oni-ecchi.info/blog/decouverte-flex-flash/flex-et-numberformatter.html</link>
		<comments>http://www.oni-ecchi.info/blog/decouverte-flex-flash/flex-et-numberformatter.html#comments</comments>
		<pubDate>Sat, 10 Jan 2009 17:57:44 +0000</pubDate>
		<dc:creator>Guillaume chave</dc:creator>
				<category><![CDATA[Flex Flash Floush]]></category>
		<category><![CDATA[astuce]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[numberFormatter]]></category>
		<category><![CDATA[tutoriel]]></category>

		<guid isPermaLink="false">http://www.oni-ecchi.info/blog/?p=127</guid>
		<description><![CDATA[Pour mon application AIR (cf le post juste en dessous) j&#8217;ai eu besoin d&#8217;arrondir mes statistiques à l&#8217;entier supérieur/inférieur et les mettre en forme pour ne garder que deux décimal après la virgule. N&#8217;étant pas du tout expert en Flash/Flex, j&#8217;ai commencé à faire un code de bourrin comme splitter mon float selon la virgule, [...]]]></description>
			<content:encoded><![CDATA[<p>Pour mon application AIR (cf le post juste en dessous) j&#8217;ai eu besoin d&#8217;arrondir mes statistiques à l&#8217;entier supérieur/inférieur et les mettre en forme pour ne garder que deux décimal après la virgule. N&#8217;étant pas du tout expert en Flash/Flex, j&#8217;ai commencé à faire un code de bourrin comme splitter mon float selon la virgule, slicer ensuite pour ne garder que deux décimal etc &#8230; Bref, un truc vraiment crade pour me dépanner vite fait.</p>
<p>Je suis revenu quelque jours après sur ce bout de code pour le cleaner un peu et pour trouver une solution vraiment propre et voici ma &laquo;&nbsp;découverte&nbsp;&raquo; : <strong>NumberFormatter </strong>! D&#8217;après une recherche google de 45s, il apparait que cette classe n&#8217;est disponible que pour Flex ..</p>
<p>Voici comment l&#8217;utiliser en AS3 seulement. Je n&#8217;ai pas pris le temps de l&#8217;essayer en MXML.</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('p127code14'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p12714"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="code" id="p127code14"><pre class="actionscript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">// L'objet magique</span>
<span style="color: #000000; font-weight: bold;">var</span> oFormat:NumberFormatter = <span style="color: #000000; font-weight: bold;">new</span> NumberFormatter<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// Arrondis à l'entier le plus proche</span>
oFormat.<span style="color: #006600;">rounding</span> = NumberBaseRoundType.<span style="color: #006600;">NEAREST</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// Et on l'utilise</span>
<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>oFormat.<span style="color: #006600;">format</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1.51</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// Affiche 2</span>
<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>oFormat.<span style="color: #006600;">format</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1.49</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// Affiche 1</span>
&nbsp;
<span style="color: #808080; font-style: italic;">// Précision à 2 décimal</span>
<span style="color: #808080; font-style: italic;">// D'abord on n'arrondis plus</span>
oFormat.<span style="color: #006600;">rounding</span> = NumberBaseRoundType.<span style="color: #006600;">NONE</span>;
<span style="color: #808080; font-style: italic;">// On définit le nb max de décimal</span>
oFormat.<span style="color: #006600;">precision</span> = <span style="color: #ff0000;">&quot;2&quot;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// Et on l'utilise</span>
<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>oFormat.<span style="color: #006600;">format</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1.544541511</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// Affiche 1.54</span>
<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>oFormat.<span style="color: #006600;">format</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1.1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// Affiche1.10 - note : rajout du 0 !</span></pre></td></tr></table></div>

<p>Et bien sur, rien ne vaut un coup d&#8217;oeil sur <a href="http://livedocs.adobe.com/flex/3/langref/index.html?mx/formatters/NumberFormatter.html&amp;mx/formatters/class-list.html" target="_blank">la documentation Adobe !</a><br />
Et voilà, c&#8217;est tout pour aujourd&#8217;hui.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.oni-ecchi.info/blog/decouverte-flex-flash/flex-et-numberformatter.html/feed</wfw:commentRss>
		<slash:comments>0</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>
