<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet title="XSL formatting" type="text/xsl" href="http://blog.lalex.com/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>LAlex devblog v6 - AS3 / Flex2</title>
  <link>http://blog.lalex.com/</link>
  <description></description>
  <language>fr</language>
  <pubDate>Wed, 23 Jul 2008 19:52:33 +0200</pubDate>
  <copyright></copyright>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Dotclear</generator>
  
    
  <item>
    <title>Tips: Angles et géométrie</title>
    <link>http://blog.lalex.com/post/2008/06/20/Angles-et-geometrie</link>
    <guid isPermaLink="false">urn:md5:9e2b41c46d1474bd55e197acaf4e2d1b</guid>
    <pubDate>Fri, 20 Jun 2008 13:45:00 +0200</pubDate>
    <dc:creator>-Alexandre LEGOUT aka LAlex-</dc:creator>
        <category>AS3 / Flex2</category>
            
    <description>    &lt;p&gt;Je suis actuellement en train de me bruler les neurones sur un éditeur,
permettant entre autres de modifier un visuel à la souris. De quoi devoir
replonger dans nos bonnes vieilles notions de trigo.&lt;br /&gt;
J'en profite donc pour donner ici 2-3 astuces&lt;/p&gt;
&lt;h4&gt;Rotation d'un point&lt;/h4&gt;
&lt;p&gt;Pour passer d'un point (x, y) à un autre (x', y') en lui appliquant une
rotation d'angle a, l'équation est la suivante:&lt;br /&gt;&lt;/p&gt;
&lt;pre&gt;
        x' = x*cos(a) - y*sin(a)
        y' = x*sin(a) + y*cos(a)
