<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet title="XSL formatting" type="text/xsl" href="http://prendreuncafe.com/blog/feed/rss2/xslt" ?><rss version="2.0"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:wfw="http://wellformedweb.org/CommentAPI/"
  xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
  <title>Prendre un Café - actionscript</title>
  <link>http://prendreuncafe.com/blog/</link>
  <description></description>
  <language>fr</language>
  <pubDate>Wed, 14 May 2008 15:57:49 +0200</pubDate>
  <copyright>Contenus sous licence Creative Commons BY-SA</copyright>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Dotclear</generator>
  
    
  <item>
    <title>Présentation de Flex</title>
    <link>http://prendreuncafe.com/blog/post/2007/08/19/Presentation-de-Flex</link>
    <guid isPermaLink="false">urn:md5:da44566c457d577a024483072a70682e</guid>
    <pubDate>Sun, 19 Aug 2007 13:04:00 +0200</pubDate>
    <dc:creator>NiKo</dc:creator>
        <category>Dev</category>
        <category>actionscript</category><category>adobe</category><category>amfphp</category><category>bestpractices</category><category>flash</category><category>flex</category><category>framework</category><category>mxml</category><category>ria</category>    
    <description>    &lt;p&gt;Pour les besoins du boulot, j'ai du me mettre à &lt;a href=&quot;http://www.adobe.com/fr/products/flex/&quot; hreflang=&quot;fr&quot;&gt;Flex&lt;/a&gt;, le framework d'&lt;a href=&quot;http://adobe.fr&quot; hreflang=&quot;fr&quot;&gt;Adobe&lt;/a&gt; orienté &lt;a href=&quot;http://fr.wikipedia.org/wiki/Rich_Internet_Application&quot; hreflang=&quot;fr&quot;&gt;&lt;acronym title=&quot;Rich Internet application&quot;&gt;RIA&lt;/acronym&gt;&lt;/a&gt; en &lt;a href=&quot;http://fr.wikipedia.org/wiki/Format_Flash&quot; hreflang=&quot;fr&quot;&gt;Flash&lt;/a&gt;.&lt;/p&gt;


&lt;p&gt;Je pensais que mon passé de flasheur m'aiderait à monter rapidement en compétence sur cette techno, ben non : c'est tout à fait autre chose que ce que je connaissais de l'IDE traditionnel, dont je m'étais arrêté à la version 8. Avec Flex on a affaire à un framework complet de génération d'interfaces riches basées sur l'emploi de composants décrits et paramétrés en XML et de la dernière mouture du langage &lt;a href=&quot;http://fr.wikipedia.org/wiki/ActionScript&quot; hreflang=&quot;fr&quot;&gt;ActionScript&lt;/a&gt; en version 3. Quelques &lt;a href=&quot;http://flex.org/showcase/&quot; hreflang=&quot;en&quot;&gt;exemples d'applications réalisées avec Flex&lt;/a&gt; sont disponibles, et pour certaines, ça en jette carrément.&lt;/p&gt;


&lt;h3&gt;Le langage MXML&lt;/h3&gt;


&lt;p&gt;La description des interfaces s'opère au moyen du langage MXML&lt;sup&gt;[&lt;a href=&quot;http://prendreuncafe.com/blog/post/2007/08/19/#pnote-908-1&quot; id=&quot;rev-pnote-908-1&quot;&gt;1&lt;/a&gt;]&lt;/sup&gt;, basé sur XML un peu comme ce que proposent &lt;a href=&quot;http://xulfr.org/&quot; hreflang=&quot;fr&quot;&gt;XUL&lt;/a&gt; ou &lt;a href=&quot;http://www.xaml.fr/&quot; hreflang=&quot;fr&quot;&gt;XAML&lt;/a&gt; ou même &lt;a href=&quot;http://fr.wikipedia.org/wiki/XHTML&quot; hreflang=&quot;fr&quot;&gt;XHTML&lt;/a&gt; (qui reste une implémentation particulière et standardisée d'XML). Deux types principaux de composants sont disponibles : les &lt;strong&gt;conteneurs&lt;/strong&gt; (boîtes, panneaux, fenêtres, etc.) et les &lt;strong&gt;éléments de contrôle&lt;/strong&gt; (champs texte, listes, datagrids, tree, etc.)&lt;/p&gt;


