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

<channel>
	<title>Nicolas Valois - Actionscript 3 Lab &#38; Blog</title>
	<atom:link href="http://blog.nvalois.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.nvalois.com</link>
	<description>Expérimentations et tutoriaux</description>
	<lastBuildDate>Mon, 01 Aug 2011 16:02:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>Création : le Factory Method Pattern</title>
		<link>http://blog.nvalois.com/creation-factory-method-pattern/</link>
		<comments>http://blog.nvalois.com/creation-factory-method-pattern/#comments</comments>
		<pubDate>Fri, 29 Jul 2011 13:28:31 +0000</pubDate>
		<dc:creator>Nicolas</dc:creator>
				<category><![CDATA[Design Patterns]]></category>
		<category><![CDATA[Tutoriaux]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[Design Pattern]]></category>
		<category><![CDATA[Factory]]></category>

		<guid isPermaLink="false">http://blog.nvalois.com/?p=351</guid>
		<description><![CDATA[<p>Le rôle d&#039;une Factory est d&#039;instancier des objets de différents types sans spécifier la classe de l&#039;objet qui sera créer. Son avantage est d&#039;éviter la redondance entre ces classes.
Les Factory Method sont en général implémenter par un <a href="http://blog.nvalois.com/creation-singleton-pattern/">Singleton</a>.</p>

<span style="color: #9900cc; font-weight: bold;">package</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> ProductFactory
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; [...]]]></description>
			<content:encoded><![CDATA[<p>Le rôle d&#039;une Factory est d&#039;instancier des objets de différents types sans spécifier la classe de l&#039;objet qui sera créer. Son avantage est d&#039;éviter la redondance entre ces classes.<br />
Les Factory Method sont en général implémenter par un <a href="http://blog.nvalois.com/creation-singleton-pattern/">Singleton</a>.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> ProductFactory
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> ProductFactory<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0033ff; font-weight: bold;">throw</span> <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Error</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Utilisez ProductFactory.getProduct(...) pour accéder à cette classe.&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #339966; font-weight: bold;">function</span> getProduct<span style="color: #000000;">&#40;</span>product<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">String</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span>IProduct
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>product == <span style="color: #990000;">&quot;p1&quot;</span><span style="color: #000000;">&#41;</span>
            <span style="color: #000000;">&#123;</span>
                <span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #0033ff; font-weight: bold;">new</span> Product1<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
            <span style="color: #000000;">&#125;</span><span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>product == <span style="color: #990000;">&quot;p2&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
                <span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #0033ff; font-weight: bold;">new</span> Product2<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
            <span style="color: #000000;">&#125;</span><span style="color: #0033ff; font-weight: bold;">else</span><span style="color: #000000;">&#123;</span>
                <span style="color: #0033ff; font-weight: bold;">throw</span> <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Error</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Aucun type ne correspond à ce produit&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
            <span style="color: #000000;">&#125;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p><strong>Explications :</strong><br />
On remarque que la classe ressemble étrangement à un Singleton, sans être instancié; getProduct remplaçant getInstance.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #339966; font-weight: bold;">function</span> getProduct<span style="color: #000000;">&#40;</span>product<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">String</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span>IProduct</pre></div></div>

<p>En fonction d&#039;un paramètre, la Factory Method va retourner le type correspondant. Tous les types retournés auront des paramètres en commun que l&#039;on regroupe dans l&#039;interface IProduct.</p>
<p>Pour appeler cette classe, on fera ainsi :</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> product<span style="color: #000066; font-weight: bold;">:</span>IProduct = ProductFactory<span style="color: #000066; font-weight: bold;">.</span>getProduct<span style="color: #000000;">&#40;</span>productID<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.nvalois.com/creation-factory-method-pattern/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Création : le Singleton Pattern</title>
		<link>http://blog.nvalois.com/creation-singleton-pattern/</link>
		<comments>http://blog.nvalois.com/creation-singleton-pattern/#comments</comments>
		<pubDate>Wed, 27 Jul 2011 10:26:56 +0000</pubDate>
		<dc:creator>Nicolas</dc:creator>
				<category><![CDATA[Design Patterns]]></category>
		<category><![CDATA[Tutoriaux]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[Design Pattern]]></category>
		<category><![CDATA[Singleton]]></category>

		<guid isPermaLink="false">http://blog.nvalois.com/?p=340</guid>
		<description><![CDATA[<p>Le Singleton est utilisé un peu partout, comme par exemple pour les classes mx.managers (DragManager, CursorManager, &#8230;). On l&#039;utilise par exemple pour enregistrer des données persistantes (ex: score d&#039;un jeu). Son intérêt est de posséder une et une seule instance de la classe. Elle est accessible de partout et doit donc avoir un seul point d&#039;accès global.</p>

<span style="color: #9900cc; font-weight: bold;">package</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> Singleton
    [...]]]></description>
			<content:encoded><![CDATA[<p>Le Singleton est utilisé un peu partout, comme par exemple pour les classes mx.managers (DragManager, CursorManager, &#8230;). On l&#039;utilise par exemple pour enregistrer des données persistantes (ex: score d&#039;un jeu). Son intérêt est de posséder une et une seule instance de la classe. Elle est accessible de partout et doit donc avoir un seul point d&#039;accès global.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> Singleton
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0033ff; font-weight: bold;">private</span> static <span style="color: #6699cc; font-weight: bold;">var</span> _instance<span style="color: #000066; font-weight: bold;">:</span>Singleton<span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
        <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> Singleton<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span> _instance <span style="color: #000000;">&#41;</span> 
                <span style="color: #0033ff; font-weight: bold;">throw</span> <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Error</span><span style="color: #000000;">&#40;</span> <span style="color: #990000;">&quot;Utilisez Singleton.getInstance() pour accéder à cette classe.&quot;</span> <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> 
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #339966; font-weight: bold;">function</span> getInstance<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span>Singleton
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>_instance == <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span>
                _instance = <span style="color: #0033ff; font-weight: bold;">new</span> Singleton<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
            <span style="color: #0033ff; font-weight: bold;">return</span> _instance<span style="color: #000066; font-weight: bold;">;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p><strong>Explications :</strong></p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">private</span> static <span style="color: #6699cc; font-weight: bold;">var</span> _instance<span style="color: #000066; font-weight: bold;">:</span>Singleton<span style="color: #000066; font-weight: bold;">;</span></pre></div></div>

<p>On passe l&#039;instance en <em>private</em> pour empêcher un accès depuis l&#039;extérieur de la classe. L&#039;attribut static autorise un accès depuis à la variable depuis une méthode statique (implicitement Singleton._instance).</p>
<p>&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #339966; font-weight: bold;">function</span> getInstance<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span>Singleton</pre></div></div>

<p>Donne un accès depuis l&#039;extérieur à l&#039;instance. <em>_instance</em> est instancié, une et une seule fois, au premier appel. On peux également directement l&#039;instancier dans la déclaration.</p>
<p>&nbsp;</p>
<p>Ensuite on peux ajouter ses méthodes et getter/setter que l&#039;on appellera de la façon suivante :</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;">Singleton<span style="color: #000066; font-weight: bold;">.</span>getInstance<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span>score</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.nvalois.com/creation-singleton-pattern/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Différence entre currentTarget et target</title>
		<link>http://blog.nvalois.com/difference-entre-currenttarget-et-target/</link>
		<comments>http://blog.nvalois.com/difference-entre-currenttarget-et-target/#comments</comments>
		<pubDate>Fri, 03 Jun 2011 11:16:24 +0000</pubDate>
		<dc:creator>Nicolas</dc:creator>
				<category><![CDATA[Tutoriaux]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[currentTarget]]></category>
		<category><![CDATA[target]]></category>

		<guid isPermaLink="false">http://blog.nvalois.com/?p=311</guid>
		<description><![CDATA[<p>Lorsque l&#039;on ajoute un écouteur sur un objet, un objet Event est transmis comme paramètre quand un évènement se produit.</p>

<span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">MouseEvent</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">CLICK</span><span style="color: #000066; font-weight: bold;">,</span> clickHandler<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&#160;
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> clickHandler<span style="color: #000000;">&#40;</span>event<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> 
<span [...]]]></description>
			<content:encoded><![CDATA[<p>Lorsque l&#039;on ajoute un écouteur sur un objet, un objet Event est transmis comme paramètre quand un évènement se produit.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">MouseEvent</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">CLICK</span><span style="color: #000066; font-weight: bold;">,</span> clickHandler<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> clickHandler<span style="color: #000000;">&#40;</span>event<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> 
<span style="color: #000000;">&#123;</span>
     <span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Click&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>L&#039;objet Event possède deux propriétés importantes : event.currentTarget et event.target.<br />
currentTarget renvoie l&#039;objet qui traite l’évènement tandis que target renvoie l&#039;objet l&#039;enfant (le noeud cible) qui a déclenché l’évènement.</p>
<p>Pour mieux comprendre, prenons un exemple simple :<br />
Imaginons le cas ou nous avons un objet carré qui contient un objet rond. On ajoute un écouteur au click sur le carré (donc le conteneur). Si l&#039;on click sur le rond, l&#039;event.target renverra le rond tandis que l&#039;event.currentTarget renverra toujours le carré.<br />

<object width="500" height="200">
<param name="movie" value="../wp-content/uploads/2011/06/target.swf"></param>
<param name="quality" value="high"></param>
<param name="wmode" value="window"></param>
<param name="menu" value="false"></param>
<param name="bgcolor" value="#FFFFFF"></param>
<embed type="application/x-shockwave-flash" width="500" height="200" src="../wp-content/uploads/2011/06/target.swf" quality="high" bgcolor="#FFFFFF" wmode="window" menu="false" ></embed>
</object>
</p>
<p>Sauf cas particulier, il faut donc veiller à bien utiliser currentTarget et non simplement target, qui peut référer à un sous-contenant non désiré.</p>
<p>Attention à l’évènement ROLL_OVER qui ne fera pas cette différence :<br />
<a href="http://blog.nvalois.com/difference-entre-roll_over-et-mouse_over/">Différence entre ROLL_OVER et MOUSE_OVER</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nvalois.com/difference-entre-currenttarget-et-target/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Exemple d&#039;utilisation de QuickB2</title>
		<link>http://blog.nvalois.com/exemple-d-utilisation-de-quickb2/</link>
		<comments>http://blog.nvalois.com/exemple-d-utilisation-de-quickb2/#comments</comments>
		<pubDate>Thu, 26 May 2011 10:20:19 +0000</pubDate>
		<dc:creator>Nicolas</dc:creator>
				<category><![CDATA[Jeux]]></category>
		<category><![CDATA[Tutoriaux]]></category>
		<category><![CDATA[jeu]]></category>
		<category><![CDATA[moteur phisique]]></category>
		<category><![CDATA[quickb2]]></category>

		<guid isPermaLink="false">http://blog.nvalois.com/?p=300</guid>
		<description><![CDATA[<p>Comme <a href="http://blog.nvalois.com/presentation-de-quickb2/">présenté ici</a> QuickB2 est une version simplifié de Box2D. Vous pouvez bien sur consulter les exemples avec sources sur leur site internet ou dans le moteur (QuickB2_0_6\QuickB2\examples\qb2DemoReel\).
Sinon vous pouvez télécharger l&#039;exemple que je vous ai préparé. J&#039;ai simplement repris et allégé la classe CarDriving.as, ça pourrait en aider certains si vous avez du mal à l&#039;installer ou à faire fonctionner les exemples. Voici ce que l&#039;on obtiens :</p>
<p>








</p>
<p>Et voici ma classe:</p>

<span style="color: #9900cc; font-weight: bold;">package</span> 
<span style="color: #000000;">&#123;</span>
	<span [...]]]></description>
			<content:encoded><![CDATA[<p>Comme <a href="http://blog.nvalois.com/presentation-de-quickb2/">présenté ici</a> QuickB2 est une version simplifié de Box2D. Vous pouvez bien sur consulter les exemples avec sources sur leur site internet ou dans le moteur (QuickB2_0_6\QuickB2\examples\qb2DemoReel\).<br />
Sinon vous pouvez télécharger l&#039;exemple que je vous ai préparé. J&#039;ai simplement repris et allégé la classe CarDriving.as, ça pourrait en aider certains si vous avez du mal à l&#039;installer ou à faire fonctionner les exemples. Voici ce que l&#039;on obtiens :</p>
<p>
<object width="500" height="400">
<param name="movie" value="../wp-content/uploads/2011/05/car-driving.swf"></param>
<param name="quality" value="high"></param>
<param name="wmode" value="window"></param>
<param name="menu" value="false"></param>
<param name="bgcolor" value="#FFFFFF"></param>
<embed type="application/x-shockwave-flash" width="500" height="400" src="../wp-content/uploads/2011/05/car-driving.swf" quality="high" bgcolor="#FFFFFF" wmode="window" menu="false" ></embed>
</object>
</p>
<p>Et voici ma classe:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> 
<span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> As3Math<span style="color: #000066; font-weight: bold;">.</span>geo2d<span style="color: #000066; font-weight: bold;">.*;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> As3Math<span style="color: #000066; font-weight: bold;">.</span>consts<span style="color: #000066; font-weight: bold;">.*;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.*;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> QuickB2<span style="color: #000066; font-weight: bold;">.</span>events<span style="color: #000066; font-weight: bold;">.</span>qb2ContainerEvent<span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> QuickB2<span style="color: #000066; font-weight: bold;">.</span>objects<span style="color: #000066; font-weight: bold;">.</span>tangibles<span style="color: #000066; font-weight: bold;">.*;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> QuickB2<span style="color: #000066; font-weight: bold;">.</span>stock<span style="color: #000066; font-weight: bold;">.*;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> TopDown<span style="color: #000066; font-weight: bold;">.</span>ai<span style="color: #000066; font-weight: bold;">.</span>brains<span style="color: #000066; font-weight: bold;">.</span>tdControllerBrain<span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> TopDown<span style="color: #000066; font-weight: bold;">.</span>ai<span style="color: #000066; font-weight: bold;">.</span>controllers<span style="color: #000066; font-weight: bold;">.</span>tdKeyboardCarController<span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> TopDown<span style="color: #000066; font-weight: bold;">.</span>carparts<span style="color: #000066; font-weight: bold;">.</span>tdEngine<span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> TopDown<span style="color: #000066; font-weight: bold;">.</span>carparts<span style="color: #000066; font-weight: bold;">.</span>tdTire<span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> TopDown<span style="color: #000066; font-weight: bold;">.</span>carparts<span style="color: #000066; font-weight: bold;">.</span>tdTorqueCurve<span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> TopDown<span style="color: #000066; font-weight: bold;">.</span>carparts<span style="color: #000066; font-weight: bold;">.</span>tdTransmission<span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> TopDown<span style="color: #000066; font-weight: bold;">.</span>objects<span style="color: #000066; font-weight: bold;">.</span>tdCarBody<span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> TopDown<span style="color: #000066; font-weight: bold;">.</span>objects<span style="color: #000066; font-weight: bold;">.</span>tdMap<span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> TopDown<span style="color: #000066; font-weight: bold;">.</span>objects<span style="color: #000066; font-weight: bold;">.</span>tdTerrain<span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> Main <span style="color: #0033ff; font-weight: bold;">extends</span> <span style="color: #004993;">Sprite</span> 
	<span style="color: #000000;">&#123;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> playerCar<span style="color: #000066; font-weight: bold;">:</span>tdCarBody = <span style="color: #0033ff; font-weight: bold;">new</span> tdCarBody<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> world<span style="color: #000066; font-weight: bold;">:</span>qb2World = <span style="color: #0033ff; font-weight: bold;">new</span> qb2World<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">map</span><span style="color: #000066; font-weight: bold;">:</span>tdMap = <span style="color: #0033ff; font-weight: bold;">new</span> tdMap<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> saveGravity<span style="color: #000066; font-weight: bold;">:</span>amVector2d = <span style="color: #0033ff; font-weight: bold;">new</span> amVector2d<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> fence<span style="color: #000066; font-weight: bold;">:</span>qb2Group = <span style="color: #0033ff; font-weight: bold;">new</span> qb2Group<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> center<span style="color: #000066; font-weight: bold;">:</span>amPoint2d<span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> Main<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> 
		<span style="color: #000000;">&#123;</span>
			center = <span style="color: #0033ff; font-weight: bold;">new</span> amPoint2d<span style="color: #000000;">&#40;</span><span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">stageWidth</span><span style="color: #000066; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">stageHeight</span><span style="color: #000066; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			<span style="color: #009900; font-style: italic;">// World</span>
			initWorld<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			world<span style="color: #000066; font-weight: bold;">.</span>addObject<span style="color: #000000;">&#40;</span><span style="color: #004993;">map</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			<span style="color: #009900; font-style: italic;">// Gravité</span>
			saveGravity<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">copy</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000066; font-weight: bold;">.</span>world<span style="color: #000066; font-weight: bold;">.</span>gravity<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000066; font-weight: bold;">.</span>world<span style="color: #000066; font-weight: bold;">.</span>gravity<span style="color: #000066; font-weight: bold;">.</span><span style="color: #0033ff; font-weight: bold;">set</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000066; font-weight: bold;">.</span>world<span style="color: #000066; font-weight: bold;">.</span>gravityZ = <span style="color: #000000; font-weight:bold;">9.8</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			<span style="color: #009900; font-style: italic;">// Terrain</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> defaultTerrain<span style="color: #000066; font-weight: bold;">:</span>tdTerrain = <span style="color: #0033ff; font-weight: bold;">new</span> tdTerrain<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			defaultTerrain<span style="color: #000066; font-weight: bold;">.</span>frictionZMultiplier = <span style="color: #000000; font-weight:bold;">1.5</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #004993;">map</span><span style="color: #000066; font-weight: bold;">.</span>addObject<span style="color: #000000;">&#40;</span>defaultTerrain<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			<span style="color: #009900; font-style: italic;">// Voiture</span>
			initCar<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #004993;">map</span><span style="color: #000066; font-weight: bold;">.</span>addObject<span style="color: #000000;">&#40;</span>playerCar<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			initObjects<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #004993;">map</span><span style="color: #000066; font-weight: bold;">.</span>addObject<span style="color: #000000;">&#40;</span>fence<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #339966; font-weight: bold;">function</span> initWorld<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #009900; font-style: italic;">//world.debugDragSource = this;</span>
			world<span style="color: #000066; font-weight: bold;">.</span>actor = <span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Sprite</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			world<span style="color: #000066; font-weight: bold;">.</span>debugDrawContext = <span style="color: #000000;">&#40;</span><span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Sprite</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> <span style="color: #004993;">Sprite</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">;</span>
			world<span style="color: #000066; font-weight: bold;">.</span>realtimeUpdate = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span>
			world<span style="color: #000066; font-weight: bold;">.</span>maximumRealtimeStep = <span style="color: #000000; font-weight:bold;">1.0</span> <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">10.0</span><span style="color: #000066; font-weight: bold;">;</span>
			world<span style="color: #000066; font-weight: bold;">.</span>gravity<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = <span style="color: #000000; font-weight:bold;">10</span><span style="color: #000066; font-weight: bold;">;</span>
			world<span style="color: #000066; font-weight: bold;">.</span>defaultPositionIterations = <span style="color: #000000; font-weight:bold;">10</span><span style="color: #000066; font-weight: bold;">;</span>
			world<span style="color: #000066; font-weight: bold;">.</span>defaultVelocityIterations = <span style="color: #000000; font-weight:bold;">10</span><span style="color: #000066; font-weight: bold;">;</span>
			world<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">start</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #339966; font-weight: bold;">function</span> initCar<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #009900; font-style: italic;">// Géométrie et poids de la voiture</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> carWidth<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">60</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> carHeight<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">90</span><span style="color: #000066; font-weight: bold;">;</span>
			playerCar<span style="color: #000066; font-weight: bold;">.</span>addObject<span style="color: #000000;">&#40;</span> qb2Stock<span style="color: #000066; font-weight: bold;">.</span>newRectShape<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> amPoint2d<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">,</span> carWidth<span style="color: #000066; font-weight: bold;">,</span> carHeight<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			playerCar<span style="color: #000066; font-weight: bold;">.</span>mass = <span style="color: #000000; font-weight:bold;">1000</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">//1000kg</span>
			playerCar<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">position</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">copy</span><span style="color: #000000;">&#40;</span>center<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			<span style="color: #009900; font-style: italic;">// Création des roues</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> tireFriction<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">2.0</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> tireRollingFriction<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> tireWidth<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">7</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> tireRadius<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">10</span><span style="color: #000066; font-weight: bold;">;</span>
			playerCar<span style="color: #000066; font-weight: bold;">.</span>addObject
			<span style="color: #000000;">&#40;</span>
				<span style="color: #0033ff; font-weight: bold;">new</span> tdTire<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> amPoint2d<span style="color: #000000;">&#40;</span><span style="color: #000066; font-weight: bold;">-</span>carWidth<span style="color: #000066; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000066; font-weight: bold;">-</span>carHeight<span style="color: #000066; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">3</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">,</span> tireWidth<span style="color: #000066; font-weight: bold;">,</span> tireRadius<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">true</span> <span style="color: #009966; font-style: italic;">/*driven*/</span><span style="color: #000066; font-weight: bold;">,</span>  <span style="color: #0033ff; font-weight: bold;">true</span> <span style="color: #009966; font-style: italic;">/*turns*/</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">false</span> <span style="color: #009966; font-style: italic;">/*brakes*/</span><span style="color: #000066; font-weight: bold;">,</span> tireFriction<span style="color: #000066; font-weight: bold;">,</span> tireRollingFriction<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">,</span>
				<span style="color: #0033ff; font-weight: bold;">new</span> tdTire<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> amPoint2d<span style="color: #000000;">&#40;</span> carWidth<span style="color: #000066; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000066; font-weight: bold;">-</span>carHeight<span style="color: #000066; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">3</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">,</span> tireWidth<span style="color: #000066; font-weight: bold;">,</span> tireRadius<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">,</span>  <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">,</span> tireFriction<span style="color: #000066; font-weight: bold;">,</span> tireRollingFriction<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">,</span>
				<span style="color: #0033ff; font-weight: bold;">new</span> tdTire<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> amPoint2d<span style="color: #000000;">&#40;</span> carWidth<span style="color: #000066; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">,</span>  carHeight<span style="color: #000066; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">3</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">,</span> tireWidth<span style="color: #000066; font-weight: bold;">,</span> tireRadius<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">,</span> tireFriction<span style="color: #000066; font-weight: bold;">,</span> tireRollingFriction<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">,</span>
				<span style="color: #0033ff; font-weight: bold;">new</span> tdTire<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> amPoint2d<span style="color: #000000;">&#40;</span><span style="color: #000066; font-weight: bold;">-</span>carWidth<span style="color: #000066; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">,</span>  carHeight<span style="color: #000066; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">3</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">,</span> tireWidth<span style="color: #000066; font-weight: bold;">,</span> tireRadius<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">,</span> tireFriction<span style="color: #000066; font-weight: bold;">,</span> tireRollingFriction<span style="color: #000000;">&#41;</span>
			<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			<span style="color: #009900; font-style: italic;">// Controle au clavier</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> playerBrain<span style="color: #000066; font-weight: bold;">:</span>tdControllerBrain = <span style="color: #0033ff; font-weight: bold;">new</span> tdControllerBrain<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			playerBrain<span style="color: #000066; font-weight: bold;">.</span>addController<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> tdKeyboardCarController<span style="color: #000000;">&#40;</span><span style="color: #004993;">stage</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			playerCar<span style="color: #000066; font-weight: bold;">.</span>addObject<span style="color: #000000;">&#40;</span>playerBrain<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			<span style="color: #009900; font-style: italic;">// Moteur et transmission de la voiture</span>
			playerCar<span style="color: #000066; font-weight: bold;">.</span>addObject<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> tdEngine<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">new</span> tdTransmission<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			<span style="color: #009900; font-style: italic;">// Gear ratios (transmission)</span>
			playerCar<span style="color: #000066; font-weight: bold;">.</span>tranny<span style="color: #000066; font-weight: bold;">.</span>gearRatios = Vector<span style="color: #000066; font-weight: bold;">.&lt;</span>Number<span style="color: #000066; font-weight: bold;">&gt;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">3.5</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">3.5</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">3</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">2.5</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">1.5</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			<span style="color: #009900; font-style: italic;">//Courbe de régime du moteur, correspondance entre RPM et NM</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> curve<span style="color: #000066; font-weight: bold;">:</span>tdTorqueCurve = playerCar<span style="color: #000066; font-weight: bold;">.</span>engine<span style="color: #000066; font-weight: bold;">.</span>torqueCurve<span style="color: #000066; font-weight: bold;">;</span>
			curve<span style="color: #000066; font-weight: bold;">.</span>addEntry<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">1000</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">300</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// à 1000 RPM, 300 Nm max</span>
			curve<span style="color: #000066; font-weight: bold;">.</span>addEntry<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">2000</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">310</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			curve<span style="color: #000066; font-weight: bold;">.</span>addEntry<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">3000</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">320</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			curve<span style="color: #000066; font-weight: bold;">.</span>addEntry<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">4000</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">325</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			curve<span style="color: #000066; font-weight: bold;">.</span>addEntry<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">5000</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">330</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			curve<span style="color: #000066; font-weight: bold;">.</span>addEntry<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">6000</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">325</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			curve<span style="color: #000066; font-weight: bold;">.</span>addEntry<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">7000</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">320</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #339966; font-weight: bold;">function</span> initObjects<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #009900; font-style: italic;">//Création d'objets en cercle</span>
			fence<span style="color: #000066; font-weight: bold;">.</span>frictionZ = <span style="color: #000000; font-weight:bold;">1.0</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> angleInc<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = RAD_10<span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> rotPoint<span style="color: #000066; font-weight: bold;">:</span>amPoint2d = center<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">clone</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span>incY<span style="color: #000000;">&#40;</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">200</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> limit<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> = AM_PI <span style="color: #000066; font-weight: bold;">*</span> <span style="color: #000000; font-weight:bold;">2</span> <span style="color: #000066; font-weight: bold;">/</span> angleInc<span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span> i <span style="color: #000066; font-weight: bold;">&lt;</span> limit<span style="color: #000066; font-weight: bold;">;</span> i<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span> 
			<span style="color: #000000;">&#123;</span>
				fence<span style="color: #000066; font-weight: bold;">.</span>addObject<span style="color: #000000;">&#40;</span>qb2Stock<span style="color: #000066; font-weight: bold;">.</span>newRectBody<span style="color: #000000;">&#40;</span>rotPoint<span style="color: #000066; font-weight: bold;">.</span>rotatedBy<span style="color: #000000;">&#40;</span>i <span style="color: #000066; font-weight: bold;">*</span> angleInc<span style="color: #000066; font-weight: bold;">,</span> center<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">20</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">20</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">200</span><span style="color: #000066; font-weight: bold;">,</span> i <span style="color: #000066; font-weight: bold;">*</span> angleInc<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>Pour tester l&#039;exemple complet, avec .fla, moteur et dépendances : <a href="http://blog.nvalois.com/wp-content/uploads/2011/05/Car-driving.zip">c&#039;est ici</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nvalois.com/exemple-d-utilisation-de-quickb2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Présentation de QuickB2</title>
		<link>http://blog.nvalois.com/presentation-de-quickb2/</link>
		<comments>http://blog.nvalois.com/presentation-de-quickb2/#comments</comments>
		<pubDate>Thu, 19 May 2011 15:17:42 +0000</pubDate>
		<dc:creator>Nicolas</dc:creator>
				<category><![CDATA[Jeux]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[box2d]]></category>
		<category><![CDATA[moteur 2D]]></category>
		<category><![CDATA[quickb2]]></category>

		<guid isPermaLink="false">http://blog.nvalois.com/?p=271</guid>
		<description><![CDATA[<p>QuickB2 ou Quick Box2D est la version simplifié (pas en fonctionnalités mais en complexité) de Box2D, un moteur physique 2D, et qui permet de faire tout ce qui était possible avec, mais beaucoup plus facilement (et rapidement). En effet, beaucoup trouvent Box2D très complexe à prendre en main, donc si c&#039;est votre cas, QuickB2 va vous ravir!</p>
<p>Quelques fonctionnalités intéressantes :
- Soft-bodies (corps souples)
- Moteur physique pour véhicules (même la gestion des traces de pneus, etc&#8230;)
- Physique diverse
- Outils de debug
- [...]]]></description>
			<content:encoded><![CDATA[<p>QuickB2 ou Quick Box2D est la version simplifié (pas en fonctionnalités mais en complexité) de Box2D, un moteur physique 2D, et qui permet de faire tout ce qui était possible avec, mais beaucoup plus facilement (et rapidement). En effet, beaucoup trouvent Box2D très complexe à prendre en main, donc si c&#039;est votre cas, QuickB2 va vous ravir!</p>
<p>Quelques fonctionnalités intéressantes :<br />
- Soft-bodies (corps souples)<br />
- Moteur physique pour véhicules (même la gestion des traces de pneus, etc&#8230;)<br />
- Physique diverse<br />
- Outils de debug<br />
- Edition d&#039;environnement WYSIWYG pour Flash CS5</p>
<p>Un petit aperçu des possibilités :<br />

<object width="500" height="600">
<param name="movie" value="http://quickb2.dougkoellmer.com/bin/qb2DemoReel.swf"></param>
<param name="quality" value="high"></param>
<param name="wmode" value="window"></param>
<param name="menu" value="false"></param>
<param name="bgcolor" value="#FFFFFF"></param>
<embed type="application/x-shockwave-flash" width="500" height="600" src="http://quickb2.dougkoellmer.com/bin/qb2DemoReel.swf" quality="high" bgcolor="#FFFFFF" wmode="window" menu="false" ></embed>
</object>
<br />
<em>Ou à voir <a href="http://quickb2.dougkoellmer.com/bin/qb2DemoReel.swf">ici</a>.</em></p>
<p>Pour télécharger QuickB2 : http://code.google.com/p/quickb2/downloads/list<br />
Box2D : http://sourceforge.net/projects/box2dflash/</p>
<p>Si vous avez des erreurs du genre &laquo;&nbsp;import cmodule.Box2D.*;&nbsp;&raquo; vous pouvez utilisez le .fla dans QuickB2\fla qui possède simplement les accès aux classes et aux dépendances : ../src, ../dependencies/src/As3Math, ../extensions/TopDown auquel vous pouvez associé votre classe. </p>
<p>A suivre prochainements quelques exemples avec sources!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nvalois.com/presentation-de-quickb2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Away3D : Panorama 360°, les différentes solutions</title>
		<link>http://blog.nvalois.com/away3d-panorama-360%c2%b0-les-differentes-solutions/</link>
		<comments>http://blog.nvalois.com/away3d-panorama-360%c2%b0-les-differentes-solutions/#comments</comments>
		<pubDate>Mon, 16 May 2011 07:23:00 +0000</pubDate>
		<dc:creator>Nicolas</dc:creator>
				<category><![CDATA[3D, Molehill]]></category>
		<category><![CDATA[Tutoriaux]]></category>
		<category><![CDATA[away3d]]></category>
		<category><![CDATA[HoverCamera3D]]></category>
		<category><![CDATA[panorama]]></category>
		<category><![CDATA[Skybox]]></category>
		<category><![CDATA[Skybox6]]></category>
		<category><![CDATA[Sphere]]></category>

		<guid isPermaLink="false">http://127.0.0.1:8888/blog/?p=91</guid>
		<description><![CDATA[<p>Il y a deux principales solution pour faire un panorama à 360° libre (c&#039;est à dire pas seulement horizontal) : utiliser un cube ou une sphère.</p>
<p><a name="sphere"><strong>La Sphere</strong></a>
Pour réaliser le 360°, nous allons placer une <a href="http://blog.nvalois.com/away3d-camera-et-mouvements-de-camera/#hoverCamera3d" target="_blank">HoverCamera3D</a> à l&#039;intérieur d&#039;une sphère. <a href="http://blog.nvalois.com/away3d-primitives-cube-plane-sphere-triangle/#sphere" target="_blank">La sphère n&#039;étant mappé que de l&#039;extérieur</a>, il va falloir également inversé les faces comme ceci :</p>

sphere<span style="color: #000066; font-weight: bold;">.</span>invertFaces<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>

<p>Vous pouvez aussi simplement utiliser la propriété scaleX :</p>

sphere<span [...]]]></description>
			<content:encoded><![CDATA[<p>Il y a deux principales solution pour faire un panorama à 360° libre (c&#039;est à dire pas seulement horizontal) : utiliser un cube ou une sphère.</p>
<p><a name="sphere"><strong>La Sphere</strong></a><br />
Pour réaliser le 360°, nous allons placer une <a href="http://blog.nvalois.com/away3d-camera-et-mouvements-de-camera/#hoverCamera3d" target="_blank">HoverCamera3D</a> à l&#039;intérieur d&#039;une sphère. <a href="http://blog.nvalois.com/away3d-primitives-cube-plane-sphere-triangle/#sphere" target="_blank">La sphère n&#039;étant mappé que de l&#039;extérieur</a>, il va falloir également inversé les faces comme ceci :</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;">sphere<span style="color: #000066; font-weight: bold;">.</span>invertFaces<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></pre></div></div>

<p>Vous pouvez aussi simplement utiliser la propriété scaleX :</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;">sphere<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">scaleX</span> = <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span></pre></div></div>

<p>La texture sera alors uniquement visible de l&#039;intérieur. Pour avoir le moins de déformation possible, il faut aussi donner un très grand radius à la sphère (1500px donne de bons résultats). Pour appliquer cette texture, vous allez devoir renseigner la propriété &#039;material&#039; de la sphère avec un jpg comme ceci:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #000000;">&#91;</span>Embed<span style="color: #000000;">&#40;</span><span style="color: #004993;">source</span>=<span style="color: #990000;">&quot;texture.jpg&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> texture<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Class</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #6699cc; font-weight: bold;">var</span> sphere<span style="color: #000066; font-weight: bold;">:</span>Sphere = <span style="color: #0033ff; font-weight: bold;">new</span> Sphere<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#123;</span>radius<span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">1500</span><span style="color: #000066; font-weight: bold;">,</span> material<span style="color: #000066; font-weight: bold;">:</span>texture<span style="color: #000066; font-weight: bold;">,</span> segmentsW<span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">15</span><span style="color: #000066; font-weight: bold;">,</span> segmentsH<span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">30</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></pre></div></div>

<p>Pour gérer la caméra, j&#039;ai fait une navigation à la souris. A l&#039;évènement MOUSE_DOWN, on va utiliser un enterFrame et mettre à jour les propriétés panAngle et tiltAngle de la caméra.<br />

<object width="360" height="300">
<param name="movie" value="../wp-content/uploads/2011/05/sphere360.swf"></param>
<param name="quality" value="high"></param>
<param name="wmode" value="window"></param>
<param name="menu" value="false"></param>
<param name="bgcolor" value="#FFFFFF"></param>
<embed type="application/x-shockwave-flash" width="360" height="300" src="../wp-content/uploads/2011/05/sphere360.swf" quality="high" bgcolor="#FFFFFF" wmode="window" menu="false" ></embed>
</object>
</p>
<p>Comme vous pouvez le constater il y a une assez grosse déformation, mais suivant le style que l&#039;on veut lui donner, la sphère peut être la meilleure solution.</p>
<p><a name="cube"><strong>Le Cube</strong></a><br />
Il y a 2 Objets qui sont spécialement destinés à cela dans Away3d : Skybox et Skybox6. Ce sont des cubes avec des tailles indéfinies, d&#039;ou le nom. En utilisant cette objet, la déformation sera moindre par contre suivant l&#039;environnement, il est possible de voir les arrêtes du cube. Un exemple sera plus parlant :<br />

<object width="360" height="300">
<param name="movie" value="../wp-content/uploads/2011/05/skybox.swf"></param>
<param name="quality" value="high"></param>
<param name="wmode" value="window"></param>
<param name="menu" value="false"></param>
<param name="bgcolor" value="#FFFFFF"></param>
<embed type="application/x-shockwave-flash" width="360" height="300" src="../wp-content/uploads/2011/05/skybox.swf" quality="high" bgcolor="#FFFFFF" wmode="window" menu="false" ></embed>
</object>
</p>
<p>Pour implémenter une skybox, voici comment cela se déroule :</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> cube<span style="color: #000066; font-weight: bold;">:</span>Skybox = <span style="color: #0033ff; font-weight: bold;">new</span> Skybox<span style="color: #000000;">&#40;</span>materialFace<span style="color: #000066; font-weight: bold;">,</span> materialGauche<span style="color: #000066; font-weight: bold;">,</span> materialDos<span style="color: #000066; font-weight: bold;">,</span> materialDroite<span style="color: #000066; font-weight: bold;">,</span> materialHaut<span style="color: #000066; font-weight: bold;">,</span> materialBas<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
view<span style="color: #000066; font-weight: bold;">.</span>scene<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>cube<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></pre></div></div>

<p>Il faut bien sur définir chaque material avant. C&#039;est un peu fastidieux, mais c&#039;est utile si plusieurs faces se répètent (ex une texture mur, une texture sol), on gagnera du temps de chargement.</p>
<p>Pour une skybox6, c&#039;est plus simple :</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> cube<span style="color: #000066; font-weight: bold;">:</span>Skybox6 = <span style="color: #0033ff; font-weight: bold;">new</span> Skybox6<span style="color: #000000;">&#40;</span>material<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
cube<span style="color: #000066; font-weight: bold;">.</span>quarterFaces<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></pre></div></div>

<p>En revanche, l&#039;image doit comporter les 6 faces, dans le même ordre que la création d&#039;une skybox. Voici l&#039;exemple que j&#039;ai utilisé :<br />
<a href="http://blog.nvalois.com/wp-content/uploads/2011/05/my_skybox.jpg"><img class="size-medium wp-image-263" title="skybox" src="http://blog.nvalois.com/wp-content/uploads/2011/05/my_skybox-300x200.jpg" alt="Skybox6" width="300" height="200" /></a></p>
<p>Voici les sources pour la sphère (ajoutez le dossier Away3D dans /classes/away3D):<br />
<a href="http://blog.nvalois.com/wp-content/uploads/2011/05/panorama_sphere.zip">Télécharger</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nvalois.com/away3d-panorama-360%c2%b0-les-differentes-solutions/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Différence entre ROLL_OVER et MOUSE_OVER</title>
		<link>http://blog.nvalois.com/difference-entre-roll_over-et-mouse_over/</link>
		<comments>http://blog.nvalois.com/difference-entre-roll_over-et-mouse_over/#comments</comments>
		<pubDate>Tue, 10 May 2011 23:16:00 +0000</pubDate>
		<dc:creator>Nicolas</dc:creator>
				<category><![CDATA[Tutoriaux]]></category>
		<category><![CDATA[MOUSE_OVER]]></category>
		<category><![CDATA[rollOver]]></category>
		<category><![CDATA[ROLL_OVER]]></category>

		<guid isPermaLink="false">http://blog.nvalois.com/?p=243</guid>
		<description><![CDATA[<p>Il y a deux évènements bien distinct pour le survol : MouseEvent.ROLL_OVER et MouseEvent.MOUSE_OVER.  Beaucoup ont tendance à utiliser MOUSE_OVER car le nom est plus parlant (aussi car on le trouve en premier dans l&#039;auto-complétion&#8230;), mais qu&#039;en est il vraiment ?</p>
<p>Ces 2 évènements se comporte en fait différemment, ce qui peut parfois expliqué des bugs inexpliqués si on ne les utilisent pas comme il le faut.</p>
<p><a href="http://livedocs.adobe.com/flash/9.0_fr/ActionScriptLangRefV3/flash/display/InteractiveObject.html#event:mouseOver">La documentation officielle d&#039;Adobe</a> indique que MOUSE_OVER est déclenché lorsque la souris pénètre [...]]]></description>
			<content:encoded><![CDATA[<p>Il y a deux évènements bien distinct pour le survol : MouseEvent.ROLL_OVER et MouseEvent.MOUSE_OVER.  Beaucoup ont tendance à utiliser MOUSE_OVER car le nom est plus parlant (aussi car on le trouve en premier dans l&#039;auto-complétion&#8230;), mais qu&#039;en est il vraiment ?</p>
<p>Ces 2 évènements se comporte en fait différemment, ce qui peut parfois expliqué des bugs inexpliqués si on ne les utilisent pas comme il le faut.</p>
<p><a href="http://livedocs.adobe.com/flash/9.0_fr/ActionScriptLangRefV3/flash/display/InteractiveObject.html#event:mouseOver">La documentation officielle d&#039;Adobe</a> indique que MOUSE_OVER est déclenché lorsque la souris pénètre dans la zone d&#039;un objet enfant du conteneur d&#039;objet d&#039;affichage (même si la souris survolait déjà un autre objet enfant du conteneur d&#039;objet d&#039;affichage).<br />
ROLL_OVER déclenche l’évènement lorsque la souris pénètre dans la zone d&#039;un objet d&#039;affichage ou de l&#039;un de ses enfants à partir d&#039;un objet qui ne fait pas partie de ses enfants</p>
<p>Pour illustrer, voici un exemple plus concret. Ici le carré jaune est contenu dans un clip gris. Survolez ces 2 carrés pour déclencher les évènements :<br />

<object width="360" height="400">
<param name="movie" value="../wp-content/uploads/2011/05/mouseover_vs_rollover.swf"></param>
<param name="quality" value="high"></param>
<param name="wmode" value="window"></param>
<param name="menu" value="false"></param>
<param name="bgcolor" value="#FFFFFF"></param>
<embed type="application/x-shockwave-flash" width="360" height="400" src="../wp-content/uploads/2011/05/mouseover_vs_rollover.swf" quality="high" bgcolor="#FFFFFF" wmode="window" menu="false" ></embed>
</object>
</p>
<p>Si vous souhaitez utiliser MOUSE_OVER en ne déclenchant pas l’évènement s&#039;il fait parti de ses enfants, donnez au clip la propriété mouseChildren =  false.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nvalois.com/difference-entre-roll_over-et-mouse_over/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installer Kinect sur Windows Vista</title>
		<link>http://blog.nvalois.com/installer-kinect-sur-windows-vista/</link>
		<comments>http://blog.nvalois.com/installer-kinect-sur-windows-vista/#comments</comments>
		<pubDate>Mon, 09 May 2011 23:12:59 +0000</pubDate>
		<dc:creator>Nicolas</dc:creator>
				<category><![CDATA[Webcam, Kinect]]></category>
		<category><![CDATA[kinect]]></category>
		<category><![CDATA[OpenNI]]></category>
		<category><![CDATA[SenSorKinect]]></category>
		<category><![CDATA[vista]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://blog.nvalois.com/?p=194</guid>
		<description><![CDATA[<p>Avant de vous présenter des tutoriaux et des expérimentations avec Kinect et Flash, commençons d&#039;abord par l&#039;installation de Kinect sur Windows.
L&#039;installation est possible sur Windows XP, Vista, 7 mais je parlerais de Windows Vista ici comme c&#039;est mon système.</p>
<p>Avant de commencer il va falloir télécharger OpenNi, Nite et SenSorKinect. Vous pouvez les <a href="http://blog.nvalois.com/wp-content/uploads/2011/05/Pack-kinect-installation.zip">télécharger ici</a>, mais il y aura peut être des versions plus récentes lorsque vous lirez ce tuto.</p>
<p>Après l&#039;extraction des fichiers, lancez OpenNI-Win32-v1.0.0.25.exe :</p>
<p><a href="http://blog.nvalois.com/wp-content/uploads/2011/05/installation-kinect-01.png" rel="lightbox[install]"></a>
Cliquez sur Install.</p>
<p><a [...]]]></description>
			<content:encoded><![CDATA[<p>Avant de vous présenter des tutoriaux et des expérimentations avec Kinect et Flash, commençons d&#039;abord par l&#039;installation de Kinect sur Windows.<br />
L&#039;installation est possible sur Windows XP, Vista, 7 mais je parlerais de Windows Vista ici comme c&#039;est mon système.</p>
<p>Avant de commencer il va falloir télécharger OpenNi, Nite et SenSorKinect. Vous pouvez les <a href="http://blog.nvalois.com/wp-content/uploads/2011/05/Pack-kinect-installation.zip">télécharger ici</a>, mais il y aura peut être des versions plus récentes lorsque vous lirez ce tuto.</p>
<p>Après l&#039;extraction des fichiers, lancez OpenNI-Win32-v1.0.0.25.exe :</p>
<p><a href="http://blog.nvalois.com/wp-content/uploads/2011/05/installation-kinect-01.png" rel="lightbox[install]"><img src="http://blog.nvalois.com/wp-content/uploads/2011/05/installation-kinect-01.png" alt="installation de OpenNI" title="installation de OpenNI" class="alignnone size-full wp-image-197" width="300" /></a><br />
Cliquez sur Install.</p>
<p><a href="http://blog.nvalois.com/wp-content/uploads/2011/05/installation-kinect-02.png" rel="lightbox[install]"><img src="http://blog.nvalois.com/wp-content/uploads/2011/05/installation-kinect-02.png" alt="installation de OpenNI" title="installation de OpenNI" class="alignnone size-full wp-image-198" width="300" /></a><br />
Pendant la progression ce message peut s&#039;afficher. Cliquez sur Install.</p>
<p><a href="http://blog.nvalois.com/wp-content/uploads/2011/05/installation-kinect-03.png" rel="lightbox[install]"><img src="http://blog.nvalois.com/wp-content/uploads/2011/05/installation-kinect-03.png" alt="installation de OpenNI" title="installation de OpenNI" class="alignnone size-full wp-image-204" width="300"/></a></p>
<p>&nbsp;</p>
<p>Ensuite installez SensorKinect-Win32-5.0.0.exe :<br />
<a href="http://blog.nvalois.com/wp-content/uploads/2011/05/installation-kinect-04.png" rel="lightbox[install]"><img src="http://blog.nvalois.com/wp-content/uploads/2011/05/installation-kinect-04.png" alt="installation SensorKinect" title="installation SensorKinect" class="alignnone size-full wp-image-205" width="300" /></a><br />
Cliquez toujours sur Next jusqu’à une alerte de sécurité Windows. Acceptez pour continuer l&#039;installation en cliquant sur &laquo;&nbsp;Install this driver software anyway&nbsp;&raquo; :<br />
<a href="http://blog.nvalois.com/wp-content/uploads/2011/05/installation-kinect-05.png" rel="lightbox[install]"><img src="http://blog.nvalois.com/wp-content/uploads/2011/05/installation-kinect-05.png" alt="installation Alerte sensorKinect" title="installation Alerte sensorKinect" class="alignnone size-full wp-image-206" width="300" /></a></p>
<p>A partir de la Kinect doit être reconnu, mais il reste à installer Nite pour l&#039;exploiter. Lancer .exe<br />
<a href="http://blog.nvalois.com/wp-content/uploads/2011/05/installation-kinect-06.png" rel="lightbox[install]"><img src="http://blog.nvalois.com/wp-content/uploads/2011/05/installation-kinect-06.png" alt="installation de Nite" title="installation de Nite" class="alignnone size-full wp-image-207" width="300" /></a></p>
<p>Il va demander une clé, entrez : 0KOIk2JeIBYClPWVnMoRKn5cdY4=<br />
<a href="http://blog.nvalois.com/wp-content/uploads/2011/05/installation-kinect-07.png" rel="lightbox[install]"><img src="http://blog.nvalois.com/wp-content/uploads/2011/05/installation-kinect-07.png" alt="installation de Nite clé" title="installation de Nite clé" class="alignnone size-full wp-image-208" width="300" /></a></p>
<p>Voila, c&#039;est fini! Maintenant l&#039;heure de la vérité avec le branchement de Kinect. Branchez Kinect au secteur puis dans une prise USB (pas en façade si vous avez une tour). Laissez Windows configurer tout seul Kinect.<br />
Redémarrez Windows pour qu&#039;il fasse les mises a jour. </p>
<p>Au redémarrage, la LED verte devrait être allumée et clignoter. Vous pouvez tester Kinect avec les exemples dans C:\Program Files\OpenNI\Samples\Bin\Release.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nvalois.com/installer-kinect-sur-windows-vista/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Détection de mouvements a la webcam</title>
		<link>http://blog.nvalois.com/detection-mouvements-webcam/</link>
		<comments>http://blog.nvalois.com/detection-mouvements-webcam/#comments</comments>
		<pubDate>Sun, 08 May 2011 15:54:30 +0000</pubDate>
		<dc:creator>Nicolas</dc:creator>
				<category><![CDATA[Lab]]></category>
		<category><![CDATA[Webcam, Kinect]]></category>
		<category><![CDATA[kinect]]></category>
		<category><![CDATA[lab]]></category>
		<category><![CDATA[webcam]]></category>

		<guid isPermaLink="false">http://127.0.0.1:8888/blog/?p=63</guid>
		<description><![CDATA[<p>J&#039;ai essayé plusieurs méthodes plus ou moins concluantes pour la détection de mouvement à la webcam. Les deux principaux problèmes que j&#039;ai rencontré sont la dépendance du résultat par rapport à la qualité de la webcam (rafraîchissement, définition, bruit/nuisances) et de la zone d&#039;action (peu performant au centre de l&#039;écran du aux moments du corps qui font parasite).
Une des méthodes qui fonctionne le mieux est de comparer deux images capturées successives, et de faire la différences. Avec quelques traitement supplémentaires [...]]]></description>
			<content:encoded><![CDATA[<p>J&#039;ai essayé plusieurs méthodes plus ou moins concluantes pour la détection de mouvement à la webcam. Les deux principaux problèmes que j&#039;ai rencontré sont la dépendance du résultat par rapport à la qualité de la webcam (rafraîchissement, définition, bruit/nuisances) et de la zone d&#039;action (peu performant au centre de l&#039;écran du aux moments du corps qui font parasite).<br />
Une des méthodes qui fonctionne le mieux est de comparer deux images capturées successives, et de faire la différences. Avec quelques traitement supplémentaires sur l&#039;image on arrive avec un plutôt bon résultat, mais toujours avec les défauts/problèmes cités ci-dessus.<br />
Si l&#039;on ne recherche pas un effet de tracking, j&#039;utilise une autre méthode qui consiste à comparer les couleurs d&#039;une zone. Je m&#039;explique : imaginons que l&#039;on veuille faire une action de clic sur un bouton (ou une zone) avec la main par webcam, on calcule la couleur moyenne de cette zone avec un refresh fréquent (enterFrame ou Timer). Au survol de cette zone avec la main, la couleur moyenne va donc être différente, et on peux donc actionner le click.</p>
<p>Sur cette démo il y a plusieurs zones clickables assez grandes. Il faut donc trouver un bon compromis dans la tolérance des différence de couleurs pour ne pas avoir une zone trop sensible aux mouvements parasites mais assez pour percevoir les mouvements volontaires :</p>
<p><!-- This is the Embed code for Flash webcam zone detect Delete all of this code to remove the video--></p>
<p><object width="480" height="350" type="application/x-shockwave-flash" data="http://vimeo.com/moogaloop.swf?clip_id=23436311&amp;server=vimeo.com&amp;show_title=&amp;show_byline=&amp;show_portrait=&amp;color=&amp;fullscreen=1" ><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=23436311&amp;server=vimeo.com&amp;show_title=&amp;show_byline=&amp;show_portrait=&amp;color=&amp;fullscreen=1" /></object></p>
<p><!-- The Embed code for Flash webcam zone detect Ends here--></p>
<p>Ici le résultat est plutôt bon car les zones sont en dehors des zones de mouvements (genre au milieu c&#039;est plus compliqué car il y a plus de mouvements parasitaires du corps, visage, etc..).</p>
<p>A terme, cette méthode doit me permettre d&#039;avoir une navigation kinect-like, comme le menu de la console avec les vignettes. Suite au prochain épisode&#8230;</p>
<p>Si vous utilisez une méthode encore différente, n&#039;hésitez pas à m&#039;en faire part!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nvalois.com/detection-mouvements-webcam/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Away3D : Primitives, les principaux objets dont vous aurez besoin</title>
		<link>http://blog.nvalois.com/away3d-primitives-cube-plane-sphere-triangle/</link>
		<comments>http://blog.nvalois.com/away3d-primitives-cube-plane-sphere-triangle/#comments</comments>
		<pubDate>Fri, 06 May 2011 15:55:19 +0000</pubDate>
		<dc:creator>Nicolas</dc:creator>
				<category><![CDATA[3D, Molehill]]></category>
		<category><![CDATA[Tutoriaux]]></category>
		<category><![CDATA[3D]]></category>
		<category><![CDATA[away3d]]></category>
		<category><![CDATA[Cube]]></category>
		<category><![CDATA[Plane]]></category>
		<category><![CDATA[Sphere]]></category>
		<category><![CDATA[Triangle]]></category>

		<guid isPermaLink="false">http://127.0.0.1:8888/blog/?p=59</guid>
		<description><![CDATA[<p>Nous allons voir ici les objets que l&#039;on se sert le plus : Cube, Plane, Sphere, Triangle.</p>
<p><a name="triangle"><strong>Triangle</strong></a>
Ce n&#039;est pas la forme que l&#039;on utilise couramment, mais il est utile de la voir car c&#039;est la forme de base. En effet chaque objet est composé d&#039;un nombre plus ou moins important de Triangles. Par exemple, Plane est composé par défaut de 2 triangles. Il peut être toutefois utilisé quand on doit représenter un très grand nombre d&#039;objets, par exemple des [...]]]></description>
			<content:encoded><![CDATA[<p>Nous allons voir ici les objets que l&#039;on se sert le plus : Cube, Plane, Sphere, Triangle.</p>
<p><a name="triangle"><strong>Triangle</strong></a><br />
Ce n&#039;est pas la forme que l&#039;on utilise couramment, mais il est utile de la voir car c&#039;est la forme de base. En effet chaque objet est composé d&#039;un nombre plus ou moins important de Triangles. Par exemple, Plane est composé par défaut de 2 triangles. Il peut être toutefois utilisé quand on doit représenter un très grand nombre d&#039;objets, par exemple des particules, afin d&#039;avoir un rendu très fluide.<br />
La création d&#039;un Triangle est défini par 3 points a, b et c.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> triangle<span style="color: #000066; font-weight: bold;">:</span>Triangle = <span style="color: #0033ff; font-weight: bold;">new</span> Triangle<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
triangle<span style="color: #000066; font-weight: bold;">.</span>a = <span style="color: #0033ff; font-weight: bold;">new</span> Vertex<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
triangle<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">b</span> = <span style="color: #0033ff; font-weight: bold;">new</span> Vertex<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">10</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
triangle<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">c</span> = <span style="color: #0033ff; font-weight: bold;">new</span> Vertex<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">5</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">10</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></pre></div></div>

<p>Vous pouvez passez ces valeurs en paramètres dans le constructeur.</p>
<p><a name="plane"><strong>Plane</strong></a><br />
Plane est donc composé de 2 triangle par défaut (donc la deuxième forme la plus légère), mais vous pouvez augmenter la complexité avec les propriétés segmentsH et segmentsW (pour Height et Width). Pour la création d&#039;un Plane, vous spécifiez la largeur et la hauteur (avec les propriété Width et Height). La création se fait comme ceci :</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> plane<span style="color: #000066; font-weight: bold;">:</span>Plane = <span style="color: #0033ff; font-weight: bold;">new</span> Plane<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
plane<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> = <span style="color: #000000; font-weight:bold;">200</span><span style="color: #000066; font-weight: bold;">;</span>
plane<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> = <span style="color: #000000; font-weight:bold;">100</span><span style="color: #000066; font-weight: bold;">;</span>
plane<span style="color: #000066; font-weight: bold;">.</span>segmentsH = <span style="color: #000000; font-weight:bold;">5</span><span style="color: #000066; font-weight: bold;">;</span>
plane<span style="color: #000066; font-weight: bold;">.</span>segmentsW = <span style="color: #000000; font-weight:bold;">5</span><span style="color: #000066; font-weight: bold;">;</span></pre></div></div>

<p>Vous pouvez passez ces valeurs en paramètres dans le constructeur.</p>
<p><a name="cube"><strong>Cube</strong></a><br />
C&#039;est en fait un Plane plus complexe, auquel on rajoute la propriété depth (et du coup segmentsD). Il a besoin de minimum 12 triangles pour être créer (1 Plane par face, avec 6 faces). Donc à la création on a ceci :</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> cube<span style="color: #000066; font-weight: bold;">:</span>Cube = <span style="color: #0033ff; font-weight: bold;">new</span> Cube<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#123;</span><span style="color: #004993;">width</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">200</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #004993;">height</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">100</span><span style="color: #000066; font-weight: bold;">,</span>depth<span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">50</span><span style="color: #000066; font-weight: bold;">,</span>segmentsH<span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">5</span><span style="color: #000066; font-weight: bold;">,</span> segmentsW<span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">5</span><span style="color: #000066; font-weight: bold;">,</span> segmentsD<span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">5</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></pre></div></div>

<p>Par défaut, le Cube et la Sphere ne sont mappé que de l&#039;extérieur.</p>
<p><a name="sphere"><strong>Sphere</strong></a><br />
Plus complexe qu&#039;un cube, la sphère a besoin de plus de triangle pour être créer (36 par défaut) et beaucoup plus pour avoir un joli rendu. Pour augmenter la complexité on utilise les propriétés segmentsW et segmentsH. La création d&#039;une sphère se fait cette fois plus avec width et height mais avec la propriété radius :</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> sphere<span style="color: #000066; font-weight: bold;">:</span>Sphere = <span style="color: #0033ff; font-weight: bold;">new</span> Sphere<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#123;</span>radius<span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">20</span><span style="color: #000066; font-weight: bold;">,</span>segmentsW<span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">5</span><span style="color: #000066; font-weight: bold;">,</span>segmentsH<span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">5</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></pre></div></div>

<p>Pour continuer avec Away3D:<br />
Tutorial 1 : <a href="http://blog.nvalois.com/away3d-installation-et-premiere-animation/">Installation et première animation</a><br />
Tutorial 2 : <a href="http://blog.nvalois.com/away3d-camera-et-mouvements-de-camera/">Caméra et mouvements de caméra</a><br />
Tutorial 4 : Materials (à venir)<br />
Tutorial 5 : Lights, les différents éclairages (à venir)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nvalois.com/away3d-primitives-cube-plane-sphere-triangle/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