&lt;/pre&gt;
&lt;p&gt;Ce qui nous donne un petite méthode AS3:&lt;/p&gt;
&lt;code class=&quot;actionscript&quot;&gt;&lt;span style=&quot;color: #0066CC;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; rotatePoint&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;point : Point, angle : &lt;span style=&quot;color: #0066CC;&quot;&gt;Number&lt;/span&gt;, isRadian : &lt;span style=&quot;color: #0066CC;&quot;&gt;Boolean&lt;/span&gt; = &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; : Point &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;ang == &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; point.&lt;span style=&quot;color: #006600;&quot;&gt;clone&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;var&lt;/span&gt; radAngle : &lt;span style=&quot;color: #0066CC;&quot;&gt;Number&lt;/span&gt; = isRadian ? angle : angle * &lt;span style=&quot;color: #0066CC;&quot;&gt;Math&lt;/span&gt;.&lt;span style=&quot;color: #0066CC;&quot;&gt;PI&lt;/span&gt; / &lt;span style=&quot;color: #cc66cc;&quot;&gt;180&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;var&lt;/span&gt; angleCos : &lt;span style=&quot;color: #0066CC;&quot;&gt;Number&lt;/span&gt; = &lt;span style=&quot;color: #0066CC;&quot;&gt;Math&lt;/span&gt;.&lt;span style=&quot;color: #0066CC;&quot;&gt;cos&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;radAngle&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;var&lt;/span&gt; angleSin : &lt;span style=&quot;color: #0066CC;&quot;&gt;Number&lt;/span&gt; = &lt;span style=&quot;color: #0066CC;&quot;&gt;Math&lt;/span&gt;.&lt;span style=&quot;color: #0066CC;&quot;&gt;sin&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;radAngle&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; Point&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;point.&lt;span style=&quot;color: #006600;&quot;&gt;x&lt;/span&gt; * angleCos - point.&lt;span style=&quot;color: #006600;&quot;&gt;y&lt;/span&gt; * angleSin, point.&lt;span style=&quot;color: #006600;&quot;&gt;x&lt;/span&gt; * angleSin + point.&lt;span style=&quot;color: #006600;&quot;&gt;y&lt;/span&gt; * angleCos&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/code&gt;
&lt;p&gt;Notez que l'on peut passer cette méthode un angle en degré (par défaut) ou
en radians.&lt;/p&gt;
&lt;h4&gt;Angle fait par un vecteur&lt;/h4&gt;
&lt;p&gt;L'AS3 nous fournit une méthode toute prête: &lt;em&gt;Math.atan2&lt;/em&gt;. Elle prend
en paramètre les coordonnées du vecteur (j'utilise un point dans l'exemple) et
retourne un angle en radian (d'où le flag &lt;em&gt;isRadian&lt;/em&gt; de la méthode
précédente).&lt;br /&gt;
&lt;ins&gt;Notez bien que la coordonnée &lt;em&gt;'y&lt;/em&gt;' est le premier argument&lt;/ins&gt;
(chez moi, FDT m'affiche 'x' en premier, je me suis fait avoir au début)&lt;/p&gt;
&lt;code class=&quot;actionscript&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;var&lt;/span&gt; vector : Point = &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; Point&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;mouseX, mouseY&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;var&lt;/span&gt; angRadian : &lt;span style=&quot;color: #0066CC;&quot;&gt;Number&lt;/span&gt; = &lt;span style=&quot;color: #0066CC;&quot;&gt;Math&lt;/span&gt;.&lt;span style=&quot;color: #0066CC;&quot;&gt;atan2&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;vector.&lt;span style=&quot;color: #006600;&quot;&gt;y&lt;/span&gt;, vector.&lt;span style=&quot;color: #006600;&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/code&gt;
&lt;h4&gt;Normaliser un angle&lt;/h4&gt;
&lt;p&gt;Selon les besoins, il peut être nécessaire d'utiliser systématiquement un
angle entre 0 et 360, ou entre -180 et 180. Avec les modulos, cela peut se
faire facilement:&lt;/p&gt;
&lt;code class=&quot;actionscript&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Get a random number between -1500 and 1500&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;var&lt;/span&gt; angle : &lt;span style=&quot;color: #0066CC;&quot;&gt;Number&lt;/span&gt; = &lt;span style=&quot;color: #0066CC;&quot;&gt;Math&lt;/span&gt;.&lt;span style=&quot;color: #0066CC;&quot;&gt;random&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; * &lt;span style=&quot;color: #cc66cc;&quot;&gt;3000&lt;/span&gt; - &lt;span style=&quot;color: #cc66cc;&quot;&gt;1500&lt;/span&gt;;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Normalize angle between 0 and 360&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;var&lt;/span&gt; angleIn360 : &lt;span style=&quot;color: #0066CC;&quot;&gt;Number&lt;/span&gt; = &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;angle % &lt;span style=&quot;color: #cc66cc;&quot;&gt;360&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; + &lt;span style=&quot;color: #cc66cc;&quot;&gt;360&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; % &lt;span style=&quot;color: #cc66cc;&quot;&gt;360&lt;/span&gt;;&lt;br /&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Normalize angle between -180 and 180&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;var&lt;/span&gt; angleIn180 : &lt;span style=&quot;color: #0066CC;&quot;&gt;Number&lt;/span&gt; = &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;angle % &lt;span style=&quot;color: #cc66cc;&quot;&gt;360&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; + &lt;span style=&quot;color: #cc66cc;&quot;&gt;540&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; % &lt;span style=&quot;color: #cc66cc;&quot;&gt;360&lt;/span&gt; - &lt;span style=&quot;color: #cc66cc;&quot;&gt;180&lt;/span&gt;;&lt;/code&gt;
&lt;p&gt;---&lt;/p&gt;
&lt;p&gt;Voilà pour les ch'tites astuces de l'oncle LAlex &lt;img src=&quot;http://common.lalex.com/themes/devblog/smilies/icon_razz.gif&quot; alt=&quot;:P&quot; class=&quot;smiley&quot; /&gt;&lt;/p&gt;</description>
    
    
    
          <comments>http://blog.lalex.com/post/2008/06/20/Angles-et-geometrie#comment-form</comments>
      <wfw:comment>http://blog.lalex.com/post/2008/06/20/Angles-et-geometrie#comment-form</wfw:comment>
      <wfw:commentRss>http://blog.lalex.com/feed/rss2/comments/792</wfw:commentRss>
      </item>
    
  <item>
    <title>JSFL mon amour...</title>
    <link>http://blog.lalex.com/post/2007/12/30/JSFL-mon-amour</link>
    <guid isPermaLink="false">urn:md5:72b970ff0990f128311388e8d334dbf0</guid>
    <pubDate>Mon, 31 Mar 2008 17:30:00 +0200</pubDate>
    <dc:creator>-Alexandre LEGOUT aka LAlex-</dc:creator>
        <category>AS3 / Flex2</category>
            
    <description>&lt;p&gt;&lt;a href=&quot;http://www.envrac.org/index.php/2006/03/25/62-le-jsfl-c-est-bon-mangez-en&quot; hreflang=&quot;fr&quot;&gt;L'équipe d'envrac avait prévenu&lt;/a&gt;, mais je suis en train de
doucement glisser vers la dépendance au JSFL...&lt;/p&gt;
&lt;p&gt;Un p'tit langage qui permet de scripter l'IDE et ainsi de raccourcir
drastiquement les taches répétitives, c'est quand-même du pain béni pour peu
qu'on prenne le temps de s'y pencher. Pas encore interessé aux panneaux
&amp;quot;custom&amp;quot;, j'ai pondu quelques petites déclinaisons d'un script inspiré par une
ancienne collègue - si tu te reconnais, un paquet de Carambars &lt;img src=&quot;http://common.lalex.com/themes/devblog/smilies/icon_wink.gif&quot; alt=&quot;;)&quot; class=&quot;smiley&quot; /&gt; - et qui
facilite grandement l'intégration timeline/code (un petit article prévu la
dessus dés que je lève un peu la tête des mes projets et que je me défénéantise
en ce qui concerne ce blog).&lt;/p&gt;
&lt;p&gt;Bref, ceci est un ensemble de 4 scripts JSFL qui font le tour des instances
nommées dans un clip, et affiche dans le panneau de sortie les déclarations AS3
de celles-ci : je ne parlerais pas ici de la quasi obligation morale qui
nous incombe à tous de décocher la case &amp;quot;Déclarer automatiquement les instances
etc...&amp;quot; si vous êtes pas des trouillards... :p&lt;/p&gt;    &lt;p&gt;Plusieurs déclinaisons donc:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&amp;quot;&lt;ins&gt;Lazy Timeline Variables&lt;/ins&gt;&amp;quot;: affiche les déclarations sour forme
&lt;em&gt;public var monClip:MonClip;&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&amp;quot;&lt;ins&gt;Lazy Timeline GetSet&lt;/ins&gt;&amp;quot;: même chose, mais déclare les variables
en mode &lt;em&gt;private&lt;/em&gt; préfixées avec un underscore, ainsi que les
getter/setter publics corrspondant (pratique si vous voulez détecter l'ajout
d'un clip à la timeline, sans attendre un Event.ADDED puis un
Event.RENDER)...&lt;/li&gt;
&lt;li&gt;&amp;quot;&lt;ins&gt;Lazy Selected Variables&lt;/ins&gt;&amp;quot;/&amp;quot;&lt;ins&gt;Lazy Selected GetSet&lt;/ins&gt;&amp;quot;:
même chose que les deux précédents, mais uniquement pour les instances
sélectionnées dans l'IDE: pratique quand on a déjà utilisés les précédents,
mais qu'on a rajouté une instance entre temps...&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;A savoir que chacun de ces scripts:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Utilise les classes renseignées dans l'IDE: en gros, si les éléments ne
sont pas exportés pour AS dans la bibliothèque, c'est MovieClip ou SimpleButton
qui seront utilisés, sinon, c'est soit la BaseClass, soit la classe elle-même
qui seront utilisées.&lt;/li&gt;
&lt;li&gt;Copie ces déclarations dans le clipboard, pour qu'il n'y ai plus qu'un
&amp;quot;coller&amp;quot; à faire dans le vrai environnement de développement que vous utilisez
certainement! &lt;img src=&quot;http://common.lalex.com/themes/devblog/smilies/icon_wink.gif&quot; alt=&quot;;)&quot; class=&quot;smiley&quot; /&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Ces scripts se décompressent dans le répertoire &lt;em&gt;~/Library/Application
Support/Adobe/Flash CS3/en/Configuration/Commands&lt;/em&gt; (sur Mac, vous trouverez
l'équivalent sur Windows), et deviennent accessibles depuis Flash dans le menu
&amp;quot;Commandes&amp;quot;...&lt;/p&gt;
&lt;p&gt;Pour le petit exemple de &lt;em&gt;&amp;quot;Lazy Timeline GetSet&amp;quot;&lt;/em&gt; pour 2 boutons:&lt;/p&gt;
&lt;code class=&quot;actionscript&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/* JSFL Example*/&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Private timeline properties&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0066CC;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;var&lt;/span&gt; _upButton:MinimalButton;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0066CC;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;var&lt;/span&gt; _downButton:MinimalButton;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Public timeline getters/setters&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0066CC;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; &lt;span style=&quot;color: #0066CC;&quot;&gt;set&lt;/span&gt; upButton&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;displayObject: MinimalButton&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; : &lt;span style=&quot;color: #0066CC;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; _upButton = displayObject;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Rajouté a posteriori&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; _upButton.&lt;span style=&quot;color: #006600;&quot;&gt;addEventListener&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;MouseEvent.&lt;span style=&quot;color: #006600;&quot;&gt;CLICK&lt;/span&gt;, upButtonClickHandler&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0066CC;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; upButtonClickHandler&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;event : MouseEvent&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; : &lt;span style=&quot;color: #0066CC;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0066CC;&quot;&gt;trace&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Up clicked&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0066CC;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; &lt;span style=&quot;color: #0066CC;&quot;&gt;get&lt;/span&gt; upButton&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; : &lt;span style=&quot;color: #0066CC;&quot;&gt;MovieClip&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; _upButton;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0066CC;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; &lt;span style=&quot;color: #0066CC;&quot;&gt;set&lt;/span&gt; downButton&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;displayObject: MinimalButton&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; : &lt;span style=&quot;color: #0066CC;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; _downButton = displayObject;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Rajouté a posteriori&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; _downButton.&lt;span style=&quot;color: #006600;&quot;&gt;addEventListener&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;MouseEvent.&lt;span style=&quot;color: #006600;&quot;&gt;CLICK&lt;/span&gt;, downButtonClickHandler&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0066CC;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; downButtonClickHandler&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;event : MouseEvent&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; : &lt;span style=&quot;color: #0066CC;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0066CC;&quot;&gt;trace&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Down clicked&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0066CC;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; &lt;span style=&quot;color: #0066CC;&quot;&gt;get&lt;/span&gt; downButton&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; : &lt;span style=&quot;color: #0066CC;&quot;&gt;MovieClip&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; _downButton;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/code&gt;
&lt;p&gt;Tous ces zoulis scripts sont téléchargeables: &lt;a href=&quot;http://download.lalex.com/devblog/LazyScripts.zip&quot; hreflang=&quot;fr&quot;&gt;LazyScripts.zip&lt;/a&gt;&lt;/p&gt;</description>
    
    
    
          <comments>http://blog.lalex.com/post/2007/12/30/JSFL-mon-amour#comment-form</comments>
      <wfw:comment>http://blog.lalex.com/post/2007/12/30/JSFL-mon-amour#comment-form</wfw:comment>
      <wfw:commentRss>http://blog.lalex.com/feed/rss2/comments/433</wfw:commentRss>
      </item>
    
  <item>
    <title>Les composants, c'est pour les graphistes!</title>
    <link>http://blog.lalex.com/post/2008/03/18/Les-composants-cest-pour-les-graphistes</link>
    <guid isPermaLink="false">urn:md5:ed4cdef0ef0ef5d080f19448f7a19891</guid>
    <pubDate>Tue, 18 Mar 2008 20:09:00 +0100</pubDate>
    <dc:creator>-Alexandre LEGOUT aka LAlex-</dc:creator>
        <category>AS3 / Flex2</category>
            
    <description>    &lt;p&gt;... qu'y disent! Eh ben, non madame, c'est bien pour les codeurs aussi!&lt;/p&gt;
&lt;p&gt;Prenons totalement au hasard un exemple de petite classe utilitaire de debug
pour afficher le framerate et la mémoire utilisée: et bien c'est quand-même
bien plus pratique de déposer un petit composant sur sa scène plutôt que de se
frapper un 'new FramerateViewer()' dans une DocumentClass quand-même... Et ca
se fait tout aussi vite!&lt;br /&gt;
Et que même si on veut mettre une icone et tout et tout, ca prend bien 2mn de
plus! &lt;img src=&quot;http://common.lalex.com/themes/devblog/smilies/icon_razz.gif&quot; alt=&quot;:P&quot; class=&quot;smiley&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Allez, l'exemple en pratique: &lt;a href=&quot;http://download.lalex.com/devblog/Framerate.swc&quot; hreflang=&quot;en&quot;&gt;Framerate.swc&lt;/a&gt; &lt;img src=&quot;http://common.lalex.com/themes/devblog/smilies/icon_wink.gif&quot; alt=&quot;;)&quot; class=&quot;smiley&quot; /&gt;&lt;/p&gt;
&lt;p&gt;PS: Merci &lt;a href=&quot;http://www.famfamfam.com/&quot; hreflang=&quot;en&quot;&gt;famfamfam&lt;/a&gt;
pour l'icone&lt;/p&gt;</description>
    
    
    
          <comments>http://blog.lalex.com/post/2008/03/18/Les-composants-cest-pour-les-graphistes#comment-form</comments>
      <wfw:comment>http://blog.lalex.com/post/2008/03/18/Les-composants-cest-pour-les-graphistes#comment-form</wfw:comment>
      <wfw:commentRss>http://blog.lalex.com/feed/rss2/comments/432</wfw:commentRss>
      </item>
    
  <item>
    <title>Flex 3, AIR 1.0, etc...</title>
    <link>http://blog.lalex.com/post/2008/02/25/Flex-3-AIR-10-etc</link>
    <guid isPermaLink="false">urn:md5:30e0d7a72d093b23fa39bf7417b30e4a</guid>
    <pubDate>Mon, 25 Feb 2008 12:58:00 +0100</pubDate>
    <dc:creator>-Alexandre LEGOUT aka LAlex-</dc:creator>
        <category>AS3 / Flex2</category>
            
    <description>    &lt;p&gt;Ca y est! Les blougs du monde entier l'ont déjà dit, le &lt;a href=&quot;http://www.adobe.com/products/flex/&quot; hreflang=&quot;fr&quot;&gt;Flex 3 SDK&lt;/a&gt;, première
release OpenSource de Flex et &lt;a href=&quot;http://www.adobe.com/products/air/&quot; hreflang=&quot;fr&quot;&gt;Adobe AIR&lt;/a&gt;, la saint graal gratuit des développeurs de RDA
(Rich Desktop Applications, bande d'inclutes), sont sortis!&lt;/p&gt;
&lt;p&gt;Tout ca semble extremement prometteur.&lt;br /&gt;
Je ne vais pas faire la liste des features, mais juste mettre le doigt sur un
enorme point positif de cette release: la disponibilité des sources de &lt;a href=&quot;http://opensource.adobe.com/svn/opensource/flex/sdk/branches/3.0.x/frameworks/projects/rpc/src/mx/rpc/soap/&quot; hreflang=&quot;fr&quot;&gt;la classe WebService de Flex&lt;/a&gt;! Le passage a l'AS3 avait tout
simplement zappé cette classe dans Flash CS3.&lt;/p&gt;
&lt;p&gt;Maintenant, reste à voir s'il est possible de se servir de celle-ci sans se
trimbaler la moitié du framework Flex...&lt;br /&gt;
Si je trouve le temps de faire des tests, j'en donnerai le resultat ici...
&lt;img src=&quot;http://common.lalex.com/themes/devblog/smilies/icon_wink.gif&quot; alt=&quot;;)&quot; class=&quot;smiley&quot; /&gt;&lt;/p&gt;</description>
    
    
    
          <comments>http://blog.lalex.com/post/2008/02/25/Flex-3-AIR-10-etc#comment-form</comments>
      <wfw:comment>http://blog.lalex.com/post/2008/02/25/Flex-3-AIR-10-etc#comment-form</wfw:comment>
      <wfw:commentRss>http://blog.lalex.com/feed/rss2/comments/430</wfw:commentRss>
      </item>
    
  <item>
    <title>Pathfinding A-star sur bitmap</title>
    <link>http://blog.lalex.com/post/2008/02/21/Pathfinding-A-star-sur-Bitmap</link>
    <guid isPermaLink="false">urn:md5:f7b21ba36192528f51d92952c746b63a</guid>
    <pubDate>Thu, 21 Feb 2008 20:02:00 +0100</pubDate>
    <dc:creator>-Alexandre LEGOUT aka LAlex-</dc:creator>
        <category>AS3 / Flex2</category>
            
    <description>&lt;p&gt;L'algorithme A* (A-star) connait de nombreuses implémentations. La plupart
utilisent une grille (tableau à deux dimensions) en tant que carte. Etant à la
base des jeux &amp;quot;tile-based&amp;quot;, celles-ci suffisent la plupart du temps à la grande
majorité des jeux. Seulement cela impose un certain nombre de contraintes,
notamment en terme de dimensions des &amp;quot;obstacles&amp;quot;, mais aussi en terme de
performances: l'algorythme se basant sur des noeux (nodes), une grille de 40/40
offre 1600 cases (maximum, l'A* n'étant pas exhaustif), ce qui est déjà bien
important...&lt;/p&gt;
&lt;p&gt;J'ai voulu essayer de me baser plutôt sur un bitmap, simple (pour
l'instant), une couleur étant celle du sol, l'autre celle des
obstacles :&lt;/p&gt;    &lt;div style=&quot;text-align:center;&quot;&gt;&lt;object type=&quot;application/x-shockwave-flash&quot; data=&quot;http://blog.lalex.com/public/bmpastar.swf&quot; width=&quot;600&quot; height=&quot;600&quot; id=&quot;BitmapAStar&quot;&gt;&lt;param name=&quot;movie&quot; value=&quot;http://blog.lalex.com/public/bmpastar.swf&quot; /&gt;
Ma jolie video&lt;/object&gt;&lt;/div&gt;
&lt;p&gt;En gros, l'appel de méthode utilisé ici est&lt;/p&gt;
&lt;code class=&quot;actionscript&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;var&lt;/span&gt; bmp:BitmapData = &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; BitmapData&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;400&lt;/span&gt;, &lt;span style=&quot;color: #cc66cc;&quot;&gt;400&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Génération d'un bitmap aléatoire: fillRect aléatoires, etc...&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;var&lt;/span&gt; finder:BitmapAStar = &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; BitmapAStar;&lt;br /&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;var&lt;/span&gt; path: &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/*Point*/&lt;/span&gt; &lt;span style=&quot;color: #0066CC;&quot;&gt;Array&lt;/span&gt; = finder.&lt;span style=&quot;color: #006600;&quot;&gt;findPath&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;bmp, &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; Point&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;5&lt;/span&gt;, &lt;span style=&quot;color: #cc66cc;&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;, &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; Point&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;395&lt;/span&gt;, &lt;span style=&quot;color: #cc66cc;&quot;&gt;395&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/code&gt;
&lt;p&gt;L'A* n'a évidemment pas été le plus compliqué à mettre en oeuvre, mais c'est
bien l'analyse et le découpage de ce bitmap qui ont été difficiles à mettre en
place. Beaucoup de choses restent à faire malgré cette démo fonctionnelle,
notamment l'optimisation du placement des &amp;quot;portes&amp;quot; (ronds blancs sur
l'affichage &amp;quot;debug&amp;quot;), et des trajectoires (je pense notamment faire un lissage
du chemin à parcourir). D'autres fonctionnalités peuvent être envisagées, comme
la gestion des altitudes (terrain en pente, ou les falaises qui seraient des
portes à sens unique - qu'on peut sauter mais pas grimper) ou des types de
terrain (un malus associé à chaque couleur par exemple).&lt;/p&gt;
&lt;p&gt;Dans le plus ardu, on peut aussi imaginer un découpage des formes non
rectangulaires (polygones ou courbes).&lt;/p&gt;
&lt;p&gt;Une fois cleanées (l'API notamment) et optimisées, je mettrai les sources à
disposition sur ce blog... &lt;img src=&quot;http://common.lalex.com/themes/devblog/smilies/icon_wink.gif&quot; alt=&quot;;)&quot; class=&quot;smiley&quot; /&gt;&lt;/p&gt;</description>
    
    
    
          <comments>http://blog.lalex.com/post/2008/02/21/Pathfinding-A-star-sur-Bitmap#comment-form</comments>
      <wfw:comment>http://blog.lalex.com/post/2008/02/21/Pathfinding-A-star-sur-Bitmap#comment-form</wfw:comment>
      <wfw:commentRss>http://blog.lalex.com/feed/rss2/comments/429</wfw:commentRss>
      </item>
    
  <item>
    <title>Options d'une méthode &quot;Array-like&quot;</title>
    <link>http://blog.lalex.com/post/2008/02/20/Options-dune-methode-Array-like</link>
    <guid isPermaLink="false">urn:md5:37d5c1ba3ca6b3b0fe166584d7b7a9b9</guid>
    <pubDate>Wed, 20 Feb 2008 19:57:00 +0100</pubDate>
    <dc:creator>-Alexandre LEGOUT aka LAlex-</dc:creator>
        <category>AS3 / Flex2</category>
            
    <description>&lt;p&gt;Un appel à une méthode paut parfois avoir besoin d'un certains nombre
&amp;quot;d'options&amp;quot;, comme c'est le cas pour la méthode &lt;em&gt;Array.sort&lt;/em&gt; par
exemple.&lt;/p&gt;
&lt;p&gt;Il existe alors plusieurs possibilités, la plus simple étant de proposer un
certain nombre de paramètres booléens facultatifs, avec des valeurs par défaut.
Le problème est tout d'abord que cela alourdit considérablement le code, mais
aussi que rajouter une option supplémentaire modifie la signature de la
méthode: si on travaille avec des interfaces, bonjour la galère).&lt;/p&gt;
&lt;p&gt;Bref, il existe aussi la possibilité de passer un seul entier, qui sera la
somme de puissances de 2. En gros, cela permet d'avoir, en binaire, une suite
de 0 et de 1, chacun correspondant à l'activation (ou pas) d'une option.&lt;br /&gt;
Voyons comment cela fonctionne concrètement avec l'exemple de
&lt;em&gt;Array.sort&lt;/em&gt;&lt;/p&gt;    &lt;p&gt;Les différentes options de cette méthode ont toutes une valeur numérique
puissance de 2:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Array.CASEINSENSITIVE: valeur 1 (2 puissance 0)&lt;/li&gt;
&lt;li&gt;Array.DESCENDING : valeur 2 (2 puissance 1)&lt;/li&gt;
&lt;li&gt;Array.UNIQUESORT : valeur 4 (2 puissance 2)&lt;/li&gt;
&lt;li&gt;etc...&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Pour les utiliser, on se sert de l'opérateur OU binaire | (pipe simple) de
la manière suivante:&lt;/p&gt;
&lt;code class=&quot;actionscript&quot;&gt;myArray.&lt;span style=&quot;color: #0066CC;&quot;&gt;sort&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0066CC;&quot;&gt;Array&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;DESCENDING&lt;/span&gt; | &lt;span style=&quot;color: #0066CC;&quot;&gt;Array&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;UNIQUESORT&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/code&gt;
&lt;p&gt;&lt;br /&gt;
Pour utiliser ce système dans d'autres situations, j'ai développé une ch'tite
classe toute simple qui génère des options propres à chaque classe, et permet
de tester si une option donnée est donnée dont voici l'utilisation:&lt;/p&gt;
&lt;code class=&quot;actionscript&quot;&gt;package com.&lt;span style=&quot;color: #006600;&quot;&gt;lalex&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;utils&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0066CC;&quot;&gt;import&lt;/span&gt; flash.&lt;span style=&quot;color: #006600;&quot;&gt;display&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;BitmapData&lt;/span&gt;;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0066CC;&quot;&gt;import&lt;/span&gt; com.&lt;span style=&quot;color: #006600;&quot;&gt;lalex&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;utils&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;Options&lt;/span&gt;; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/**&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;* @author LAlex&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;*/&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0066CC;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; LAlexDemo &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Create options on the fly&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0066CC;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0066CC;&quot;&gt;static&lt;/span&gt; const SHOW_DEBUG : &lt;span style=&quot;color: #0066CC;&quot;&gt;int&lt;/span&gt; = Options.&lt;span style=&quot;color: #006600;&quot;&gt;create&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;LAlexDemo&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0066CC;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0066CC;&quot;&gt;static&lt;/span&gt; const SHOW_BORDER : &lt;span style=&quot;color: #0066CC;&quot;&gt;int&lt;/span&gt; = Options.&lt;span style=&quot;color: #006600;&quot;&gt;create&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;LAlexDemo&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0066CC;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0066CC;&quot;&gt;static&lt;/span&gt; const HIDE_FILL : &lt;span style=&quot;color: #0066CC;&quot;&gt;int&lt;/span&gt; = Options.&lt;span style=&quot;color: #006600;&quot;&gt;create&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;LAlexDemo&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0066CC;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; drawShape&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;bdt : BitmapData, options:&lt;span style=&quot;color: #0066CC;&quot;&gt;int&lt;/span&gt; = &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; : &lt;span style=&quot;color: #0066CC;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;Options.&lt;span style=&quot;color: #006600;&quot;&gt;hasOption&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;options, SHOW_DEBUG&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #0066CC;&quot;&gt;trace&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;We will show debug infos&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;Options.&lt;span style=&quot;color: #006600;&quot;&gt;hasOption&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;options, SHOW_BORDER&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #0066CC;&quot;&gt;trace&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;We will show shape's border&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;Options.&lt;span style=&quot;color: #006600;&quot;&gt;hasOption&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;options, HIDE_FILL&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #0066CC;&quot;&gt;trace&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;We will hide shape's fill color&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Utilisation&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;var&lt;/span&gt; demo:LAlexDemo = &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; LAlexDemo;&lt;br /&gt;
demo.&lt;span style=&quot;color: #006600;&quot;&gt;drawShape&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;myBitmapData, LAlexDemo.&lt;span style=&quot;color: #006600;&quot;&gt;SHOW_DEBUG&lt;/span&gt; | LAlexDemo.&lt;span style=&quot;color: #006600;&quot;&gt;HIDE_FILL&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/code&gt;
&lt;p&gt;Voila, un p'tit clic pour télécharger &lt;a href=&quot;http://download.lalex.com/devblog/Options_class.zip&quot; hreflang=&quot;fr&quot;&gt;com.lalex.utils.Options&lt;/a&gt; &lt;img src=&quot;http://common.lalex.com/themes/devblog/smilies/icon_wink.gif&quot; alt=&quot;;)&quot; class=&quot;smiley&quot; /&gt;&lt;/p&gt;</description>
    
    
    
          <comments>http://blog.lalex.com/post/2008/02/20/Options-dune-methode-Array-like#comment-form</comments>
      <wfw:comment>http://blog.lalex.com/post/2008/02/20/Options-dune-methode-Array-like#comment-form</wfw:comment>
      <wfw:commentRss>http://blog.lalex.com/feed/rss2/comments/427</wfw:commentRss>
      </item>
    
  <item>
    <title>TextField, htmlText et retours à la ligne</title>
    <link>http://blog.lalex.com/post/2008/01/07/TextField-htmlText-et-retours-a-la-ligne</link>
    <guid isPermaLink="false">urn:md5:298e1621d0e4a05040b094fee0cd5f03</guid>
    <pubDate>Mon, 07 Jan 2008 19:37:00 +0100</pubDate>
    <dc:creator>-Alexandre LEGOUT aka LAlex-</dc:creator>
        <category>AS3 / Flex2</category>
            
    <description>&lt;p&gt;Le nouvelle gestion des TextField avec AS3 est assez géniale je dirais: plus
de propriété &lt;em&gt;html&lt;/em&gt;, et une gestion commune entre le texte &amp;quot;classique&amp;quot;
associé aux &lt;em&gt;TextFormat&lt;/em&gt; et le texte HTML. Du coup, on peut manipuler
indifféremment le HTML ou les &lt;em&gt;TextFormat&lt;/em&gt;, la modification de l'un sera
reportée sur l'autre, comme on peut le voir via le code suivant:&lt;/p&gt;
&lt;code class=&quot;actionscript&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Crée le champ texte&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;var&lt;/span&gt; tField:&lt;span style=&quot;color: #0066CC;&quot;&gt;TextField&lt;/span&gt; = &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #0066CC;&quot;&gt;TextField&lt;/span&gt;;&lt;br /&gt;
tField.&lt;span style=&quot;color: #0066CC;&quot;&gt;text&lt;/span&gt; = &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;LAlex&amp;quot;&lt;/span&gt;;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Crée le format (couleur rouge)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;var&lt;/span&gt; tFormat:&lt;span style=&quot;color: #0066CC;&quot;&gt;TextFormat&lt;/span&gt; = &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #0066CC;&quot;&gt;TextFormat&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
tFormat.&lt;span style=&quot;color: #0066CC;&quot;&gt;color&lt;/span&gt; = 0xFF0000;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Applique sur les deux premiers caractères&lt;/span&gt;&lt;br /&gt;
tField.&lt;span style=&quot;color: #0066CC;&quot;&gt;setTextFormat&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;tFormat, &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #cc66cc;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Affiche le resultat HTML de tout ca&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #0066CC;&quot;&gt;trace&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;tField.&lt;span style=&quot;color: #0066CC;&quot;&gt;htmlText&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/code&gt;
&lt;pre&gt;
&amp;lt;P ALIGN=&amp;quot;LEFT&amp;quot;&amp;gt;&amp;lt;FONT FACE=&amp;quot;Times Roman&amp;quot; SIZE=&amp;quot;12&amp;quot; COLOR=&amp;quot;#FF0000&amp;quot; LETTERSPACING=&amp;quot;0&amp;quot; KERNING=&amp;quot;0&amp;quot;&amp;gt;LA&amp;lt;FONT COLOR=&amp;quot;#000000&amp;quot;&amp;gt;lex&amp;lt;/FONT&amp;gt;&amp;lt;/FONT&amp;gt;&amp;lt;/P&amp;gt;
&lt;/pre&gt;
&lt;p&gt;Bon, aprés on va pas chipoter sur la cohérence du formatage HTML, évidemment
il y a mieux, mais le tout est d'avoir notre correspondance
&lt;em&gt;TextFormat&lt;/em&gt;/HTML...&lt;/p&gt;
&lt;p&gt;Bref, tout ceci étant fait, si on veut obtenir le copie conforme d'un texte
dans un autre, il suffit alors de copier le &lt;em&gt;htmlText&lt;/em&gt; du premier sur le
second, sans se préoccuper des &lt;em&gt;TextFormat&lt;/em&gt;? Eh bien pas
forcément...&lt;/p&gt;    &lt;p&gt;En effet, un petit bug (a mon avis, car j'ai du mal à expliquer la logique
derrière ca) s'est glissé dans la gestion du HTML par les &lt;em&gt;TextField&lt;/em&gt;.
En effet, quelle que soit la valeur de la propriété &lt;em&gt;condenseWhite&lt;/em&gt;
(sensée faire le même travail qu'un navigateur HTML, à savoir ne pas afficher
les espaces blancs consécutifs), un &lt;em&gt;TextField&lt;/em&gt; va systématiquement
zapper les paragraphes vides, alors que c'est ce qu'il utilise en interne pour
faire des retours à la ligne! Bref, tous les retours à la ligne vont sauter
quand on copie le &lt;em&gt;htmlText&lt;/em&gt;... Par exemple, si j'ai mis trois retours à
la ligne et un texte dans un TextField, les retours à la ligne seront en fait
des paragraphes vides &amp;lt;p&amp;gt;:&lt;/p&gt;
&lt;code class=&quot;actionscript&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;var&lt;/span&gt; tField:&lt;span style=&quot;color: #0066CC;&quot;&gt;TextField&lt;/span&gt; = &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #0066CC;&quot;&gt;TextField&lt;/span&gt;;&lt;br /&gt;
tField.&lt;span style=&quot;color: #0066CC;&quot;&gt;text&lt;/span&gt; = &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;LAlex&amp;quot;&lt;/span&gt;;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #0066CC;&quot;&gt;trace&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;tField.&lt;span style=&quot;color: #0066CC;&quot;&gt;htmlText&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/code&gt;
&lt;pre&gt;
&amp;lt;P ALIGN=&amp;quot;LEFT&amp;quot;&amp;gt;&amp;lt;FONT FACE=&amp;quot;Times Roman&amp;quot; SIZE=&amp;quot;12&amp;quot; COLOR=&amp;quot;#000000&amp;quot; LETTERSPACING=&amp;quot;0&amp;quot; KERNING=&amp;quot;0&amp;quot;&amp;gt;&amp;lt;/FONT&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P ALIGN=&amp;quot;LEFT&amp;quot;&amp;gt;&amp;lt;FONT FACE=&amp;quot;Times Roman&amp;quot; SIZE=&amp;quot;12&amp;quot; COLOR=&amp;quot;#000000&amp;quot; LETTERSPACING=&amp;quot;0&amp;quot; KERNING=&amp;quot;0&amp;quot;&amp;gt;&amp;lt;/FONT&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P ALIGN=&amp;quot;LEFT&amp;quot;&amp;gt;&amp;lt;FONT FACE=&amp;quot;Times Roman&amp;quot; SIZE=&amp;quot;12&amp;quot; COLOR=&amp;quot;#000000&amp;quot; LETTERSPACING=&amp;quot;0&amp;quot; KERNING=&amp;quot;0&amp;quot;&amp;gt;&amp;lt;/FONT&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P ALIGN=&amp;quot;LEFT&amp;quot;&amp;gt;&amp;lt;FONT FACE=&amp;quot;Times Roman&amp;quot; SIZE=&amp;quot;12&amp;quot; COLOR=&amp;quot;#000000&amp;quot; LETTERSPACING=&amp;quot;0&amp;quot; KERNING=&amp;quot;0&amp;quot;&amp;gt;LAlex&amp;lt;/FONT&amp;gt;&amp;lt;/P&amp;gt;
&lt;/pre&gt;
&lt;p&gt;Bon, OK. Et si maintenant on réaffecte cette valeur à htmlText et qu'on la
relit? Voilà ce que ca donne:&lt;/p&gt;
&lt;code class=&quot;actionscript&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;var&lt;/span&gt; tField:&lt;span style=&quot;color: #0066CC;&quot;&gt;TextField&lt;/span&gt; = &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #0066CC;&quot;&gt;TextField&lt;/span&gt;;&lt;br /&gt;
tField.&lt;span style=&quot;color: #0066CC;&quot;&gt;text&lt;/span&gt; = &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;LAlex&amp;quot;&lt;/span&gt;;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;var&lt;/span&gt; myHtmlText:&lt;span style=&quot;color: #0066CC;&quot;&gt;String&lt;/span&gt; = tField.&lt;span style=&quot;color: #0066CC;&quot;&gt;htmlText&lt;/span&gt;;&lt;br /&gt;
tField.&lt;span style=&quot;color: #0066CC;&quot;&gt;text&lt;/span&gt; = &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;;&lt;br /&gt;
tField.&lt;span style=&quot;color: #0066CC;&quot;&gt;htmlText&lt;/span&gt; = myHtmlText;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #0066CC;&quot;&gt;trace&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;tField.&lt;span style=&quot;color: #0066CC;&quot;&gt;htmlText&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/code&gt;
&lt;pre&gt;
&amp;lt;P ALIGN=&amp;quot;LEFT&amp;quot;&amp;gt;&amp;lt;FONT FACE=&amp;quot;Times Roman&amp;quot; SIZE=&amp;quot;12&amp;quot; COLOR=&amp;quot;#000000&amp;quot; LETTERSPACING=&amp;quot;0&amp;quot; KERNING=&amp;quot;0&amp;quot;&amp;gt;LAlex&amp;lt;/FONT&amp;gt;&amp;lt;/P&amp;gt;
&lt;/pre&gt;
&lt;p&gt;(a noter que je remet le texte à zéro avant de le réattribuer, car sinon il
ne fait aucun traitement: il doit exister en interne un traitement du type
&lt;em&gt;if (_odlHtmlText != _newHtmlText) {...}&lt;/em&gt;).&lt;/p&gt;
&lt;p&gt;Comment parer ce problème? J'ai constaté qu'un &amp;quot;vrai&amp;quot; retour à la ligne
entre deux paragraphes restaure le retour à la ligne dans le champ texte. Il
suffit donc de rajouter un &lt;strong&gt;\n&lt;/strong&gt; entre la fin d'un paragraphe et
le suivant. Du coup, une petite regexp fait l'affaire:&lt;/p&gt;
&lt;code class=&quot;actionscript&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;var&lt;/span&gt; tField:&lt;span style=&quot;color: #0066CC;&quot;&gt;TextField&lt;/span&gt; = &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #0066CC;&quot;&gt;TextField&lt;/span&gt;;&lt;br /&gt;
tField.&lt;span style=&quot;color: #0066CC;&quot;&gt;text&lt;/span&gt; = &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;LAlex&amp;quot;&lt;/span&gt;;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;var&lt;/span&gt; myHtmlText:&lt;span style=&quot;color: #0066CC;&quot;&gt;String&lt;/span&gt; = tField.&lt;span style=&quot;color: #0066CC;&quot;&gt;htmlText&lt;/span&gt;;&lt;br /&gt;
tField.&lt;span style=&quot;color: #0066CC;&quot;&gt;text&lt;/span&gt; = &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;var&lt;/span&gt; reg : RegExp = &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; RegExp&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;lt;/([Pp])&amp;gt;&amp;lt;&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;g&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
tField.&lt;span style=&quot;color: #0066CC;&quot;&gt;htmlText&lt;/span&gt; = myHtmlText.&lt;span style=&quot;color: #006600;&quot;&gt;replace&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;reg, &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;lt;/$1&amp;gt;&amp;lt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #0066CC;&quot;&gt;trace&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;tField.&lt;span style=&quot;color: #0066CC;&quot;&gt;htmlText&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/code&gt;
&lt;pre&gt;
&amp;lt;P ALIGN=&amp;quot;LEFT&amp;quot;&amp;gt;&amp;lt;FONT FACE=&amp;quot;Times Roman&amp;quot; SIZE=&amp;quot;12&amp;quot; COLOR=&amp;quot;#000000&amp;quot; LETTERSPACING=&amp;quot;0&amp;quot; KERNING=&amp;quot;0&amp;quot;&amp;gt;&amp;lt;/FONT&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P ALIGN=&amp;quot;LEFT&amp;quot;&amp;gt;&amp;lt;FONT FACE=&amp;quot;Times Roman&amp;quot; SIZE=&amp;quot;12&amp;quot; COLOR=&amp;quot;#000000&amp;quot; LETTERSPACING=&amp;quot;0&amp;quot; KERNING=&amp;quot;0&amp;quot;&amp;gt;&amp;lt;/FONT&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P ALIGN=&amp;quot;LEFT&amp;quot;&amp;gt;&amp;lt;FONT FACE=&amp;quot;Times Roman&amp;quot; SIZE=&amp;quot;12&amp;quot; COLOR=&amp;quot;#000000&amp;quot; LETTERSPACING=&amp;quot;0&amp;quot; KERNING=&amp;quot;0&amp;quot;&amp;gt;&amp;lt;/FONT&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P ALIGN=&amp;quot;LEFT&amp;quot;&amp;gt;&amp;lt;FONT FACE=&amp;quot;Times Roman&amp;quot; SIZE=&amp;quot;12&amp;quot; COLOR=&amp;quot;#000000&amp;quot; LETTERSPACING=&amp;quot;0&amp;quot; KERNING=&amp;quot;0&amp;quot;&amp;gt;LAlex&amp;lt;/FONT&amp;gt;&amp;lt;/P&amp;gt;
&lt;/pre&gt;
&lt;p&gt;Et voilà! &lt;img src=&quot;http://common.lalex.com/themes/devblog/smilies/icon_cool.gif&quot; alt=&quot;8-)&quot; class=&quot;smiley&quot; /&gt;&lt;/p&gt;</description>
    
    
    
          <comments>http://blog.lalex.com/post/2008/01/07/TextField-htmlText-et-retours-a-la-ligne#comment-form</comments>
      <wfw:comment>http://blog.lalex.com/post/2008/01/07/TextField-htmlText-et-retours-a-la-ligne#comment-form</wfw:comment>
      <wfw:commentRss>http://blog.lalex.com/feed/rss2/comments/384</wfw:commentRss>
      </item>
    
  <item>
    <title>Interfaces et classes internal</title>
    <link>http://blog.lalex.com/post/2007/12/17/Interfaces-et-classes-internal</link>
    <guid isPermaLink="false">urn:md5:61c0beb04f69d8988cd51e0fc462837f</guid>
    <pubDate>Mon, 17 Dec 2007 13:04:00 +0100</pubDate>
    <dc:creator>-Alexandre LEGOUT aka LAlex-</dc:creator>
        <category>AS3 / Flex2</category>
            
    <description>&lt;p&gt;L'AS3 nous a amené les classes internes (mot-clé &lt;em&gt;internal&lt;/em&gt;) qui nous
permettent d'encapsuler un certain nombre de fonctionnalités dans une classe
disponible uniquement à la classe publique qui l'utilise. Bien pratique, cela
évite les classes trop longues, et grâce à l'héritage (une classe interne peut
en étendre une autre), cela peut aussi éviter l'utilisation d'un trop grand
nombre de &lt;em&gt;if&lt;/em&gt;, et donc abaisser la complexité du code.&lt;/p&gt;
&lt;p&gt;Cela peut aussi permettre de disposer d'une classe qui n'est pas
instanciable depuis l'extérieur. Seulement, il peut parfois être utile
d'accéder à une instance de ces classes, et là, la solution c'est tout
simplement les interfaces...&lt;/p&gt;    &lt;p&gt;Prenons l'exemple d'une liste de contacts (VoIP un jour, VoIP toujours!),
dans laquelle on peut sélectionner un contact. Le XML sera utilisé pour remplir
cette liste, et un certain nombre d'actions peuvent être effectuées sur les
contacts, mais la liste reste le seul moyen d'avoir des contacts: en gros, il
est impossible de créer un contact via un constructeur de type &lt;em&gt;new
Contact(...)&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;L'utilisation conjointe des classes internes et des interfaces nous donnerai
ceci: Une interface contact&lt;/p&gt;
&lt;code class=&quot;actionscript&quot;&gt;package &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/**&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;* Contact public interface&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;* &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;* @author LAlex&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;*/&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0066CC;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0066CC;&quot;&gt;interface&lt;/span&gt; Contact &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; sendMail&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0066CC;&quot;&gt;text&lt;/span&gt;:&lt;span style=&quot;color: #0066CC;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; : &lt;span style=&quot;color: #0066CC;&quot;&gt;void&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; &lt;span style=&quot;color: #0066CC;&quot;&gt;get&lt;/span&gt; firstName&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; : &lt;span style=&quot;color: #0066CC;&quot;&gt;String&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; &lt;span style=&quot;color: #0066CC;&quot;&gt;get&lt;/span&gt; lastName&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; : &lt;span style=&quot;color: #0066CC;&quot;&gt;String&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/code&gt;
&lt;p&gt;Une classe ContactList et son implémentation de l'interface en tant que
classe interne&lt;/p&gt;
&lt;code class=&quot;actionscript&quot;&gt;package &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/**&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;* @author LAlex&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;*/&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0066CC;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; ContactList &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0066CC;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;var&lt;/span&gt; _contacts:&lt;span style=&quot;color: #0066CC;&quot;&gt;Array&lt;/span&gt; = &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0066CC;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;var&lt;/span&gt; _selectedContactPosition : &lt;span style=&quot;color: #0066CC;&quot;&gt;int&lt;/span&gt; = &lt;span style=&quot;color: #cc66cc;&quot;&gt;-1&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; ContactList&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;dP:&lt;span style=&quot;color: #0066CC;&quot;&gt;XML&lt;/span&gt; = &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;dP != &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; setDataProvider&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;dP&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Methods&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0066CC;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; setDataProvider&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;x : &lt;span style=&quot;color: #0066CC;&quot;&gt;XML&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; : &lt;span style=&quot;color: #0066CC;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #b1b100;&quot;&gt;for&lt;/span&gt; each &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;var&lt;/span&gt; contactNode:&lt;span style=&quot;color: #0066CC;&quot;&gt;XML&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;in&lt;/span&gt; x.&lt;span style=&quot;color: #006600;&quot;&gt;contacts&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;contact&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; _contacts.&lt;span style=&quot;color: #0066CC;&quot;&gt;push&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; ContactImpl&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;contactNode&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0066CC;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; selectContactAt&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;ind : &lt;span style=&quot;color: #0066CC;&quot;&gt;int&lt;/span&gt; = &lt;span style=&quot;color: #cc66cc;&quot;&gt;-1&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; : &lt;span style=&quot;color: #0066CC;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;ind &amp;lt; _contacts.&lt;span style=&quot;color: #0066CC;&quot;&gt;length&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; _selectedContactPosition = ind;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0066CC;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; &lt;span style=&quot;color: #0066CC;&quot;&gt;get&lt;/span&gt; selectedContact&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; : Contact &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;_selectedContactPosition != &lt;span style=&quot;color: #cc66cc;&quot;&gt;-1&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; _contacts&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;_selectedContactPosition&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt; as Contact;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;null&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Contact interface implementation&lt;/span&gt;&lt;br /&gt;
internal &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; ContactImpl&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0066CC;&quot;&gt;implements&lt;/span&gt; Contact &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0066CC;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;var&lt;/span&gt; _firstName:&lt;span style=&quot;color: #0066CC;&quot;&gt;String&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0066CC;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;var&lt;/span&gt; _lastName:&lt;span style=&quot;color: #0066CC;&quot;&gt;String&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; ContactImpl&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;x : &lt;span style=&quot;color: #0066CC;&quot;&gt;XML&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; _firstName = x.@first;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; _lastName = x.@last;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Other initiation&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0066CC;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; sendMail&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0066CC;&quot;&gt;text&lt;/span&gt; : &lt;span style=&quot;color: #0066CC;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; : &lt;span style=&quot;color: #0066CC;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Mail sending implementation&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0066CC;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; &lt;span style=&quot;color: #0066CC;&quot;&gt;get&lt;/span&gt; firstName&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; : &lt;span style=&quot;color: #0066CC;&quot;&gt;String&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; _firstName;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0066CC;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; &lt;span style=&quot;color: #0066CC;&quot;&gt;get&lt;/span&gt; lastName&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; : &lt;span style=&quot;color: #0066CC;&quot;&gt;String&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; _lastName;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/code&gt;
&lt;p&gt;L'utilisation de cette classe donnerait:&lt;/p&gt;
&lt;code class=&quot;actionscript&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;var&lt;/span&gt; &lt;span style=&quot;color: #0066CC;&quot;&gt;list&lt;/span&gt; : ContactList = &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; ContactList&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&amp;lt;dataprovider&amp;gt;&amp;lt;contacts&amp;gt;&amp;lt;contact first=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Alexandre&amp;quot;&lt;/span&gt; last=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;LEGOUT&amp;quot;&lt;/span&gt; /&amp;gt;&amp;lt;contact first=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Gérard&amp;quot;&lt;/span&gt; last=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;DUPONT&amp;quot;&lt;/span&gt; /&amp;gt;&amp;lt;/contacts&amp;gt;&amp;lt;/dataprovider&amp;gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&lt;span style=&quot;color: #0066CC;&quot;&gt;list&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;selectContactAt&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;var&lt;/span&gt; selected : Contact = &lt;span style=&quot;color: #0066CC;&quot;&gt;list&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;selectedContact&lt;/span&gt;;&lt;br /&gt;
&lt;span style=&quot;color: #0066CC;&quot;&gt;trace&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;selected.&lt;span style=&quot;color: #006600;&quot;&gt;firstName&lt;/span&gt; + &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot; &amp;quot;&lt;/span&gt; + selected.&lt;span style=&quot;color: #006600;&quot;&gt;lastName&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/code&gt;
&lt;p&gt;Et voilà, on a accès depuis l'extérieur de la classe à tous les
comportements &amp;quot;publics&amp;quot; d'un contact, sans avoir accés à son implémentation!
&lt;img src=&quot;http://common.lalex.com/themes/devblog/smilies/icon_cool.gif&quot; alt=&quot;8-)&quot; class=&quot;smiley&quot; /&gt;&lt;br /&gt;
Alors je sais que c'est justement le but des interfaces, mais j'ai trouvé cette
utilisation intéressante, et assez représentative de l'utilité des interfaces,
au cas où vous ne seriez pas encore convaincus... &lt;img src=&quot;http://common.lalex.com/themes/devblog/smilies/icon_wink.gif&quot; alt=&quot;;)&quot; class=&quot;smiley&quot; /&gt;&lt;/p&gt;</description>
    
    
    
          <comments>http://blog.lalex.com/post/2007/12/17/Interfaces-et-classes-internal#comment-form</comments>
      <wfw:comment>http://blog.lalex.com/post/2007/12/17/Interfaces-et-classes-internal#comment-form</wfw:comment>
      <wfw:commentRss>http://blog.lalex.com/feed/rss2/comments/380</wfw:commentRss>
      </item>
    
  <item>
    <title>Tweens: frame-based vs. time-based</title>
    <link>http://blog.lalex.com/post/2007/12/03/Tweens%3A-frame-based-vs-time-based</link>
    <guid isPermaLink="false">urn:md5:f8cfe57b664ab8734309702ef6bbd693</guid>
    <pubDate>Mon, 03 Dec 2007 15:55:00 +0100</pubDate>
    <dc:creator>-Alexandre LEGOUT aka LAlex-</dc:creator>
        <category>AS3 / Flex2</category>
            
    <description>&lt;p&gt;Actuellement en train de travailler sur un séquenceur de différents types
d'action, incluant notamment les interpolations, j'en viens à re-développer une
classe de Tween, incluant les améliorations standards des TweenEngine en
circulation sur la toile (tween de plusieurs propriétés par exemple).&lt;/p&gt;
&lt;p&gt;Tout d'abord, il faut savoir qu'un tween a un principe tout simple: je veux
qu'une propriété numérique d'un objet (le plus souvent un objet visuel, comme
un Sprite par exemple) évolue entre une valeur de départ et une valeur
d'arrivée sur une durée précise. Une équation est utilisée afin de déterminer
l'évolution de cette valeur, la plus simple étant une équation linéaire (on
partage la distance en intervalles réguliers).&lt;/p&gt;
&lt;p&gt;Pour cela, il existe trois méthodes:&lt;/p&gt;    &lt;h2&gt;Le frame-based&lt;/h2&gt;
&lt;p&gt;&lt;ins&gt;Caractéristiques&lt;/ins&gt;: La durée du tween est donnée en nombre de
frames, et le calcul de chaque position se fait à chaque frame (typiquement, en
écoutant l'évènement &lt;em&gt;Event.ENTER_FRAME&lt;/em&gt;)&lt;br /&gt;
&lt;ins&gt;Concept&lt;/ins&gt;: à chaque calcul, on regarde le nombre de frames écoulé
depuis le départ par rapport à la durée en nombre de frames.&lt;br /&gt;
&lt;ins&gt;Avantages&lt;/ins&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;On travaille avec des nombres entiers et invariants concernant la position
courante dans le temps (nombre de frames écoulé) et la durée. Il devient donc
possible de cacher une interpolation et donc de réduire les temps de calcul
pour les interpolations suivantes utilisant le même couple équation/durée. En
effet, une équation donnée sur une durée donnée se comportera toujours de la
même manière. En gros, elle sera toujours à x% de son trajet à la n-ième frame,
et c'est donc possible de le mettre en cache.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;ins&gt;Inconvénient&lt;/ins&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;L'intervalle de temps entre deux frames n'est pas fixe: si lors de
l'exécution d'une frame un code oblige à ralentir le framerate, le player flash
le fera automatiquement. Cela est probablement du à son mode d'exécution
mono-threadé. Donc, sur une animation à 30fps, un tween d'une durée de 30 peut
prendre plus d'une seconde... L'autre inconvénient, qui peut aussi être un
comportement voulu, est que modifier le FPS global de l'animation revient à
modifier la vitesse d'interpolation.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Le time-based&lt;/h2&gt;
&lt;p&gt;&lt;ins&gt;Caractéristiques&lt;/ins&gt;: La durée du tween est donnée en seconde, et le
calcul de chaque position est faite à un intervalle de temps donné (typiquement
avec &lt;em&gt;setInterval&lt;/em&gt;, ou plus &amp;quot;clean&amp;quot; avec la classe
&lt;em&gt;Timer&lt;/em&gt;).&lt;br /&gt;
&lt;ins&gt;Concept&lt;/ins&gt;: un Timer lance le calcul de la nouvelle position toutes les
&lt;em&gt;x&lt;/em&gt; millisecondes. La base de calcul est le nombre de millisecondes
écoulées sur la durée en nombre de millisecondes. Un
TimerEvent.updateAfterEvent s'occupe de rafraichir l'affichage indépendamment
du framerate.&lt;br /&gt;
&lt;ins&gt;Avantages&lt;/ins&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;L'interpolation se fait sur une notion de temps. Bien que le Timer ne soit
pas forcément extrêmement précis, c'est ce qu'on peut obtenir de plus proche.
Ainsi, le taux de rafraichissement du tween peut même être configurable
dynamiquement. Par exemple, on pourrait avoir un tween fluide sur une animation
pourtant compilée à 2FPS.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;ins&gt;Inconvénients&lt;/ins&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Justement, on ne contrôle pas la synchronisation anim/temps. Du coup, on
surcharge beaucoup le moteur d'affichage du Flash Player, qui doit rafraichir
l'affichage à chaque frame &lt;strong&gt;mais aussi&lt;/strong&gt; à chaque calcul du
tween. Il est également trés dur de synchroniser deux tweens: en effet, deux
&lt;em&gt;Timer&lt;/em&gt; de même durée peuvent dispatcher à plusieurs millisecondes
d'intervalle, décalant d'autant les traitements.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Le &amp;quot;frame/time-based&amp;quot;&lt;/h2&gt;
&lt;p&gt;&lt;ins&gt;Caractéristiques&lt;/ins&gt;: Mix entre le time-based et le frame-based: la
durée du tween est donnée en secondes, et le calcul de chaque position se fait
à chaque frame.&lt;br /&gt;
&lt;ins&gt;Concept&lt;/ins&gt;: A chaque frame, on calcule le temps écoulé en millisecondes
depuis le départ sur la durée totale en millisecondes&lt;br /&gt;
&lt;ins&gt;Avantage&lt;/ins&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;On obtient les avantages combinés du frame-based (économie du moteur
d'affichage) et du time-based (durée constante, indépendante du
framerate).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;ins&gt;Inconvénient&lt;/ins&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;La fluidité de l'anim nécessitera un FPS élevé, comme pour le frame-based:
fini les anims fluides à 2FPS! &lt;img src=&quot;http://common.lalex.com/themes/devblog/smilies/icon_wink.gif&quot; alt=&quot;;)&quot; class=&quot;smiley&quot; /&gt;&lt;/li&gt;
&lt;li&gt;Comme pour le time-based, il est difficile de synchroniser les tweens entre
eux, ou alors ils peuvent être synchronisés alors qu'ils ne devraient pas. En
effet, admettons qu'une frame s'affiche toutes les 100ms
&lt;strong&gt;exactement&lt;/strong&gt; (je sais, un monde parfait n'existe pas, mais
faites comme si). Le framerate est volontairement bas (10FPS) pour l'exemple.
Deux tweens commencant exactement au même moment, et ayant des durées
respectives de 820 et 880ms finiront en même temps, sur la frame 9. En effet,
sur la frame 8, 800ms se sont écoulées, et le prochain calcul, qui déterminera
la fin des deux tweens, se fera à la frame suivante, soit à 900ms.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Quel mode pour quel usage?&lt;/h2&gt;
&lt;p&gt;Le mode à utiliser est extrêmement propre à l'usage auquel il est destiné.
Les moteurs existants utilisent souvent par défault la troisième option
(frame/time-based), et proposent assez souvent la première (frame-based). Le
deuxième reste la plus marginale, mais est tout de même proposée dans quelques
moteurs/classes. Globalement, je suggèrerais:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;ins&gt;frame-based&lt;/ins&gt;: si vous avez le &lt;strong&gt;contrôle de votre
environnement de déploiement&lt;/strong&gt; ou un &lt;strong&gt;framerate connu et
fixe&lt;/strong&gt;, ce mode ci devrait être le plus performant car travaillant sur
des petits nombres et &amp;quot;cachables&amp;quot; (sauf aprés calcul dans l'équation).
Egalement bien utile quand on a un besoin de &lt;strong&gt;synchronisation très
précise&lt;/strong&gt; (sauf avec les classes de Tween d'Adobe, voire poste
précédent) entre différents tweens, ou quand on travaille avec beaucoup
d'éléments &lt;strong&gt;issus de la timeline&lt;/strong&gt; (trés fréquent quand on
travaille avec un graphiste/animateur flash) avec lesquels vous devez vous
caler.&lt;/li&gt;
&lt;li&gt;&lt;ins&gt;time-based&lt;/ins&gt;: a priori le moins utilisé (y compris par les
TweenEngine). Il est le moins performant car il rajoute du travail au moteur
d'affichage du Flash Player. A utiliser si vous avez besoin d'une
&lt;strong&gt;fluidité constante&lt;/strong&gt; quel que soit le framerate. S'il vous faut
uniquement des interpolations dont la vitesse est indépendante, voir le
&amp;quot;frame/time-based&amp;quot;.&lt;/li&gt;
&lt;li&gt;&lt;ins&gt;frame/time-based&lt;/ins&gt;: utile pour avoir une durée a peu prés
constante &lt;strong&gt;indépendamment du framerate&lt;/strong&gt;. Très utilisé
&lt;strong&gt;avec les vidéos ou les sons&lt;/strong&gt; par exemple, il se positionne
systématiquement au bon endroit selon le temps &amp;quot;réel&amp;quot; écoulé, quel que soit le
nombre de calculs déjà effectués. En bref, même si l'appli &amp;quot;rame&amp;quot;, votre tween
sera plus ou moins synchro. Interessant aussi &lt;strong&gt;quand on ignore le
framerate&lt;/strong&gt; qui sera utilisé par l'application et qu'on désire conserver
la vitesse des interpolations, si votre anim est &lt;strong&gt;chargée par un
Loader&lt;/strong&gt; par exemple (dans un site portail, un CMS, etc...).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Perso, quand je sais que mon SWF va tourner &amp;quot;tout seul&amp;quot;, j'utilise beaucoup
de frame-based, avec un &amp;quot;stabilisateur&amp;quot; de framerate (type &lt;a href=&quot;http://blog.andre-michelle.com/2006/stable-fps-test/&quot; hreflang=&quot;en&quot;&gt;celui
d'André Michelle&lt;/a&gt;) pour être sur qu'il sera vu de la même manière par tout
le monde...&lt;/p&gt;</description>
    
    
    
          <comments>http://blog.lalex.com/post/2007/12/03/Tweens%3A-frame-based-vs-time-based#comment-form</comments>
      <wfw:comment>http://blog.lalex.com/post/2007/12/03/Tweens%3A-frame-based-vs-time-based#comment-form</wfw:comment>
      <wfw:commentRss>http://blog.lalex.com/feed/rss2/comments/375</wfw:commentRss>
      </item>
    
  <item>
    <title>Tweens Flash CS3</title>
    <link>http://blog.lalex.com/post/2007/10/30/Tweens-Flash-CS3</link>
    <guid isPermaLink="false">urn:md5:22dd7ecebd2aea324cca853e507f1230</guid>
    <pubDate>Tue, 30 Oct 2007 16:50:00 +0100</pubDate>
    <dc:creator>-Alexandre LEGOUT aka LAlex-</dc:creator>
        <category>AS3 / Flex2</category>
            
    <description>    &lt;p&gt;Je me rend compte carrément tard par rapport au temps depuis lequel
j'utilise les Tweens, mais aviez-vous remarqué que la classe fournie par Adobe
dans Flash CS3 (&lt;em&gt;fl.transitions.Tween&lt;/em&gt;) émettait l'évènement de fin
(&lt;em&gt;TweenEvent.MOTION_FINISH&lt;/em&gt;) une frame trop tard? La raison est simple,
le test effectué pour détecter la fin est strict:&lt;/p&gt;
&lt;code class=&quot;actionscript&quot;&gt;&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;t &amp;gt; &lt;span style=&quot;color: #0066CC;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #0066CC;&quot;&gt;duration&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/code&gt;
&lt;p&gt;Il suffirait d'un '&amp;gt;=' à la place pour modifier cela, mais à ce moment là
la fonctionnalité de boucle zapperais une frame avant de boucler...&lt;/p&gt;
&lt;p&gt;Les Tweens de Flex et des &amp;quot;tween engines&amp;quot; que j'ai vu en AS3 (&lt;a href=&quot;http://blog.greensock.com/tweenliteas3&quot; hreflang=&quot;en&quot;&gt;TweenLite&lt;/a&gt; et
&lt;a href=&quot;http://code.google.com/p/tweener/&quot; hreflang=&quot;en&quot;&gt;Tweener&lt;/a&gt;) n'ont
pas ce défaut par contre...&lt;/p&gt;</description>
    
    
    
          <comments>http://blog.lalex.com/post/2007/10/30/Tweens-Flash-CS3#comment-form</comments>
      <wfw:comment>http://blog.lalex.com/post/2007/10/30/Tweens-Flash-CS3#comment-form</wfw:comment>
      <wfw:commentRss>http://blog.lalex.com/feed/rss2/comments/371</wfw:commentRss>
      </item>
    
  <item>
    <title>Des coquilles dans l'AS3</title>
    <link>http://blog.lalex.com/post/2007/07/27/Des-coquilles-dans-AS3</link>
    <guid isPermaLink="false">urn:md5:bcf32fa4aee085aa62af2de04a55d85c</guid>
    <pubDate>Fri, 27 Jul 2007 18:44:00 +0200</pubDate>
    <dc:creator>-Alexandre LEGOUT aka LAlex-</dc:creator>
        <category>AS3 / Flex2</category>
            
    <description>    &lt;p&gt;Aprés maintenant quelques un grand nombre de lignes de code en AS3, j'ai
noté quelques comportements bizarres...&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;la propriété &amp;quot;constructor&amp;quot; de la classe Object ne semble pas être déclarée
comme publique. Donc, on se retrouve avec une contradiction entre la doc et la
réalité... et surtout aucun moyen de connaitre la classe qui a servie à créer
l'objet. Un workaround existe utilisant &lt;em&gt;describeType&lt;/em&gt;:&lt;/li&gt;
&lt;/ul&gt;
&lt;code class=&quot;actionscript&quot;&gt;&lt;span style=&quot;color: #0066CC;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; ClassUtils&lt;br /&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0066CC;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0066CC;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; getConstructor&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;o : *&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; : &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;Class&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;var&lt;/span&gt; clname:&lt;span style=&quot;color: #0066CC;&quot;&gt;String&lt;/span&gt; = describeType&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;o&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;.@&lt;span style=&quot;color: #0066CC;&quot;&gt;name&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;toXMLString&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;var&lt;/span&gt; claz:&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;Class&lt;/span&gt; = getDefinitionByName&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;clname&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; as &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;Class&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; claz;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/code&gt;
&lt;ul&gt;
&lt;li&gt;imaginons que je crée une interface vide (ainsi que son implémentation) qui
me sert uniquement à indiquer l'appartenance à deux types simultanément: en
gros, une interface qui hérite de deux interfaces. Si ces deux interfaces mères
ont une méthode commune et que j'utilise mon interface fille pour typer une
variable, le compilateur va me remonter une erreur comme quoi la référence à
cette méthode est ambigue. Ceci est tout à fait inconcevable, car il est clair
que l'implémentation utilisée sera évidemment unique! Bon, étant donné que ce
charabia doit être super flou, voici un exemple:&lt;/li&gt;
&lt;/ul&gt;
&lt;code class=&quot;actionscript&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Voir plus bas pour les différentes interfaces&lt;/span&gt;&lt;br /&gt;
package &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0066CC;&quot;&gt;import&lt;/span&gt; flash.&lt;span style=&quot;color: #006600;&quot;&gt;display&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;Sprite&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0066CC;&quot;&gt;import&lt;/span&gt; itf.&lt;span style=&quot;color: #006600;&quot;&gt;IDataSet&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0066CC;&quot;&gt;import&lt;/span&gt; itf.&lt;span style=&quot;color: #006600;&quot;&gt;IList&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0066CC;&quot;&gt;import&lt;/span&gt; cl.&lt;span style=&quot;color: #006600;&quot;&gt;DataSet&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0066CC;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; ASPlayground &lt;span style=&quot;color: #0066CC;&quot;&gt;extends&lt;/span&gt; Sprite&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0066CC;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; ASPlayground&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;var&lt;/span&gt; ids:IDataSet = &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; DataSet;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0066CC;&quot;&gt;trace&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;ids.&lt;span style=&quot;color: #006600;&quot;&gt;getLength&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Erreur du compilateur: Référence ambiguë à getLength.&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0066CC;&quot;&gt;trace&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;ids as IList&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;getLength&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Marche bien !&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
package itf&lt;br /&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0066CC;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0066CC;&quot;&gt;interface&lt;/span&gt; IList&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; getLength&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; : &lt;span style=&quot;color: #0066CC;&quot;&gt;int&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
package itf&lt;br /&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0066CC;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0066CC;&quot;&gt;interface&lt;/span&gt; ICollection&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; getLength&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; : &lt;span style=&quot;color: #0066CC;&quot;&gt;int&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Cette interface sert au typage&lt;/span&gt;&lt;br /&gt;
package itf&lt;br /&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0066CC;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0066CC;&quot;&gt;interface&lt;/span&gt; IDataSet &lt;span style=&quot;color: #0066CC;&quot;&gt;extends&lt;/span&gt; IList, ICollection&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Implémentation de IDataSet&lt;/span&gt;&lt;br /&gt;
package cl&lt;br /&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0066CC;&quot;&gt;import&lt;/span&gt; itf.&lt;span style=&quot;color: #006600;&quot;&gt;IDataSet&lt;/span&gt;;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0066CC;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; DataSet &lt;span style=&quot;color: #0066CC;&quot;&gt;implements&lt;/span&gt; IDataSet&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0066CC;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; getLength&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;:&lt;span style=&quot;color: #0066CC;&quot;&gt;int&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;-1&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/code&gt;
&lt;p&gt;Rien de bien gênant, mais ca peut parfois être troublant! &lt;img src=&quot;http://common.lalex.com/themes/devblog/smilies/icon_wink.gif&quot; alt=&quot;;)&quot; class=&quot;smiley&quot; /&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Le workaround du premier problême fait surtout chuter les performances&lt;/li&gt;
&lt;li&gt;Le deuxième problême par contre ne sacrifie en rien les performances, mais
peut-être gênant si on ne connait pas les interfaces mères...&lt;/li&gt;
&lt;/ul&gt;</description>
    
    
    
          <comments>http://blog.lalex.com/post/2007/07/27/Des-coquilles-dans-AS3#comment-form</comments>
      <wfw:comment>http://blog.lalex.com/post/2007/07/27/Des-coquilles-dans-AS3#comment-form</wfw:comment>
      <wfw:commentRss>http://blog.lalex.com/feed/rss2/comments/364</wfw:commentRss>
      </item>
    
  <item>
    <title>AS3 - Vérifier qu'une classe hérite d'une autre...</title>
    <link>http://blog.lalex.com/post/2007/04/06/AS3-Verifier-une-classe-herite-dune-autre</link>
    <guid isPermaLink="false">urn:md5:9bea6869c74985631453e7256a5db192</guid>
    <pubDate>Fri, 06 Apr 2007 16:40:00 +0200</pubDate>
    <dc:creator>-Alexandre LEGOUT aka LAlex-</dc:creator>
        <category>AS3 / Flex2</category>
            
    <description>    &lt;p&gt;Ayant eu besoin de m'assurer qu'une classe (instance de Class) hérite d'une
autre, j'ai cherché un bon moment à reproduire mes anciennes habitudes issues
de l'AS2, à savoir utiliser les bons vieux prototypes agrémentés d'une touche
de &amp;quot;is&amp;quot; histoire de faire plus actuel... &lt;img src=&quot;http://common.lalex.com/themes/devblog/smilies/icon_razz.gif&quot; alt=&quot;:-P&quot; class=&quot;smiley&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Autant vous le dire tout de suite: ca ne donne rien! &lt;img src=&quot;http://common.lalex.com/themes/devblog/smilies/icon_mrgreen.gif&quot; alt=&quot;:=)&quot; class=&quot;smiley&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Il faut donc se tourner vers les excellentes fonctions de reflexion que nous
fournis l'AS3 pour arriver à son bonheur, en agrémentant ca de E4X! &lt;img src=&quot;http://common.lalex.com/themes/devblog/smilies/icon_wink.gif&quot; alt=&quot;;-)&quot; class=&quot;smiley&quot; /&gt;&lt;/p&gt;
&lt;code class=&quot;actionscript&quot;&gt;&lt;span style=&quot;color: #0066CC;&quot;&gt;import&lt;/span&gt; flash.&lt;span style=&quot;color: #006600;&quot;&gt;utils&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;describeType&lt;/span&gt;;&lt;br /&gt;
&lt;span style=&quot;color: #0066CC;&quot;&gt;import&lt;/span&gt; flash.&lt;span style=&quot;color: #006600;&quot;&gt;utils&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;getQualifiedClassName&lt;/span&gt;;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #0066CC;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; inherit&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;childClass:&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;Class&lt;/span&gt;, parentClass:&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;Class&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; : &lt;span style=&quot;color: #0066CC;&quot;&gt;Boolean&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; describeType&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;childClass&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;factory&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;extendsClass&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;/span&gt;@&lt;span style=&quot;color: #0066CC;&quot;&gt;type&lt;/span&gt;==getQualifiedClassName&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;parentClass&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #0066CC;&quot;&gt;length&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &amp;gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;;&lt;br /&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/code&gt;
&lt;p&gt;Et wala! &lt;img src=&quot;http://common.lalex.com/themes/devblog/smilies/icon_cool.gif&quot; alt=&quot;8-)&quot; class=&quot;smiley&quot; /&gt;&lt;/p&gt;</description>
    
    
    
          <comments>http://blog.lalex.com/post/2007/04/06/AS3-Verifier-une-classe-herite-dune-autre#comment-form</comments>
      <wfw:comment>http://blog.lalex.com/post/2007/04/06/AS3-Verifier-une-classe-herite-dune-autre#comment-form</wfw:comment>
      <wfw:commentRss>http://blog.lalex.com/feed/rss2/comments/343</wfw:commentRss>
      </item>
    
</channel>
</rss>