&lt;p&gt;Le nombre de conteneurs et de contrôles est impressionnant, on se prend à rêver de la même richesse en HTML &lt;sup&gt;[&lt;a href=&quot;http://prendreuncafe.com/blog/post/2007/08/19/#pnote-908-2&quot; id=&quot;rev-pnote-908-2&quot;&gt;2&lt;/a&gt;]&lt;/sup&gt;. La plupart des composants sont visibles sur &lt;a href=&quot;http://examples.adobe.com/flex2/inproduct/sdk/explorer/explorer.html&quot; hreflang=&quot;en&quot;&gt;l'explorateur de composants Flex&lt;/a&gt;, sur le site d'Adobe. Et le meilleur reste sans doute à venir quand on voit le catalogue de composants supplémentaires open source comme ceux du projet &lt;a href=&quot;http://code.google.com/p/flexlib/&quot; hreflang=&quot;en&quot;&gt;FlexLib&lt;/a&gt;...&lt;/p&gt;


&lt;p&gt;Le format généré après compilation d'un ensemble de fichiers MXML constituant une application Flex est le &lt;a href=&quot;http://fr.wikipedia.org/wiki/SWF&quot; hreflang=&quot;fr&quot;&gt;SWF&lt;/a&gt;, le format natif d'Adobe Flash, lisible par tout bon &lt;a href=&quot;http://www.adobe.com/fr/products/flashplayer/&quot; hreflang=&quot;fr&quot;&gt;Flash Player 9&lt;/a&gt; qui se respecte, implanté sur plus de 80% du parc machines desktop mondial &lt;a href=&quot;http://www.adobe.com/products/player_census/flashplayer/version_penetration.html&quot; hreflang=&quot;en&quot;&gt;d'après les dernières statistiques disponibles sur le site d'Adobe&lt;/a&gt;.&lt;/p&gt;


&lt;p&gt;Voila un exemple de code MXML décrivant l'interface d'une application simpliste :&lt;/p&gt;

&lt;pre class=&quot;xml&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;?xml&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;version&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;1.0&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;encoding&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;utf-8&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;mx&lt;/span&gt;:Application xmlns:&lt;span style=&quot;color: #000066;&quot;&gt;mx&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://www.adobe.com/2006/mxml&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;layout&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;absolute&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
   &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;mx&lt;/span&gt;:Panel &lt;span style=&quot;color: #000066;&quot;&gt;title&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Dire bonjour&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;x&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;10&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;y&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;10&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;layout&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;absolute&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;width&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;303&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;mx&lt;/span&gt;:TextInput &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;firstname&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;x&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;10&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;y&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;10&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;mx&lt;/span&gt;:Button &lt;span style=&quot;color: #000066;&quot;&gt;label&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Dire bonjour&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;click&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;result.text='Bonjour, '+firstname.text&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;x&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;178&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;y&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;10&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;mx&lt;/span&gt;:Label &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;result&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;x&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;10&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;y&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;40&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;width&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;265&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;
   &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/mx&lt;/span&gt;:Panel&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/mx&lt;/span&gt;:Application&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Le code est assez parlant, mais voici quelques éléments significatifs :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Le conteneur principal de l'application déclare l'espace de noms &lt;code&gt;mx&lt;/code&gt;, ce qui nous permettra d'utiliser les composants natifs de Flex&lt;/li&gt;
&lt;li&gt;L'application déclare un conteneur sous la forme d'un &lt;code&gt;Panel&lt;/code&gt; contenant trois contrôles :
&lt;ul&gt;
&lt;li&gt;un &lt;code&gt;InputText&lt;/code&gt;, champs de saisie textuelle&lt;/li&gt;
&lt;li&gt;un &lt;code&gt;Button&lt;/code&gt;, un bouton d'action&lt;/li&gt;
&lt;li&gt;un &lt;code&gt;Label&lt;/code&gt;, un champs de texte potentiellement dynamique&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;Chaque élément peut se voir nanti d'un attribut &lt;code&gt;id&lt;/code&gt; qui doit être unique si renseigné ; il permet de référencer facilement un élément de l'arbre &lt;acronym title=&quot;Document Object Model&quot;&gt;DOM&lt;/acronym&gt;&lt;/li&gt;
&lt;li&gt;La gestion des évènements peut se faire directement en MXML : ici, quand on clique sur le bouton, le contenu texte du label est modifié en fonction de la valeur textuelle du champs de saisie.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Style et mise en forme&lt;/h3&gt;


&lt;p&gt;Dans l'exemple précédent, on voit que les styles sont appliqués sous forme d'attributs XML. C'est une solution pratique à court terme mais qui peut rapidement s'avérer problématique à maintenir dès que votre application grossit. Aussi, pour séparer la couche de présentation de la description des contenus, tout comme en HTML, Flex permet l'utilisation de feuilles de styles CSS embarquées ou externalisées. Beaucoup de propriétés CSS ont du être créées ou adaptées aux spécificités du balisage MXML et des composants proposés, mais le résultat est une grande souplesse d'utilisation et une large palette de mise en forme disponible. Pour preuve, un petit tour du côté de l'&lt;a href=&quot;http://examples.adobe.com/flex2/consulting/styleexplorer/Flex2StyleExplorer.html&quot; hreflang=&quot;en&quot;&gt;explorateur de styles Flex&lt;/a&gt; s'impose.&lt;/p&gt;


&lt;h3&gt;Le langage ActionScript 3&lt;/h3&gt;


&lt;p&gt;ActionScript 3 est l'évolution logique des précédentes versions, étendant le périmètre fonctionnel et accentuant son caractère professionnel, notamment dans l'implémentation objet, les types natifs et l'organisation en packages des différents objets de programmation.&lt;/p&gt;


&lt;h3&gt;Composants personnalisés&lt;/h3&gt;


&lt;p&gt;Une des grandes forces de Flex à mes yeux est la simplicité avec laquelle on peut créer ses propres composants en héritant de composants basiques préexistants et de les manipuler via son propre espace de noms. Par exemple, la création d'un composant dérivé d'un formulaire présentant un champs de login/mot de passe donne à peu près ceci :&lt;/p&gt;

&lt;pre class=&quot;xml&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;?xml&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;version&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;1.0&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;encoding&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;utf-8&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;mx&lt;/span&gt;:Form xmlns:&lt;span style=&quot;color: #000066;&quot;&gt;mx&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://www.adobe.com/2006/mxml&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;width&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;280&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;height&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;105&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
   &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;mx&lt;/span&gt;:FormItem &lt;span style=&quot;color: #000066;&quot;&gt;label&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Login&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;mx&lt;/span&gt;:TextInput &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;username&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;
   &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/mx&lt;/span&gt;:FormItem&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
   &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;mx&lt;/span&gt;:FormItem &lt;span style=&quot;color: #000066;&quot;&gt;label&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Mot de passe&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;mx&lt;/span&gt;:TextInput &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;password&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;displayAsPassword&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;true&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;
   &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/mx&lt;/span&gt;:FormItem&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
   &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;mx&lt;/span&gt;:FormItem&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;mx&lt;/span&gt;:Button &lt;span style=&quot;color: #000066;&quot;&gt;label&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Connexion&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;
   &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/mx&lt;/span&gt;:FormItem&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/mx&lt;/span&gt;:Form&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Si on nomme notre fichier de composant &lt;code&gt;LoginForm.mxml&lt;/code&gt; et qu'on le stocke dans le répertoire &lt;code&gt;./components&lt;/code&gt; de notre projet Flex, on va pouvoir l'utiliser de la façon suivante dans une application :&lt;/p&gt;

&lt;pre class=&quot;xml&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;?xml&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;version&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;1.0&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;encoding&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;utf-8&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;mx&lt;/span&gt;:Application 
   xmlns:&lt;span style=&quot;color: #000066;&quot;&gt;mx&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://www.adobe.com/2006/mxml&amp;quot;&lt;/span&gt; 
   xmlns:&lt;span style=&quot;color: #000066;&quot;&gt;niko&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;components.*&amp;quot;&lt;/span&gt;
   &lt;span style=&quot;color: #000066;&quot;&gt;layout&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;absolute&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
   &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;mx&lt;/span&gt;:Panel &lt;span style=&quot;color: #000066;&quot;&gt;title&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Connexion&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;niko&lt;/span&gt;:LoginForm &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;loginform&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;
   &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/mx&lt;/span&gt;:Panel&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/mx&lt;/span&gt;:Application&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;On a déclaré un nouvel espace de noms, ici &lt;code&gt;niko&lt;/code&gt; (mais on aurait pu mettre ce qu'on veut) pointant vers les fichiers sous le répertoire &lt;code&gt;components&lt;/code&gt; du projet. Simple, non ? En tout cas, cela devient un jeu d'enfant de produire des composants réutilisables.&lt;/p&gt;


&lt;h3&gt;Le nerf de la guerre, l'accès aux données distantes&lt;/h3&gt;


&lt;p&gt;Flex propose trois modes d'accès aux données distantes, par le biais de trois composants :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;L'objet &lt;code&gt;HTTPService&lt;/code&gt;, comme son nom l'indique, permet d'effectuer des requêtes &lt;a href=&quot;http://fr.wikipedia.org/wiki/HTTP&quot; hreflang=&quot;fr&quot;&gt;HTTP&lt;/a&gt; sur une url et d'en récupérer la réponse. Un objet bien pratique quand on veut s'interfacer avec une &lt;a href=&quot;http://www.biologeek.com/journal/index.php/pour-ne-plus-etre-en-rest-comprendre-cette-architecture&quot; hreflang=&quot;fr&quot;&gt;architecture REST&lt;/a&gt;, par exemple.&lt;/li&gt;
&lt;li&gt;L'objet &lt;code&gt;WebService&lt;/code&gt; permet de s'interfacer avec un webservice au format &lt;a href=&quot;http://fr.wikipedia.org/wiki/WSDL&quot; hreflang=&quot;fr&quot;&gt;WSDL&lt;/a&gt; via &lt;a href=&quot;http://fr.wikipedia.org/wiki/SOAP&quot; hreflang=&quot;fr&quot;&gt;SOAP&lt;/a&gt;. Quand on dispose de tels service, c'est un plaisir de se baser dessus depuis Flex puisqu'on a qu'à réferencer les méthodes à utiliser et les déclencher depuis leur référence.&lt;/li&gt;
&lt;li&gt;Mais l'objet de loin le plus intéressant à mes yeux est &lt;code&gt;RemoteObject&lt;/code&gt;, implémentation du protocole &lt;a href=&quot;http://fr.wikipedia.org/wiki/Remote_procedure_call&quot; hreflang=&quot;fr&quot;&gt;RPC&lt;/a&gt; dans Flex, pendant Flash/ActionScript du &lt;a href=&quot;http://fr.wikipedia.org/wiki/Remote_method_invocation_%28Java%29&quot; hreflang=&quot;fr&quot;&gt;RMI&lt;/a&gt; en Java. Comme je fais peu de Java, j'ai tendance à plutôt utiliser &lt;a href=&quot;http://www.amfphp.org/&quot; hreflang=&quot;en&quot;&gt;AMFPHP&lt;/a&gt;&lt;sup&gt;[&lt;a href=&quot;http://prendreuncafe.com/blog/post/2007/08/19/#pnote-908-3&quot; id=&quot;rev-pnote-908-3&quot;&gt;3&lt;/a&gt;]&lt;/sup&gt; pour publier mes services en utilisant &lt;a href=&quot;http://fr.php.net/&quot; hreflang=&quot;fr&quot;&gt;PHP&lt;/a&gt;. Un très bon &lt;a href=&quot;http://www.sephiroth.it/tutorials/flashPHP/flex_remoteobject/index.php&quot; hreflang=&quot;en&quot;&gt;tuto de mise en oeuvre du couple AMFPHP/Flex&lt;/a&gt; se chargera d'illustrer le concept plus efficacement que je ne le fais ici.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;FlexBuilder&lt;/h3&gt;


&lt;p&gt;Adobe propose un IDE dédié à la réalisation d'applications Flex, &lt;a href=&quot;http://www.adobe.com/fr/products/flex/flexbuilder/&quot; hreflang=&quot;fr&quot;&gt;FlexBuilder&lt;/a&gt;. Cet outil, basé sur le célebrissime &lt;a href=&quot;http://eclipse.org&quot; hreflang=&quot;fr&quot;&gt;Eclipse&lt;/a&gt;, permet de disposer d'un environnement complet de développement comprenant entre autres un éditeur de code (MXML en mode source/wysiwyg, ActionScript, CSS, etc.), un débogueur avancé &lt;em&gt;à la Java&lt;/em&gt;, un gestionnaire de projets, la compilation automatique et surtout un accès à l'immense &lt;a href=&quot;http://eclipse-plugins.2y.net/eclipse/plugins.jsp&quot; hreflang=&quot;en&quot;&gt;catalogue des plugins Eclipse&lt;/a&gt;. D'ailleurs, FlexBuilder est également disponible sous la forme d'un plugin à installer sur une instance d'Eclipse existante : de quoi travailler sur vos projets Flex/PHP de façon centralisée, par exemple.&lt;/p&gt;


&lt;p&gt;Inconvénient majeur de cet outil, il est payant. Et coûte relativement cher, puisque proposé aux alentours de 500€. Néanmoins, le SDK de Flex étant gratuit, vous pouvez tout à fait vous passer de FlexBuilder et compiler vos applications à la main. Une bonne nouvelle ne venant jamais seule, &lt;a href=&quot;http://www.adobe.com/aboutadobe/pressroom/pressreleases/200704/042607Flex.html&quot; hreflang=&quot;en&quot;&gt;Adobe a décidé de publier la prochaine mouture du framework sous licence libre&lt;/a&gt; &lt;sup&gt;[&lt;a href=&quot;http://prendreuncafe.com/blog/post/2007/08/19/#pnote-908-4&quot; id=&quot;rev-pnote-908-4&quot;&gt;4&lt;/a&gt;]&lt;/sup&gt;, aussi nous devrions voir fleurir des alternatives à FlexBuilder et assister à un taux d'adoption plus conséquent de la technologie.&lt;/p&gt;


&lt;h3&gt;Organisation du code, frameworks&lt;/h3&gt;


&lt;p&gt;Au vu de l'étendue fonctionnelle de Flex et des différents formats de fichiers mis en oeuvre ainsi que de leurs interactions potentielles, il est clair que maintenir la moindre petite application peut vite relever du cauchemar les développements avançant. Pour faire face à cette problématique, Adobe propose un &lt;em&gt;surframework&lt;/em&gt; du nom de &lt;a href=&quot;http://labs.adobe.com/wiki/index.php/Cairngorm&quot; hreflang=&quot;en&quot;&gt;Cairngorm&lt;/a&gt; mettant en oeuvre les bonnes pratiques d'architecture logicielle en implémentant le motif de conception &lt;acronym title=&quot;Modèle Vue Controlleur&quot;&gt;MVC&lt;/acronym&gt; bien connu des utilisateurs de frameworks de développement rapide orientés web.&lt;/p&gt;


&lt;p&gt;Même si le projet semble extrêmement intéressant, je n'ai pas encore pour l'heure pu jouer avec.&lt;/p&gt;


&lt;h3&gt;Conclusion&lt;/h3&gt;


&lt;p&gt;Pour l'heure et après avoir pas mal &lt;del&gt;galéré&lt;/del&gt; tâtonné avec l'outil au début, je dois reconnaître maintenant et avec un peu de recul que c'est assez efficace. C'est relativement déstabilisant pour quelqu'un qui comme moi avait l'habitude de l'IDE Flash Authoring classique, mais au final FlexBuilder semble beaucoup plus sérieux pour tout ce qui concerne la programmation et l'organisation des fichiers (Eclipse oblige.) Même le templating y gagne à mon sens, mais par contre impossible de faire de la création graphique avancée directement dans FlexBuilder, l'outil n'est clairement pas l'ami des infographistes de vocation.&lt;/p&gt;


&lt;p&gt;Pour enfoncer le clou, j'ai pu comparer l'utilisation de Flex et de XUL, ayant enchaîné deux projets coup sur coup les mettant en oeuvre. L'excellente documentation de Flex et la richesse des outils gravitant autour de la techno font que pour l'heure Flex me semble l'un des meilleurs choix pour développer une RIA, si l'on écarte le couple HTML/Ajax qui garde une toujours une place de choix dans mon arsenal webdeuzéroesque &lt;img src=&quot;/blog/themes/PuC4/smilies/wink.gif&quot; alt=&quot;;)&quot; class=&quot;smiley&quot; /&gt;&lt;/p&gt;
&lt;div class=&quot;footnotes&quot;&gt;&lt;h4&gt;Notes&lt;/h4&gt;
&lt;p&gt;[&lt;a href=&quot;http://prendreuncafe.com/blog/post/2007/08/19/#rev-pnote-908-1&quot; id=&quot;pnote-908-1&quot;&gt;1&lt;/a&gt;] Je ne sais pas à quoi correspond la lettre M de l'acronyme, &lt;em&gt;Macromedia&lt;/em&gt; sans doute.&lt;/p&gt;
&lt;p&gt;[&lt;a href=&quot;http://prendreuncafe.com/blog/post/2007/08/19/#rev-pnote-908-2&quot; id=&quot;pnote-908-2&quot;&gt;2&lt;/a&gt;] En attendant &lt;a href=&quot;http://www.whatwg.org/specs/web-forms/current-work/&quot; hreflang=&quot;en&quot;&gt;HTML5&lt;/a&gt;, les antiflash pourront aller zieuter du côté d'&lt;a href=&quot;http://extjs.com/&quot; hreflang=&quot;en&quot;&gt;extjs&lt;/a&gt; ou de &lt;a href=&quot;http://developer.yahoo.com/yui/&quot; hreflang=&quot;en&quot;&gt;YUI&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;[&lt;a href=&quot;http://prendreuncafe.com/blog/post/2007/08/19/#rev-pnote-908-3&quot; id=&quot;pnote-908-3&quot;&gt;3&lt;/a&gt;] Attention à bien utiliser la &lt;a href=&quot;http://www.5etdemi.com/blog/archives/2006/12/amfphp-19-beta-get-it-now/&quot; hreflang=&quot;en&quot;&gt;dernière version 1.9 beta&lt;/a&gt; compatible avec Flex2&lt;/p&gt;
&lt;p&gt;[&lt;a href=&quot;http://prendreuncafe.com/blog/post/2007/08/19/#rev-pnote-908-4&quot; id=&quot;pnote-908-4&quot;&gt;4&lt;/a&gt;] Sous licence &lt;acronym title=&quot;Mozilla Public Licence&quot;&gt;MPL&lt;/acronym&gt; plus précisément.&lt;/p&gt;&lt;/div&gt;</description>
    
    
    
      </item>
    
</channel>
</rss>