<?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>Flashxpress &#187; Tutoriels Flash</title>
	<atom:link href="http://www.flashxpress.net/category/ressources-flash/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.flashxpress.net</link>
	<description>Ressources pour la création et les technologies du web</description>
	<lastBuildDate>Thu, 09 Feb 2012 01:00:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Nouveautés Flash Player 11.2 &#8211; mouseLock, right click et cie..</title>
		<link>http://www.flashxpress.net/ressources-flash/nouveautes-flash-player-11-2-mouselock-right-click-et-cie/</link>
		<comments>http://www.flashxpress.net/ressources-flash/nouveautes-flash-player-11-2-mouselock-right-click-et-cie/#comments</comments>
		<pubDate>Mon, 12 Dec 2011 11:56:00 +0000</pubDate>
		<dc:creator>alama</dc:creator>
				<category><![CDATA[Flash ActionScript]]></category>
		<category><![CDATA[Flash général]]></category>
		<category><![CDATA[Tutoriels Flash]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[beta]]></category>
		<category><![CDATA[Flash Player 11.2]]></category>
		<category><![CDATA[middle_click]]></category>
		<category><![CDATA[MouseEvent.RIGHT_CLICK]]></category>
		<category><![CDATA[mouseLock]]></category>

		<guid isPermaLink="false">http://www.flashxpress.net/?p=6842</guid>
		<description><![CDATA[Nouveautés Flash Player 11.2 (Beta au 7/12/2011) Les nouveautés principales que la majorité des programmeurs risquent d&#8217;utiliser tournent autour de la gestion souris. Voyons ça en détail. !! Les swfs d&#8217;exemples necessitent le Player 11.2 (beta) ou supérieur !! Téléchargez la beta 11.2 ici Gestion du right clic et du middle clic de la souris [...]]]></description>
			<content:encoded><![CDATA[<h1>Nouveautés Flash Player 11.2 (Beta au 7/12/2011)</h1>
<p>Les nouveautés principales que la majorité des programmeurs risquent d&#8217;utiliser tournent autour de la gestion souris. Voyons ça en détail.</p>
<p><strong>!! Les swfs d&#8217;exemples necessitent le Player 11.2 (beta) ou supérieur !!<br />
</strong></p>
<p><a href="http://labs.adobe.com/downloads/flashplayer11-2.html" target="_blank">Téléchargez la beta 11.2 ici</a></p>
<h1>Gestion du right clic et du middle clic de la souris</h1>
<p>Commençons par la plus simple, on peut désormais écouter des événements <strong><span class="typ">MouseEvent</span><span class="pun">.</span><span class="pln">RIGHT_CLICK</span></strong> et <strong><span class="typ">MouseEvent</span><span class="pun">.</span><span class="pln">MIDDLE_CLICK</span></strong>.</p>
<p>Concernant le middle clic, sur la plupart des souris, c&#8217;est l&#8217;enfoncement de la roulette.</p>
<p>Concernant le clic droit, par défaut, le clic droit fait apparaître le menu contextuel natif de Flash. Menu que l&#8217;on peut d&#8217;ailleurs modifier en partie, en ajoutant de nouvelles entrées. Depuis la version 11.2, le simple fait d&#8217;ajouter un écouteur d&#8217;événement sur le clic droit désactive le menu natif de Flash. Cela permet de faire d&#8217;autres choses au clic droit, ou de faire son propre menu avec son propre skin et ses propres entrées&#8230;</p>
<p>Aucune classe native de menu contextuel ne pourra servir de base, il faudra créer à 100% son menu et le gérer. L&#8217;avantage est une liberté totale.</p>
<p>Voici un simple exemple, il est évident qu&#8217;en situation réelle, il faudra créer une classe pour ce menu et la faire autrement avec des méthodes &laquo;&nbsp;addItem&nbsp;&raquo;, etc., plus un contrôle de positionnement en bord d&#8217;application, que je n&#8217;ai pas pris la peine de faire&#8230; Ici, c&#8217;est juste pour l&#8217;exemple.</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_rightclic_1396820427"
			class="flashmovie"
			width="400"
			height="300">
	<param name="movie" value="http://www.covergraph.com/blog/flash/player11.2features/rightclic.swf" />
	<param name="scale" value="noscale" />
	<param name="allowfullscreen" value="true" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.covergraph.com/blog/flash/player11.2features/rightclic.swf"
			name="fm_rightclic_1396820427"
			width="400"
			height="300">
		<param name="scale" value="noscale" />
		<param name="allowfullscreen" value="true" />
	<!--<![endif]-->
		<br />
<a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a><br />

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<h3>Code de test:</h3>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p6842code3'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p68423"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
</pre></td><td class="code" id="p6842code3"><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> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=sprite%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:sprite.html"><span style="color: #004993;">Sprite</span></a><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=mouseevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:mouseevent.html"><span style="color: #004993;">MouseEvent</span></a><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.text</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=textfield%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textfield.html"><span style="color: #004993;">TextField</span></a><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.text</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=textfieldautosize%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textfieldautosize.html"><span style="color: #004993;">TextFieldAutoSize</span></a><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #3f5fbf;">/**
	 * ...
	 * @author Alama
	 */</span>
	<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> <a href="http://www.google.com/search?q=sprite%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:sprite.html"><span style="color: #004993;">Sprite</span></a>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> menuItems<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=array%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:array.html"><span style="color: #004993;">Array</span></a><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> menu<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=sprite%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:sprite.html"><span style="color: #004993;">Sprite</span></a><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> output<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=textfield%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textfield.html"><span style="color: #004993;">TextField</span></a><span style="color: #000066; font-weight: bold;">;</span>
		<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>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">stage</span><span style="color: #000000;">&#41;</span>
				<span style="color: #004993;">init</span><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;">else</span>
				<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">ADDED_TO_STAGE</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">init</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;">private</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">init</span><span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a> = <span style="color: #0033ff; font-weight: bold;">null</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;">removeEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">ADDED_TO_STAGE</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">init</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #009900; font-style: italic;">// entry point</span>
			menuItems = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=array%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:array.html"><span style="color: #004993;">Array</span></a><span style="color: #000066; font-weight: bold;">;</span>
			makeExampleMenu<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			output = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=textfield%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textfield.html"><span style="color: #004993;">TextField</span></a><span style="color: #000066; font-weight: bold;">;</span>
			output<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">autoSize</span> = <a href="http://www.google.com/search?q=textfieldautosize%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textfieldautosize.html"><span style="color: #004993;">TextFieldAutoSize</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">LEFT</span><span style="color: #000066; font-weight: bold;">;</span>
			output<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> = <span style="color: #990000;">&quot;Action: &quot;</span><span style="color: #000066; font-weight: bold;">;</span>
			output<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</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;">20</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>output<span style="color: #000000;">&#41;</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;">addEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=mouseevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:mouseevent.html"><span style="color: #004993;">MouseEvent</span></a><span style="color: #000066; font-weight: bold;">.</span>RIGHT_CLICK<span style="color: #000066; font-weight: bold;">,</span> mouseRightClikHandler<span style="color: #000000;">&#41;</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;">addEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=mouseevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:mouseevent.html"><span style="color: #004993;">MouseEvent</span></a><span style="color: #000066; font-weight: bold;">.</span>MIDDLE_CLICK<span style="color: #000066; font-weight: bold;">,</span> mouseMiddleClikHandler<span style="color: #000000;">&#41;</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;">addEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=mouseevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:mouseevent.html"><span style="color: #004993;">MouseEvent</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">CLICK</span><span style="color: #000066; font-weight: bold;">,</span> mouseClikHandler<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #000000;">&#125;</span>
		<span style="color: #3f5fbf;">/*__________________________________________________________________________________
		*
		*  Events Handlers
		* __________________________________________________________________________________
		*/</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> mouseRightClikHandler<span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=mouseevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:mouseevent.html"><span style="color: #004993;">MouseEvent</span></a><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>
			output<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> = <span style="color: #990000;">&quot;Action: <span style="">\&quot;</span>Right Click<span style="">\&quot;</span>&quot;</span><span style="color: #000066; font-weight: bold;">;</span>
			menu<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = <span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">mouseX</span><span style="color: #000066; font-weight: bold;">;</span>
			menu<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = <span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">mouseY</span><span style="color: #000066; font-weight: bold;">;</span>
			menu<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">visible</span> = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #000000;">&#125;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> mouseMiddleClikHandler<span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=mouseevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:mouseevent.html"><span style="color: #004993;">MouseEvent</span></a><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>
			output<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> = <span style="color: #990000;">&quot;Action: <span style="">\&quot;</span>Middle Click<span style="">\&quot;</span>&quot;</span><span style="color: #000066; font-weight: bold;">;</span>
			menu<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">visible</span> = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #000000;">&#125;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> mouseClikHandler<span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=mouseevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:mouseevent.html"><span style="color: #004993;">MouseEvent</span></a><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>
			output<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> = <span style="color: #990000;">&quot;Action: <span style="">\&quot;</span>Left Click<span style="">\&quot;</span>&quot;</span><span style="color: #000066; font-weight: bold;">;</span>
			menu<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">visible</span> = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #000000;">&#125;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> menuClickHandler<span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=mouseevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:mouseevent.html"><span style="color: #004993;">MouseEvent</span></a><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>
			e<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">stopPropagation</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			output<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> = <span style="color: #990000;">&quot;Action: Click on <span style="">\&quot;</span>&quot;</span> <span style="color: #000066; font-weight: bold;">+</span> menuItems<span style="color: #000000;">&#91;</span>e<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">target</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">name</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span>label<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #990000;">&quot;<span style="">\&quot;</span>&quot;</span><span style="color: #000066; font-weight: bold;">;</span>
			menu<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">visible</span> = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #000000;">&#125;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> menuItemOverHandler<span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=mouseevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:mouseevent.html"><span style="color: #004993;">MouseEvent</span></a><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>
			menuItems<span style="color: #000000;">&#91;</span>e<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">target</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">name</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span>label<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">textColor</span> = 0xff6600<span style="color: #000066; font-weight: bold;">;</span>
			menuItems<span style="color: #000000;">&#91;</span>e<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">target</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">name</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span>btn<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #000000;">&#125;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> menuItemMouseOutHandler<span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=mouseevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:mouseevent.html"><span style="color: #004993;">MouseEvent</span></a><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>
			menuItems<span style="color: #000000;">&#91;</span>e<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">target</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">name</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span>label<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">textColor</span> = 0xffffff<span style="color: #000066; font-weight: bold;">;</span>
			menuItems<span style="color: #000000;">&#91;</span>e<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">target</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">name</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span>btn<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> = <span style="color: #000066; font-weight: bold;">.</span>5<span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #000000;">&#125;</span>
		<span style="color: #3f5fbf;">/*__________________________________________________________________________________
		*
		*  Privates Functions
		* __________________________________________________________________________________
		*/</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> makeExampleMenu<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>
			menu = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=sprite%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:sprite.html"><span style="color: #004993;">Sprite</span></a><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><a href="http://www.google.com/search?q=uint%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:uint.html"><span style="color: #004993;">uint</span></a> = <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;">&amp;</span>lt<span style="color: #000066; font-weight: bold;">;</span> <span style="color: #000000; font-weight:bold;">6</span><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>
				menuItems<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=object%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:object.html"><span style="color: #004993;">Object</span></a><span style="color: #000066; font-weight: bold;">;</span>
				menuItems<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span>label = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=textfield%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textfield.html"><span style="color: #004993;">TextField</span></a><span style="color: #000066; font-weight: bold;">;</span>
				<span style="color: #009900; font-style: italic;">// ! casting just for AutoCompletion helper</span>
				<a href="http://www.google.com/search?q=textfield%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textfield.html"><span style="color: #004993;">TextField</span></a><span style="color: #000000;">&#40;</span>menuItems<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span>label<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">autoSize</span> = <a href="http://www.google.com/search?q=textfieldautosize%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textfieldautosize.html"><span style="color: #004993;">TextFieldAutoSize</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">LEFT</span><span style="color: #000066; font-weight: bold;">;</span>
				<a href="http://www.google.com/search?q=textfield%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textfield.html"><span style="color: #004993;">TextField</span></a><span style="color: #000000;">&#40;</span>menuItems<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span>label<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">selectable</span> = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span>
				menuItems<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span>label<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> = <span style="color: #990000;">&quot;Ceci est l'Item &quot;</span> <span style="color: #000066; font-weight: bold;">+</span> <a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a><span style="color: #000000;">&#40;</span>i<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
				menuItems<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span>label<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">textColor</span> = 0xffffff<span style="color: #000066; font-weight: bold;">;</span>
				menuItems<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span>label<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">mouseEnabled</span> = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span>
				menuItems<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span>label<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = <span style="color: #000000; font-weight:bold;">10</span><span style="color: #000066; font-weight: bold;">;</span>
				menuItems<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span>label<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = i <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>
				menuItems<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span>btn = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=sprite%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:sprite.html"><span style="color: #004993;">Sprite</span></a><span style="color: #000066; font-weight: bold;">;</span>
				menuItems<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span>btn<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">name</span> = i<span style="color: #000066; font-weight: bold;">;</span>
				menuItems<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span>btn<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">buttonMode</span> = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span>
				menuItems<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span>btn<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=mouseevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:mouseevent.html"><span style="color: #004993;">MouseEvent</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">MOUSE_OVER</span><span style="color: #000066; font-weight: bold;">,</span> menuItemOverHandler<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
				menuItems<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span>btn<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=mouseevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:mouseevent.html"><span style="color: #004993;">MouseEvent</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">MOUSE_OUT</span><span style="color: #000066; font-weight: bold;">,</span> menuItemMouseOutHandler<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
				menuItems<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span>btn<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">beginFill</span><span style="color: #000000;">&#40;</span>0x000000<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
				menuItems<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span>btn<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">drawRect</span><span style="color: #000000;">&#40;</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;">*</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;">100</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">20</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
				menuItems<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span>btn<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">endFill</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
				menuItems<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span>btn<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> = <span style="color: #000066; font-weight: bold;">.</span>5<span style="color: #000066; font-weight: bold;">;</span>
				menu<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>menuItems<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span>btn<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
				menu<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>menuItems<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span>label<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #000000;">&#125;</span>
			menu<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=mouseevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:mouseevent.html"><span style="color: #004993;">MouseEvent</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">CLICK</span><span style="color: #000066; font-weight: bold;">,</span> menuClickHandler<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			menu<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">visible</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;">this</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>menu<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></pre></td></tr></table></div>

<h1>Le mouseLock et le movementMouse</h1>
<p>Une autre nouvelle fonctionnalité est le <strong>mouseLock</strong>. Le but ici est de rendre la souris active tout le temps! Même en dehors du stage (donc, en dehors de l&#8217;animation et même de l&#8217;écran).</p>
<p>Seule restriction, le <strong>mouseLock </strong>n&#8217;est possible qu&#8217;on mode <strong>fullScreen </strong>! Si on essaye de l&#8217;activer en mode normal, cela génère une erreur d&#8217;exécution visible par le player debugger.</p>
<p>Lorsque le <strong>mouseLock </strong>est <strong>activé</strong>, le <strong>curseur </strong>de la souris <strong>disparaît </strong>! A la base, c&#8217;est logique, puisque dans ce mode, nous n&#8217;avons pas besoin de savoir où se trouve réellement la souris. &laquo;&nbsp;Ha bon&nbsp;&raquo;, vous allez me dire.. Oui! dans ce mode, seules les variations de souris nous intéressent.. Voici l&#8217;explication..</p>
<p>Normalement, quand a besoin de connaître les coordonnées de la souris, on lit une des propriétés <strong>stageX</strong>(Y) ou <strong>localX</strong>(Y) d&#8217;un évènement <code>MouseEvent</code>. Lorsque le <strong>mouseLock </strong>est <strong>actif</strong>, ces propriétés sont fixée à <strong>0 </strong>et ne peuvent plus servir! On peut être tenté d&#8217;utiliser <code>le stage.mouseX(Y)</code>, mais celui-ci ne fonctione plus non plus&#8230; Il renverra n&#8217;importe quoi, basé sur un delta que nous allons voir ci après. Donc, en mode &laquo;&nbsp;<strong>mouseLock</strong>&laquo;&nbsp;, on oublie le système de coordonnées classique.</p>
<p>Par contre, deux nouvelles propriétés ont été ajoutées à <code>MouseEvent</code>! Il s&#8217;agit de <strong>movementX </strong>et <strong>movementY</strong>. Ces nouvelles propriétés, à l&#8217;inverse des anciennes, ne sont actives qu&#8217;en mode mouseLock! Le reste du temps, elles sont fixées à 0.</p>
<p>Le &laquo;&nbsp;movement&nbsp;&raquo; est en fait un deltaMouse, le nombre de pixels de déplacement qui a eu lieu entre 2 appels de l&#8217;<code>Event</code> mouseMove.</p>
<p>Cette nouveauté peut servir à plein de choses&#8230; surtout pour les jeux et certaines applications&#8230; On est plus contraint à la taille de l&#8217;animation, on peut juste regretter que cette <strong>fonctionalité ne soit disponible qu&#8217;en fullScreen</strong>..</p>
<p>Dans l&#8217;exemple ci dessous, je fais tourner un jog shuttle sans math, juste grace au <strong>movementX</strong>.</p>
<p><strong>Pour passer en fullScreen, veuillez cliquer sur le rectangle noir</strong>.</p>
<p>On peut voir que les propriétés <strong>mouseX(Y)</strong> ne fonctionnent qu&#8217;en <strong>normalScreen </strong>et que les <strong>movementX(Y)</strong> ne fonctionnent qu&#8217;en <strong>fullScreen</strong>. Cela est dû à <strong>l&#8217;activation du mouseLock</strong> au moment du passage en fullScreen.</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_mouselock_1644543917"
			class="flashmovie"
			width="400"
			height="300">
	<param name="movie" value="http://www.covergraph.com/blog/flash/player11.2features/mouselock.swf" />
	<param name="scale" value="noscale" />
	<param name="allowfullscreen" value="true" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.covergraph.com/blog/flash/player11.2features/mouselock.swf"
			name="fm_mouselock_1644543917"
			width="400"
			height="300">
		<param name="scale" value="noscale" />
		<param name="allowfullscreen" value="true" />
	<!--<![endif]-->
		<br />
<a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a><br />

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<h3>Code simple qui permet de tester la chose.</h3>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p6842code4'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p68424"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
</pre></td><td class="code" id="p6842code4"><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> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=sprite%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:sprite.html"><span style="color: #004993;">Sprite</span></a><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>StageDisplayState<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><a href="http://www.google.com/search?q=stagescalemode%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:stagescalemode.html"><span style="color: #004993;">StageScaleMode</span></a><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=mouseevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:mouseevent.html"><span style="color: #004993;">MouseEvent</span></a><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.text</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=textfield%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textfield.html"><span style="color: #004993;">TextField</span></a><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.text</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=textfieldautosize%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textfieldautosize.html"><span style="color: #004993;">TextFieldAutoSize</span></a><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
	<span style="color: #3f5fbf;">/**
	 * ...
	 * @author Alama
	 */</span>
	<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> <a href="http://www.google.com/search?q=sprite%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:sprite.html"><span style="color: #004993;">Sprite</span></a>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> menuItems<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=array%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:array.html"><span style="color: #004993;">Array</span></a><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> menu<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=sprite%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:sprite.html"><span style="color: #004993;">Sprite</span></a><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> output<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=textfield%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textfield.html"><span style="color: #004993;">TextField</span></a><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> shuttle<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=sprite%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:sprite.html"><span style="color: #004993;">Sprite</span></a><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>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">stage</span><span style="color: #000000;">&#41;</span>
				<span style="color: #004993;">init</span><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;">else</span>
				<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">ADDED_TO_STAGE</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">init</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;">private</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">init</span><span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a> = <span style="color: #0033ff; font-weight: bold;">null</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;">removeEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">ADDED_TO_STAGE</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">init</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #009900; font-style: italic;">// entry point</span>
			output = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=textfield%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textfield.html"><span style="color: #004993;">TextField</span></a><span style="color: #000066; font-weight: bold;">;</span>
			output<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">autoSize</span> = <a href="http://www.google.com/search?q=textfieldautosize%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textfieldautosize.html"><span style="color: #004993;">TextFieldAutoSize</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">LEFT</span><span style="color: #000066; font-weight: bold;">;</span>
			output<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = <span style="color: #000000; font-weight:bold;">100</span><span style="color: #000066; font-weight: bold;">;</span>
			output<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> = <span style="color: #990000;">&quot;Stage Size = &quot;</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;">stageWidth</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #990000;">&quot; X &quot;</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: #004993;">addChild</span><span style="color: #000000;">&#40;</span>output<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			<span style="color: #6699cc; font-weight: bold;">var</span> btn<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=sprite%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:sprite.html"><span style="color: #004993;">Sprite</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=sprite%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:sprite.html"><span style="color: #004993;">Sprite</span></a><span style="color: #000066; font-weight: bold;">;</span>
			btn<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">beginFill</span><span style="color: #000000;">&#40;</span>0x000000<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			btn<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">drawRect</span><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;">40</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> <span style="color: #000000; font-weight:bold;">50</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			btn<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">endFill</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>btn<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			btn<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">buttonMode</span> = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span>
			btn<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=mouseevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:mouseevent.html"><span style="color: #004993;">MouseEvent</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">CLICK</span><span style="color: #000066; font-weight: bold;">,</span> btnClickHandler<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			shuttle = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=sprite%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:sprite.html"><span style="color: #004993;">Sprite</span></a><span style="color: #000066; font-weight: bold;">;</span>
			shuttle<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">beginFill</span><span style="color: #000000;">&#40;</span>0x333333<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			shuttle<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">drawCircle</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: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">100</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			shuttle<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">endFill</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			shuttle<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">beginFill</span><span style="color: #000000;">&#40;</span>0x999999<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			shuttle<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">drawCircle</span><span style="color: #000000;">&#40;</span><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> <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> <span style="color: #000000; font-weight:bold;">10</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			shuttle<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">endFill</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			shuttle<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = <span style="color: #000000; font-weight:bold;">100</span><span style="color: #000066; font-weight: bold;">;</span>
			shuttle<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = <span style="color: #000000; font-weight:bold;">260</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>shuttle<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			<span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">RESIZE</span><span style="color: #000066; font-weight: bold;">,</span> stageResizeHandler<span style="color: #000000;">&#41;</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;">addEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=mouseevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:mouseevent.html"><span style="color: #004993;">MouseEvent</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">MOUSE_MOVE</span><span style="color: #000066; font-weight: bold;">,</span> stageMouseMoveHandler<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #3f5fbf;">/*__________________________________________________________________________________
		 *
		 *  Events Handlers
		 * __________________________________________________________________________________
		 */</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> btnClickHandler<span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=mouseevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:mouseevent.html"><span style="color: #004993;">MouseEvent</span></a><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;">stage</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">displayState</span> = StageDisplayState<span style="color: #000066; font-weight: bold;">.</span>FULL_SCREEN<span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span>mouseLock = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> stageResizeHandler<span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><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>
			output<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> = <span style="color: #990000;">&quot;Stage Size = &quot;</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;">stageWidth</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #990000;">&quot; X &quot;</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;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> stageMouseMoveHandler<span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=mouseevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:mouseevent.html"><span style="color: #004993;">MouseEvent</span></a><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>
			output<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> = <span style="color: #990000;">&quot;Stage Size = &quot;</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;">stageWidth</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #990000;">&quot; X &quot;</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: #990000;">&quot;<span style="">\n</span>mouseX: &quot;</span> <span style="color: #000066; font-weight: bold;">+</span> e<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">stageX</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #990000;">&quot; - mouseY: &quot;</span> <span style="color: #000066; font-weight: bold;">+</span> e<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">stageY</span> <span style="color: #000066; font-weight: bold;">+</span>
			<span style="color: #990000;">&quot;<span style="">\n</span>movementX: &quot;</span> <span style="color: #000066; font-weight: bold;">+</span> e<span style="color: #000066; font-weight: bold;">.</span>movementX <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #990000;">&quot; - movementY: &quot;</span> <span style="color: #000066; font-weight: bold;">+</span> e<span style="color: #000066; font-weight: bold;">.</span>movementY<span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			shuttle<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">rotation</span> <span style="color: #000066; font-weight: bold;">+</span>= e<span style="color: #000066; font-weight: bold;">.</span>movementX<span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<h1>Conclusion</h1>
<p>Ces nouvelles fonctionnalités vont sans doute trouver un certain succès auprès des programmeurs&#8230; Surtout la gestion du clic droit et le fait de pouvoir faire ses propres menus contextuels.</p>
<p>Le mouseLock est très bien lorqu&#8217;on souhaitera avoir un contrôle qui va au-delà de l&#8217;espace de l&#8217;animation et même au-delà de l&#8217;écran (défilement de quelque chose, jeux, ..).</p>
<p>Il y a encore d&#8217;autres nouveautés telles que la mise à jour automatique du Player en arrière plan (tâche de fond) ou le décodage de la video (h264) en background, dans un thread séparé.</p>
<p>Les exemples de code (et swfs) présents sur cette page sont très primaires, ils ont pour but de démystifier les nouvelles fonctionnalités du Flash Player 11.2. A chacun d&#8217;y trouver un usage propre et de développer ses algorithmes persos&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashxpress.net/ressources-flash/nouveautes-flash-player-11-2-mouselock-right-click-et-cie/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Introduction au Starling Framework</title>
		<link>http://www.flashxpress.net/ressources-flash/introduction-au-starling-framework/</link>
		<comments>http://www.flashxpress.net/ressources-flash/introduction-au-starling-framework/#comments</comments>
		<pubDate>Thu, 20 Oct 2011 12:41:30 +0000</pubDate>
		<dc:creator>Nicolas Gans</dc:creator>
				<category><![CDATA[Flash ActionScript]]></category>
		<category><![CDATA[Tutoriels Flash]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Stage3D]]></category>
		<category><![CDATA[Starling]]></category>

		<guid isPermaLink="false">http://www.flashxpress.net/?p=6643</guid>
		<description><![CDATA[Avec la sortie de Flash player 11, une petite révolution fait son apparition : Stage3D. Connue auparavant sous le nom de Molehill, cette nouvelle API apporte ce dont beaucoup de développeurs Flash on rêvé : la VRAIE 3D, calculée par le GPU (carte graphique) de l'ordinateur. Si Stage3D permet évidemment d'afficher des modèles 3D complexes de plusieurs dizaine de milliers de polygones (voir ici, ici et là), un autre usage a rapidement été envisagé : l'affichage 2D. En effet, qu'est ce que la 2D, sinon de la 3D avec une dimension en moins ;)]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-6704" title="starling_header" src="http://www.flashxpress.net/wp-content/uploads/2011/10/starling_header.jpg" alt="" width="630" height="300" /></p>
<h1>Starling Framework ? Keskeussé ?</h1>
<p>Avec la sortie de Flash player 11, une petite révolution fait son apparition : <strong>Stage3D</strong>. Connue auparavant sous le nom de Molehill, cette nouvelle API apporte ce dont beaucoup de développeurs Flash ont rêvé : la <span style="text-decoration: underline;"><strong>VRAIE</strong></span> 3D, calculée par le GPU (carte graphique) de l&#8217;ordinateur. Si Stage3D permet évidemment d&#8217;afficher des modèles 3D complexes de plusieurs dizaines de milliers de polygones (voir <a title="Les Chinois" href="http://www.leschinois.com/" target="_blank">ici</a>, <a title="Flare3D" href="http://www.flare3d.com/demos/max/gargoile.html" target="_blank">ici</a> et <a title="Alternativa3D" href="http://alternativaplatform.com/en/demos/crash/" target="_blank">là</a>), <strong>un autre usage a rapidement été envisagé : l&#8217;affichage 2D.</strong> En effet, qu&#8217;est ce que la 2D, sinon de la 3D avec une dimension en moins <img src='http://www.flashxpress.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Dans cette optique, Adobe a annoncé récemment la sortie d&#8217;une librairie nommée <a title="Starling Framework" href="http://www.starling-framework.org/" target="_blank">Starling Framework</a> qui permet un affichage 2D beaucoup plus rapide que l&#8217;affichage &laquo;&nbsp;classique&nbsp;&raquo; de Flash, en s&#8217;appuyant sur la puissance de calcul du GPU et les nouvelles API de Stage3D. Signalons qu&#8217;Adobe n&#8217;a pas développé Starling directement, mais que c&#8217;est <a href="http://bytearray.org" target="_blank">Thibault Imbert</a>, product manager responsable de Stage3D, qui a demandé à <strong>Daniel Sperl</strong> de porter Sparrow &#8211; une librairie pour iOS reproduisant les mécanismes de la liste d&#8217;affichage de Flash &#8211; en ActionScript 3. La bonne nouvelle, <span style="text-decoration: underline;">c&#8217;est que Starling est Open Source et fortement communautaire</span> : chacun a accès au code, peut le modifier et l&#8217;enrichir selon ses besoins propres ou ceux de la communauté !</p>
<p><strong>Note culturelle</strong> : <em>en français, Starling signifie étourneau. D&#8217;où l&#8217;image utilisée comme illustration</em> <img src='http://www.flashxpress.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<h1>Demo Time !</h1>
<p>Mettons de côté le blabla quelques secondes et allez voir ces deux petits tests que j&#8217;ai réalisé pour vous rendre compte des performances de Starling (<span style="text-decoration: underline;">ATTENTION : il faut le Flash Player 11</span>) :</p>
<p><a title="Particules Starling" href="http://www.kouma.fr/lab/StarlingParticles/" target="_blank"><img class="alignnone size-full wp-image-6645" title="starling_tuto_01" src="http://www.flashxpress.net/wp-content/uploads/2011/10/starling_tuto_01-e1319034008695.png" alt="" width="630" height="369" /><br />
</a>Des petites particules, parce que c&#8217;est joli et que&#8230; tout le monde aime les particules <img src='http://www.flashxpress.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><a title="Starling Stress Test" href="http://www.kouma.fr/lab/StarlingStressTest/" target="_blank"><img class="alignnone size-full wp-image-6648" title="starling_tuto_02" src="http://www.flashxpress.net/wp-content/uploads/2011/10/starling_tuto_02-e1319034440957.png" alt="" width="630" height="367" /><br />
</a>Un stress test pour voir jusqu&#8217;où Starling tient : cliquez sur le bouton en haut à gauche pour ajouter plein de MovieClip et les faire bouger dans tous les sens.</p>
<p>Je ne sais pas ce que vous en pensez, mais personnellement je trouve que Starling envoie ! Pour les mauvais esprits (il y&#8217;en a), notez bien que <strong>Starling n&#8217;en est qu&#8217;à la V1 et que des optimisations sont déjà envisagées</strong>, qui seront ajoutées dans une mise à jour future.</p>
<h1>Pourquoi utiliser Starling ?</h1>
<p>En premier lieu, <strong>pour les performances</strong> ! D&#8217;autant que Stage3D arrivera bientôt sur nos téléphones et tablettes via <strong>AIR 3.1</strong>. Alors que des optimisations complexes étaient nécessaire pour atteindre péniblement les 30 fps avec la liste d&#8217;affichage traditionnelle de Flash, on peut tout à fait envisager que Stage3D nous permette de rivaliser en terme de performances avec les applications &laquo;&nbsp;natives&nbsp;&raquo;.</p>
<p>En second lieu, parce que Starling a été pensé <strong>pour coller à l&#8217;API de la DisplayList de Flash</strong> : on y retrouve nos Sprite, MovieClip, addChild(), removeChild(), etc&#8230; ainsi qu&#8217;un modèle événementiel calqué sur celui de Flash avec un support du bubbling. <strong>La transition est donc largement simplifiée pour les développeurs</strong>, avec tout de même des spécificités propres à un environnement &laquo;&nbsp;full GPU&nbsp;&raquo;. En effet, dès lors que l&#8217;on confie l&#8217;affichage au GPU et non plus au CPU, il faut dire adieu au vectoriel et n&#8217;utiliser que des bitmaps. Mais nous allons en reparler dans ce tutoriel&#8230;</p>
<p>Enfin, il faut reconnaître que Starling a été <strong>pensé avant tout pour le jeu 2D</strong>, et même si on peut tout-à-fait l&#8217;envisager pour de l&#8217;application mobile ou du site &laquo;&nbsp;multimédia&nbsp;&raquo;, ce n&#8217;est pas son but premier&#8230; Pas étonnant dès lors que les premières démos crées avec Starling soient des casual games Flash :</p>
<p><iframe src="http://www.youtube.com/embed/yOtnRSaoK-c" frameborder="0" width="630" height="350"></iframe><br />
Angry Bird pour le player 11, c&#8217;est pour bientôt dans le browser.</p>
<p>Toutefois, la nature &laquo;&nbsp;low-level&nbsp;&raquo; de Stage3D permet à chacun &#8211; pour peu qu&#8217;il en ait la capacité &#8211; de créer son propre moteur 2D. <strong>Il existe ainsi un &laquo;&nbsp;concurrent&nbsp;&raquo; à Starling</strong> : <a title="ND2D framework" href="https://github.com/nulldesign/nd2d" target="_blank">ND2D</a>, qui fait à peu près la même chose et qui est plutôt plus optimisé. Et même si Starling est officiellement supporté par Adobe, rien ne vous oblige à l&#8217;utiliser !</p>
<p>Ceci étant dit, passons à la pratique !</p>
<h1>Mise en place</h1>
<p>Pour notre exemple nous utiliserons Flash Builder 4.5.</p>
<h2>Téléchargements</h2>
<p>Tout d&#8217;abord, il faut télécharger les fichiers suivants :</p>
<ul>
<li>Si le SDK 4.5.1 n&#8217;est pas déjà installé dans le dossier &laquo;&nbsp;sdks&nbsp;&raquo; du répertoire d&#8217;install de Flash Builder, il faudra le télécharger : <a title="Flex SDK 4.5.1" href="http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+4.5" target="_blank">http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+4.5</a></li>
</ul>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/10/starling_tuto_03.png"><img class="alignnone size-full wp-image-6669" style="border-width: 1px; border-color: black; border-style: solid;" title="starling_tuto_03" src="http://www.flashxpress.net/wp-content/uploads/2011/10/starling_tuto_03-e1319099653341.png" alt="" width="594" height="284" /></a></p>
<ul>
<li>Télécharger le SDK AIR 3.0 : <a title="AIR SDK" href="http://www.adobe.com/special/products/air/sdk/" target="_blank">http://www.adobe.com/special/products/air/sdk/</a></li>
<li>Télécharger la librairie Starling : <a title="Starling Framework" href="http://www.starling-framework.org" target="_blank">http://www.starling-framework.org</a> (le gros bouton &laquo;&nbsp;DOWNLOAD&nbsp;&raquo;)</li>
</ul>
<h2>Installation du SDK</h2>
<h3>Windows</h3>
<p>1) Allez dans le dossier &laquo;&nbsp;<strong>sdks</strong>&nbsp;&raquo; du répertoire d&#8217;installation de Flash Builder 4.5. Si le SDK 4.5.1 est déjà présent, faites-en une copie et renommez-la « <strong>AIR 3.0</strong> ». Sinon, dézippez l&#8217;archive téléchargée à l&#8217;étape précédente et renommez le répertoire « <strong>AIR 3.0</strong> ».</p>
<p>2) Copiez ensuite le .zip du SDK AIR 3.0 dans le dossier « AIR 3.0 » et dézippez-la <span style="text-decoration: underline;"><strong>en veillant bien à écraser les fichiers déjà présents</strong></span>.</p>
<h3>MAC OS</h3>
<p>1) Allez dans le dossier « <strong>sdks</strong> » du répertoire d&#8217;installation de Flash Builder 4.5. Si le SDK 4.5.1 est déjà présent, faites-en une copie et renommez-la « <strong>AIR 3.0</strong> ». Sinon, dézippez l&#8217;archive téléchargée à l&#8217;étape précédente et renommez le répertoire « <strong>AIR 3.0</strong> ».</p>
<p>2) Placer l’archive « <strong>AdobeAIRSDK.tbz2</strong> » dans le répertoire « <strong>AIR 3.0</strong> ».</p>
<p>3) Ouvrir le Terminal, aller dans le répertoire dans lequel on a copié le AIR SDK avec la commande suivante (valider en appuyant sur return) :</p>
<pre><span style="color: #808080;">cd /Applications/Adobe Flash Builder 4.5/sdks/</span></pre>
<p>Il faut échapper les espaces avec un « \ »</p>
<p><strong>Note</strong> : <em>on peut faire un drag n’drop du répertoire dans le terminal pour récupérer automatiquement le chemin d’accès. <strong>METTRE « cd » devant le chemin !!</strong></em></p>
<p>4) Puis taper la commande suivante et appuyer sur return :</p>
<pre><span style="color: #808080;">tar jxvf AdobeAIRSDK.tbz2</span></pre>
<p>Cela dézippera l’archive et la fusionnera avec Flex SDK.</p>
<h3>playerglobal.swc</h3>
<p><span style="text-decoration: underline;">Ajout du 27 octobre 2011 (merci à Dredge pour le commentaire).</span></p>
<p>Vous aurez éventuellement besoin du playerglobal.swc de Flash 11 : il contient les définitions de classes compilés et si il n&#8217;est pas présent par défaut dans le SDK, il faut donc l&#8217;ajouter.</p>
<p>Pour vérifier si ce fichier est présent, aller dans le répertoire de Flash Builder, puis dans « sdks\AIR 3.0\frameworks\libs\player ». <strong>Si le répertoire « 11.0 » n&#8217;est pas présent, il faut l&#8217;ajouter.</strong></p>
<p>Pour remédier à ça :<br />
- Télécharger le playerglobal.swc depuis cette url : <a href="http://fpdownload.macromedia.com/pub/flashplayer/updaters/11/playerglobal11_0.swc" rel="nofollow">http://fpdownload.macromedia.com/pub/flashplayer/updaters/11/playerglobal11_0.swc</a><br />
- renommer le fichier en « playerglobal.swc »<br />
- dans le répertoire de Flash Builder, aller dans « sdks\AIR 3.0\frameworks\libs\player »<br />
- créer un répertoire « 11.0 » et y placer le « playerglobal.swc »</p>
<p>Si FB vous signale une erreur, nettoyer le projet via le menu « project/clean/ », cela devrait supprimer l’erreur.</p>
<h3>Ajout du SDK à Flash Builder</h3>
<p>1) Lancer Flash Builder et aller dans les préférences. <strong>Window &gt; Preferences</strong> (Fenêtre &gt; Préférences) sous Windows ou <strong>Flash Builder &gt; Preferences</strong> sous MAC OS.</p>
<p>2) Dans le champ de recherche, taper “<strong>sdk</strong>”, puis sélectionner “<strong>Installed Flex SDKs</strong>”.</p>
<p>3) Vous pouvez voir la liste des SDKs installés, les mêmes que dans le répertoire &laquo;&nbsp;<strong>sdks</strong>&nbsp;&raquo; de l&#8217;application. Cliquer sur le bouton &laquo;&nbsp;<strong>Add…</strong>&nbsp;&raquo; situé à droite de la liste :</p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/10/starling_tuto_04.png"><img class="alignnone size-full wp-image-6671" title="starling_tuto_04" src="http://www.flashxpress.net/wp-content/uploads/2011/10/starling_tuto_04.png" alt="" width="774" height="537" /></a></p>
<p>4) Dans la fenêtre ouverte, &laquo;&nbsp;<strong>Flex SDK location</strong>&nbsp;&raquo; : parcourir le disque dur et sélectionner le répertoire « <strong>AIR 3.0</strong> » créé précédemment.</p>
<p>5) &laquo;&nbsp;<strong>Flex SDK name</strong>&nbsp;&raquo; : taper « <strong>AIR 3.0</strong> ».</p>
<p>6) Puis valider en cliquant sur &laquo;&nbsp;<strong>OK</strong>&laquo;&nbsp;.</p>
<p><strong>En principe, le SDK doit dorénavant apparaître dans la liste des SDKs installés.</strong></p>
<h2>Création d&#8217;une librairie Starling</h2>
<p>Pour utiliser la librairie Starling dans différents projets Flash Builder, nous allons créer une librairie <strong>qui pourra être partagée entre différents projets</strong>, évitant ainsi la duplication des classes Starling.</p>
<p>1) Créer un projet de type &laquo;&nbsp;<strong>Flex Library Project</strong>&nbsp;&raquo;</p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/10/starling_tuto_05.png"><img class="alignnone size-full wp-image-6676" title="starling_tuto_05" src="http://www.flashxpress.net/wp-content/uploads/2011/10/starling_tuto_05.png" alt="" width="661" height="137" /></a></p>
<p>2) Nommer ce projet StarlingLib et choisir le SDK « <strong>AIR 3.0</strong> » :</p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/10/starling_tuto_06.png"><img class="alignnone size-full wp-image-6677" title="starling_tuto_06" src="http://www.flashxpress.net/wp-content/uploads/2011/10/starling_tuto_06.png" alt="" width="525" height="577" /></a></p>
<p>3) Une fois le projet créé, faire un <strong>clic droit sur le projet &gt; &laquo;&nbsp;Properties</strong>&laquo;&nbsp;, puis sélectionner &laquo;&nbsp;<strong>Flex Librairy Compiler</strong>&nbsp;&raquo; dans la colonne de gauche. Cibler le <strong>player 11.0.0</strong> et ajouter « <strong>-swf-version=13</strong> » dans les paramètres additionnels du compilateur :</p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/10/starling_tuto_07.png"><img class="alignnone size-full wp-image-6678" title="starling_tuto_07" src="http://www.flashxpress.net/wp-content/uploads/2011/10/starling_tuto_07.png" alt="" width="784" height="697" /></a></p>
<p>4) Copier les classes de l&#8217;archive du Starling Framework dans le dossier &laquo;&nbsp;<strong>src</strong>&nbsp;&raquo; du projet StarlingLib. Les classes de Starling se trouvent dans le dossier &laquo;&nbsp;<strong>Starling/src</strong>&nbsp;&raquo; de l&#8217;archive. <strong><span style="text-decoration: underline;">Il faut aussi copier le dossier &laquo;&nbsp;media&nbsp;&raquo;, sinon une erreur d&#8217;embed sera générée par Flash Builder !</span></strong> Au final, vous aurez trois répertoires dans le dossier &laquo;&nbsp;<strong>src</strong>&nbsp;&raquo; :</p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/10/starling_tuto_08.png"><img class="alignnone size-full wp-image-6679" title="starling_tuto_08" src="http://www.flashxpress.net/wp-content/uploads/2011/10/starling_tuto_08.png" alt="" width="411" height="78" /></a></p>
<p>5) En principe, un fichier <strong>StarlingLib.swc</strong> a été créé dans le répertoire &laquo;&nbsp;<strong>bin</strong>&nbsp;&raquo; du projet StarlingLib.</p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/10/starling_tuto_09.png"><img class="alignnone size-full wp-image-6680" title="starling_tuto_09" src="http://www.flashxpress.net/wp-content/uploads/2011/10/starling_tuto_09.png" alt="" width="378" height="136" /></a></p>
<p><strong>Note</strong> : <em>si Flash Builder peine à créer le .swc, faites un clic droit sur le projet &gt; &laquo;&nbsp;Refresh&nbsp;&raquo;.</em></p>
<p><strong>Vous pourrez maintenant utiliser cette librairie pour tous vos projets Starling, en l&#8217;ajoutant au &laquo;&nbsp;library path&nbsp;&raquo; du projet (voir exemple ci-dessous).</strong></p>
<h2>Création d&#8217;un premier projet Starling</h2>
<p>1) Dans Flash Builder, créer un nouveau &laquo;&nbsp;<strong>ActionScript Project</strong>&nbsp;&raquo; :</p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/10/starling_tuto_10.png"><img class="alignnone size-full wp-image-6682" title="starling_tuto_10" src="http://www.flashxpress.net/wp-content/uploads/2011/10/starling_tuto_10.png" alt="" width="636" height="133" /></a></p>
<p>2) Choisir le SDK &laquo;&nbsp;<strong>AIR 3.0</strong>&nbsp;&raquo; :</p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/10/starling_tuto_11.png"><img class="alignnone size-full wp-image-6683" title="starling_tuto_11" src="http://www.flashxpress.net/wp-content/uploads/2011/10/starling_tuto_11.png" alt="" width="515" height="547" /></a></p>
<p>3) Dans le panneau suivant, cliquer sur &laquo;&nbsp;<strong>Add Project</strong>&nbsp;&raquo; pour ajouter la StarlingLib à votre projet (<strong>Note</strong> : <em>le projet StarlingLib doit être ouvert</em>) :</p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/10/starling_tuto_12.png"><img class="alignnone size-full wp-image-6684" title="starling_tuto_12" src="http://www.flashxpress.net/wp-content/uploads/2011/10/starling_tuto_12.png" alt="" width="530" height="313" /></a></p>
<p>4) Une fois le projet créé, faire un <strong>clic droit sur le projet &gt; &laquo;&nbsp;Properties&nbsp;&raquo;</strong>, puis sélectionner &laquo;&nbsp;<strong>ActionScript Compiler</strong>&nbsp;&raquo; dans la colonne de gauche. Cibler le <strong>player 11.0.0</strong> et ajouter &laquo;&nbsp;<strong>-swf-version=13</strong>&nbsp;&raquo; dans les paramètres additionnels du compilateur :</p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/10/starling_tuto_13.png"><img class="alignnone size-full wp-image-6685" title="starling_tuto_13" src="http://www.flashxpress.net/wp-content/uploads/2011/10/starling_tuto_13.png" alt="" width="784" height="687" /></a></p>
<p>5) Dernière étape, <strong>il faut modifier le template HTML</strong> utilisé par Flash Builder. En effet le &laquo;&nbsp;<strong>wmode</strong>&nbsp;&raquo; utilisé par Stage3D est le mode &laquo;&nbsp;<strong>direct</strong>&laquo;&nbsp;. <strong>Si vous ne le modifiez pas, rien ne s&#8217;affichera dans le .swf !<br />
</strong>Ouvrir le fichier &laquo;&nbsp;index.template.html&nbsp;&raquo; dans l&#8217;éditeur de texte de Flash Builder :</p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/10/starling_tuto_14.png"><img class="alignnone size-full wp-image-6686" title="starling_tuto_14" src="http://www.flashxpress.net/wp-content/uploads/2011/10/starling_tuto_14.png" alt="" width="671" height="403" /></a></p>
<p>6) Il faut ajouter à ce template le<strong> wmode=direct</strong> à plusieurs endroits :</p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/10/starling_tuto_15.png"><img class="alignnone size-full wp-image-6687" style="border-width: 1px; border-color: black; border-style: solid;" title="starling_tuto_15" src="http://www.flashxpress.net/wp-content/uploads/2011/10/starling_tuto_15.png" alt="" width="736" height="382" /></a></p>
<p>et là aussi :</p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/10/starling_tuto_16.png"><img class="alignnone size-full wp-image-6688" style="border-width: 1px; border-color: black; border-style: solid;" title="starling_tuto_16" src="http://www.flashxpress.net/wp-content/uploads/2011/10/starling_tuto_16.png" alt="" width="468" height="483" /></a></p>
<p><strong>Félicitations ! Vous voilà prêt à faire votre premier projet en Starling.</strong></p>
<h1>Codons un peu&#8230;</h1>
<p>Pour fonctionner, un projet Starling doit contenir une classe qui hérite de &laquo;&nbsp;<strong>starling.display.Sprite</strong>&nbsp;&raquo; qui sera le root de notre application Starling. En effet, Starling n&#8217;utilise pas la display list de Flash mais s&#8217;affiche via Stage3D qui est une autre couche de rendu du player Flash, indépendante de la display list &laquo;&nbsp;classique&nbsp;&raquo;.</p>
<p>Nous allons donc commencer par créer cette &laquo;&nbsp;<strong>classe du document Starling</strong>&nbsp;&raquo; :</p>
<p>1) Clic droit sur le dossier &laquo;&nbsp;<strong>src</strong>&nbsp;&raquo; du projet, puis &laquo;&nbsp;<strong>New &gt; ActionScript Class</strong>&nbsp;&raquo;</p>
<p>2) Indiquez un package (j&#8217;ai mis &laquo;&nbsp;classes&nbsp;&raquo;), nommez votre classe &laquo;&nbsp;<strong>StarlingMain</strong>&nbsp;&raquo; et faites-là hériter de &laquo;&nbsp;<span style="text-decoration: underline;"><strong>starling.display.Sprite</strong></span>&nbsp;&raquo; (et non de &laquo;&nbsp;flash.display.Sprite&nbsp;&raquo;) :</p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/10/starling_tuto_17.png"><img class="alignnone size-full wp-image-6693" title="starling_tuto_17" src="http://www.flashxpress.net/wp-content/uploads/2011/10/starling_tuto_17.png" alt="" width="525" height="617" /></a></p>
<p>3) Créer un dossier &laquo;&nbsp;<strong>assets</strong>&nbsp;&raquo; dans votre projet HelloStarling et y placer un .jpg de votre choix en le nommant &laquo;&nbsp;<strong>starling.jpg</strong>&nbsp;&raquo; : cette image sera incluse via un <a title="Embed" href="http://www.flashxpress.net/ressources-flash/embarquer-des-assets-externes-avec-embed/" target="_blank">embed</a> et utilisée <strong>comme texture d&#8217;affichage</strong>.</p>
<p>4) Puis taper le code suivant :</p>
<p><strong>Note</strong> : <em><span style="text-decoration: underline;">faites bien attention aux import des classes</span>. En effet, Starling utilise les mêmes noms de classes que les DisplayObjects Flash, il peut donc y avoir des conflits entre les deux. Toutes les classes du framework commence par le package &laquo;&nbsp;starling&nbsp;&raquo;.</em></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p6643code5'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p66435"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
</pre></td><td class="code" id="p6643code5"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> classes
<span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> starling<span style="color: #000066; font-weight: bold;">.</span>display<span style="color: #000066; font-weight: bold;">.</span>Image<span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> starling<span style="color: #000066; font-weight: bold;">.</span>display<span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=sprite%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:sprite.html"><span style="color: #004993;">Sprite</span></a><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> starling<span style="color: #000066; font-weight: bold;">.</span>events<span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> starling<span style="color: #000066; font-weight: bold;">.</span>textures<span style="color: #000066; font-weight: bold;">.</span>Texture<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> StarlingMain <span style="color: #0033ff; font-weight: bold;">extends</span> <a href="http://www.google.com/search?q=sprite%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:sprite.html"><span style="color: #004993;">Sprite</span></a>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #009900; font-style: italic;">// embed avec le chemin d'accès à notre .jpg contenu dans le dossier assets</span>
		<span style="color: #000000;">&#91;</span>Embed<span style="color: #000000;">&#40;</span><span style="color: #004993;">source</span>=<span style="color: #990000;">&quot;../assets/starling.jpg&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> static const myBitmap<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=class%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:class.html"><span style="color: #004993;">Class</span></a><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> StarlingMain<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;">this</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">ADDED_TO_STAGE</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">init</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> <span style="color: #004993;">init</span><span style="color: #000000;">&#40;</span>event<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><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: #0033ff; font-weight: bold;">this</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">removeEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">ADDED_TO_STAGE</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">init</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			<span style="color: #009900; font-style: italic;">// création d'une Texture à partir du bitmap embedé</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> texture<span style="color: #000066; font-weight: bold;">:</span>Texture = Texture<span style="color: #000066; font-weight: bold;">.</span>fromBitmap <span style="color: #000000;">&#40;</span> <span style="color: #0033ff; font-weight: bold;">new</span> myBitmap<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>
			<span style="color: #009900; font-style: italic;">// création d'une instance d'Image avec notre texture</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> image<span style="color: #000066; font-weight: bold;">:</span>Image = <span style="color: #0033ff; font-weight: bold;">new</span> Image<span style="color: #000000;">&#40;</span>texture<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #009900; font-style: italic;">// affichage de l'image</span>
			<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>image<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>5) Dans la classe <strong>HelloStarling</strong> (classe du document) de votre projet, tapez le code suivant :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p6643code6'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p66436"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
</pre></td><td class="code" id="p6643code6"><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> classes<span style="color: #000066; font-weight: bold;">.</span>StarlingMain<span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=sprite%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:sprite.html"><span style="color: #004993;">Sprite</span></a><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><a href="http://www.google.com/search?q=stagealign%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:stagealign.html"><span style="color: #004993;">StageAlign</span></a><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><a href="http://www.google.com/search?q=stagescalemode%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:stagescalemode.html"><span style="color: #004993;">StageScaleMode</span></a><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">import</span> starling<span style="color: #000066; font-weight: bold;">.</span>core<span style="color: #000066; font-weight: bold;">.</span>Starling<span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
	<span style="color: #000000;">&#91;</span>SWF<span style="color: #000000;">&#40;</span><span style="color: #004993;">frameRate</span>=<span style="color: #990000;">&quot;60&quot;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">backgroundColor</span>=<span style="color: #990000;">&quot;#DDDDDD&quot;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;960&quot;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;660&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> HelloStarling <span style="color: #0033ff; font-weight: bold;">extends</span> <a href="http://www.google.com/search?q=sprite%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:sprite.html"><span style="color: #004993;">Sprite</span></a>
	<span style="color: #000000;">&#123;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> myStarling<span style="color: #000066; font-weight: bold;">:</span>Starling<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> HelloStarling<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
&nbsp;
			<span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">align</span> = <a href="http://www.google.com/search?q=stagealign%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:stagealign.html"><span style="color: #004993;">StageAlign</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">TOP_LEFT</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;">scaleMode</span> = <a href="http://www.google.com/search?q=stagescalemode%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:stagescalemode.html"><span style="color: #004993;">StageScaleMode</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">NO_SCALE</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			<span style="color: #009900; font-style: italic;">// création d'une instance de Starling</span>
			myStarling = <span style="color: #0033ff; font-weight: bold;">new</span> Starling<span style="color: #000000;">&#40;</span>StarlingMain<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">stage</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			<span style="color: #009900; font-style: italic;">// réglage de l'antialiasing (valeur haute = meilleure qualité, mais performances moindres)</span>
			myStarling<span style="color: #000066; font-weight: bold;">.</span>antiAliasing = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			<span style="color: #009900; font-style: italic;">// démarrage</span>
			myStarling<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>
&nbsp;
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>7) Compiler votre projet&#8230; et voilà le résultat :</p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/10/starling_tuto_18-e1319108538125.png"><img class="alignnone size-full wp-image-6694" title="starling_tuto_18" src="http://www.flashxpress.net/wp-content/uploads/2011/10/starling_tuto_18-e1319108538125.png" alt="" width="630" height="453" /></a></p>
<p>Bravo ! Votre premier projet Starling fonctionne.</p>
<p><strong>Rien de très impressionnant pour le moment, mais nous verrons dans de prochains tutoriels comment donner un peu vie à tout ça.</strong></p>
<p>Merci pour votre patience et à bientôt pour la suite <img src='http://www.flashxpress.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><a href="http://twitter.com/#!/nicolasgans" target="_blank">Nicolas Gans</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashxpress.net/ressources-flash/introduction-au-starling-framework/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>E-seminaire &#171;&#160;Développement de jeu avec AIR mobile&#160;&#187; chez Adobe le 4 octobre</title>
		<link>http://www.flashxpress.net/ressources-flash/e-seminaire-developpement-de-jeu-avec-air-mobile-chez-adobe-le-4-octobre/</link>
		<comments>http://www.flashxpress.net/ressources-flash/e-seminaire-developpement-de-jeu-avec-air-mobile-chez-adobe-le-4-octobre/#comments</comments>
		<pubDate>Fri, 23 Sep 2011 14:40:10 +0000</pubDate>
		<dc:creator>Nicolas Gans</dc:creator>
				<category><![CDATA[Evénements]]></category>
		<category><![CDATA[Flash ActionScript]]></category>
		<category><![CDATA[Flash mobile]]></category>
		<category><![CDATA[Tutoriels Flash]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[iOS]]></category>

		<guid isPermaLink="false">http://www.flashxpress.net/?p=6565</guid>
		<description><![CDATA[Le 4 octobre prochain de 14h à 15h, Nicolas Gans &#8211; formateur Flash chez Regart.net &#8211; sera chez Adobe France pour animer un e-seminaire sur le thème &#171;&#160;Développement de jeu avec AIR mobile&#160;&#187;. Lors de cet atelier online, il abordera la création d&#8217;un casse-brique en AIR mobile avec Flash CS5.5 et Flash Builder, depuis la [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/09/illus_focus_eseminar.png"><img class="alignnone size-full wp-image-6568" title="illus_focus_eseminar" src="http://www.flashxpress.net/wp-content/uploads/2011/09/illus_focus_eseminar.png" alt="" width="630" height="225" /></a></p>
<p><strong>Le 4 octobre prochain de 14h à 15h</strong>, Nicolas Gans &#8211; formateur Flash chez <a title="Centre de formation agréé Adobe" href="http://www.regart.net" target="_blank">Regart.net</a> &#8211; sera chez Adobe France pour animer un e-seminaire sur le thème &laquo;&nbsp;Développement de jeu avec AIR mobile&nbsp;&raquo;.</p>
<p>Lors de cet atelier online, il abordera la création d&#8217;un casse-brique en AIR mobile avec Flash CS5.5 et Flash Builder, depuis la création des assets graphiques jusqu&#8217;au code et la compilation pour les différentes plate-formes (iOS, Android&#8230;).</p>
<p>Au programme :<br />
- le concept de multi-screen et ses conséquences pour le développement d&#8217;applications mobiles<br />
- préparation des éléments graphiques dans Flash CS5.5<br />
- optimisation des éléments graphiques pour le mobile<br />
- choix du mode de rendu : CPU ou GPU<br />
- configuration de la compilation pour iOS et Android : certificats, provisioning profiles&#8230;<br />
- gestion des différentes tailles d&#8217;écran<br />
- liaison avec Flash Builder<br />
- mise en cache des éléments graphiques<br />
- partial et full blitting<br />
- object pooling</p>
<p>Le e-seminar nécessite une inscription en ligne, cliquez sur ce lien :<br />
<a href="http://www.adobe-events-france.com/event/creation-dapplications-mobile-flash-avec-flash-pro-et-flash-builder/" target="_blank">http://www.adobe-events-france.com/event/creation-dapplications-mobile-flash-avec-flash-pro-et-flash-builder/</a></p>
<p><span style="text-decoration: underline;"><strong>Edit du 4 octobre 2011 :</strong></span><br />
<strong><a href="http://www.flashxpress.net/wp-content/uploads/2011/10/eseminaire_regart_adobe_04_10_2011.zip">&gt;&gt; Télécharger les fichiers du e-séminaire</a></strong></p>
<p><strong>Notes :</strong><br />
- pour compiler le casse brique, il faudra importer le projet &laquo;&nbsp;Casse brique&nbsp;&raquo; dans Flash Builder 4.5<br />
- il vous faudra aussi créer vos certificats .p12 et provisioning profiles si vous souhaitez compiler le projet</p>
<div id="__ss_9542663" style="width: 595px;">
<p><strong style="display: block; margin: 12px 0 4px;"><a title="e-séminaire Regart.net / Adobe : &quot;Création d'un jeu AIR mobile&quot;" href="http://www.slideshare.net/maru.maru/esminaire-regartnet-adobe-cration-dun-jeu-air-mobile-p" target="_blank">e-séminaire Regart.net / Adobe : &laquo;&nbsp;Création d&#8217;un jeu AIR mobile&nbsp;&raquo;</a></strong> <object id="__sse9542663" width="595" height="497" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="src" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=eseminaireregartadobe04102011-111004092528-phpapp01&amp;stripped_title=esminaire-regartnet-adobe-cration-dun-jeu-air-mobile-p&amp;userName=maru.maru" /><param name="allowscriptaccess" value="always" /><param name="allowfullscreen" value="true" /><embed id="__sse9542663" width="595" height="497" type="application/x-shockwave-flash" src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=eseminaireregartadobe04102011-111004092528-phpapp01&amp;stripped_title=esminaire-regartnet-adobe-cration-dun-jeu-air-mobile-p&amp;userName=maru.maru" allowFullScreen="true" allowScriptAccess="always" allowscriptaccess="always" allowfullscreen="true" /> </object></p>
<div style="padding: 5px 0 12px;">View more <a href="http://www.slideshare.net/" target="_blank">presentations</a> from <a href="http://www.slideshare.net/maru.maru" target="_blank">maru.maru</a></div>
</div>
<p>A très bientôt !</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashxpress.net/ressources-flash/e-seminaire-developpement-de-jeu-avec-air-mobile-chez-adobe-le-4-octobre/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Applications iOS avec AIR mobile : création de certificats .p12 et de provisioning files</title>
		<link>http://www.flashxpress.net/ressources-flash/applications-ios-avec-air-mobile-creation-de-certificats-p12-et-de-provisioning-files/</link>
		<comments>http://www.flashxpress.net/ressources-flash/applications-ios-avec-air-mobile-creation-de-certificats-p12-et-de-provisioning-files/#comments</comments>
		<pubDate>Wed, 13 Jul 2011 15:46:15 +0000</pubDate>
		<dc:creator>Nicolas Gans</dc:creator>
				<category><![CDATA[Flash mobile]]></category>
		<category><![CDATA[Tutoriels Flash]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[iPad]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://www.flashxpress.net/?p=6470</guid>
		<description><![CDATA[Depuis la sortie de Flash CS5.5 et de Flash Builder 4.5, AIR 2.6 et AIR 2.7 vous permettent de développer des applications iOS en AS3 et de les déployer sur iPhone, iPad et iPod Touch. Il n'est dès lors plus nécessaire d'apprendre l'Objective C et de posséder un Mac pour créer des applications. Toutefois, la création de votre premier fichier *.ipa (le format des applications iOS) vous demandera de passer par des étapes préliminaires longues et complexes...]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/07/illus_tuto.png"><img class="alignnone size-full wp-image-6514" title="illus_tuto" src="http://www.flashxpress.net/wp-content/uploads/2011/07/illus_tuto.png" alt="" width="620" height="415" /></a></p>
<p>Depuis la sortie de Flash CS5.5 et de Flash Builder 4.5, <strong>AIR 2.6 et AIR 2.7 </strong>vous permettent de développer des <strong>applications iOS en AS3 et de les déployer sur iPhone, iPad et iPod Touch</strong>. Il n&#8217;est dès lors plus nécessaire d&#8217;apprendre l&#8217;Objective C et de posséder un Mac pour créer des applications. Toutefois, la création de votre premier fichier *.ipa (le format des applications iOS) vous demandera de passer par des étapes préliminaires longues et complexes&#8230;</p>
<p>En effet, pour compiler et tester une application iOS sur votre iDevice, il faudra <strong>obligatoirement </strong>la signer avec :</p>
<ul>
<li>Un <strong>certificat </strong>Apple iOS au format .p12</li>
<li>Un fichier de <strong>provisioning</strong></li>
</ul>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/07/image1.png"><img class="alignnone size-full wp-image-6504" title="image1" src="http://www.flashxpress.net/wp-content/uploads/2011/07/image1.png" alt="" width="613" height="388" /></a></p>
<p><strong> </strong>Et vous allez le voir, la création de ces deux précieux fichiers ne se fera qu&#8217;au prix d&#8217;un périple épique.</p>
<p><strong>Alors, accrochez-vous, restez braves et suivez-moi pour cette longue route !</strong></p>
<h1>Etapes Apple Developer</h1>
<h2>1)   S’inscrire au programme développeur</h2>
<p><a href="http://developer.apple.com/programs/register/">http://developer.apple.com/programs/register/</a></p>
<p>Suivre les étapes pour créer une Apple ID pour un « <strong>individual </strong>» ou une « <strong>company </strong>», ou utiliser une Apple ID existante (ajouter le « iOS developer program » si vous développez déjà pour Mac OS X). A l’étape « Select a program », choisir « iOS developer program ».</p>
<p><strong>Note</strong> : si vous choisissez « <strong>company </strong>» plutôt que « individual », vous serez désigné en tant que « Team Agent » et pourrez inviter d’autres membres de votre équipe et choisir des admins d’équipe. Voir Apple <a href="http://adcdownload.apple.com/ios/ios_developer_program_user_guide/ios_developer_program_user_guide__standard_program_v2.7__final_9110.pdf">iOS Developer’s guide</a> pour plus de détails.<br />
Si vous vous vous enregistrez en tant que « <strong>individual </strong>», votre nom apparaîtra en tant que vendeur de vos apps soumises à l’App Store. Si vous vous enregistrez en tant que « Company », c’est le nom de votre entreprise qui apparaîtra.</p>
<h2>2)   Payer (99$ / an)</h2>
<h2>3)   Attendre l’email d’activation</h2>
<p>Compter entre 24 et 48 heures, des fois moins pour le profil « individual ».</p>
<h2>4)   Choisir le type de contrat à l’aide du lien iTunes Connect de l’email d’activation</h2>
<p><strong>Free Application Contract</strong> – Vous serez immédiatement éligible pour développer des applications gratuites pour l&#8217;app-store. Ce contrat est géré via iTunes Connect, dont vous recevrez un email avec un lien, et à partir duquel vous pourrez vous loguer en utilisant votre Apple Developer ID obtenue lors du processus d’inscription.</p>
<p><strong>Paid Applications Contract</strong> – Vous devrez compléter un contrat séparé via iTunes Connect pour les applications que vous souhaitez vendre. Il faudra fournir vos coordonnées bancaires (pour les paiements) et des informations fiscales. Le contrat sera validé par Apple, cela peut prendre quelques jours. <strong>Note</strong> : vous pouvez compléter cette étape plus tard si vous souhaitez juste faire des tests.</p>
<h1>Etapes Application</h1>
<p>Vous êtes en phase de développement, de test et de debug de votre appli. Il vous faudra mettre en place certificats, profiles et devices pour pouvoir tester votre application en mode debug. Cette étape est sans doute la plus complexe du processus…</p>
<p><strong>Note </strong>: les fichiers .p12 et provisioning ne sont pas les mêmes pour le debug et pour la release finale ! Il faudra refaire certaines étapes lorsque vous souhaiterez packager votre app pour la distribuer sur l&#8217;app-store. <strong>Voir la 3e partie Etape Distribution.</strong></p>
<h2>1)   L’iOS Provisioning Portal</h2>
<p>Une fois les étapes précédentes achevées, loguez vous au <a href="http://developer.apple.com/membercenter/index.action" target="_blank">Apple Developper Center</a> avec votre developer ID, puis cliquez sur <a href="https://developer.apple.com/ios/manage/overview/index.action" target="_blank">iOS Provisioning Portal</a>.</p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/07/image2.png"><img class="alignnone size-full wp-image-6477" title="image2" src="http://www.flashxpress.net/wp-content/uploads/2011/07/image2.png" alt="" width="622" height="382" /></a></p>
<p><strong>TIP :</strong> n’hésitez pas à consulter l’onglet « How To » pour des infos détaillées sur les étapes de configuration et de création.</p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/07/image3.png"><img class="alignnone size-full wp-image-6478" title="image3" src="http://www.flashxpress.net/wp-content/uploads/2011/07/image3.png" alt="" width="598" height="339" /></a></p>
<h2>2)   Résumé des étapes :</h2>
<ul>
<li>Requête, autorisation et téléchargement des <strong>Certificats.</strong></li>
<li>Définition des <strong>Devices</strong> de votre équipe de développement.</li>
<li>Création d’<strong>App IDs </strong>uniques pour chacune de vos applications ou création d’une <strong>Wildcard App ID (*)</strong> pour un ensemble d’applications.</li>
<li>Création et téléchargement d’un <strong>Provisioning Profile</strong>.</li>
</ul>
<h2>3)   Création d’un « developer certificate » (.cer) et d’un fichier P12</h2>
<p>Liens utiles :<br />
<a href="http://help.adobe.com/en_US/as3/iphone/WS144092a96ffef7cc-371badff126abc17b1f-8000.html">http://help.adobe.com/en_US/as3/iphone/WS144092a96ffef7cc-371badff126abc17b1f-8000.html</a><br />
<a href="http://help.adobe.com/en_US/as3/iphone/WS144092a96ffef7cc-371badff126abc17b1f-7fff.html">http://help.adobe.com/en_US/as3/iphone/WS144092a96ffef7cc-371badff126abc17b1f-7fff.html</a></p>
<p>Le developer certificate (.cer) est le fichier qui vous identifie en tant que développeur auprès d&#8217;Apple. Il est nécessaire pour générer le fichier .p12 qui va vous permettre de signer vos applications pour les installer sur votre iDevice.</p>
<p><span style="text-decoration: underline;"><strong>Notez bien que ces 2 fichiers (.cer et .p12) n&#8217;ont besoin d&#8217;être générés qu&#8217;une seule fois </strong></span>: vous utiliserez le même .p12 pour signer toutes vos applications. Il ne sera pas nécessaire de refaire ces étapes plus d&#8217;une fois.</p>
<h3>Mac OS X :</h3>
<h4><span style="text-decoration: underline;">Création d’un fichier *.cer :</span></h4>
<p>1. Lancer l’application <strong>Trousseau d’accès</strong> (« Keychain Access ») qui se trouve dans « <strong>Applications &gt; Utilitaires &gt; Trousseau d’accès</strong> ». Dans le menu du haut, choisir « <strong>Trousseau d’accès &gt; Assistant de Certification &gt; Demander un certificat à une autorité de certificat</strong> ». Entrer l’email que vous avez utilisé lors de l’enregistrement en tant que développeur et laisser le champ « Adresse électronique de l’AC » vide. Sélectionner « Enregistrée sur le disque » et cocher « Me laisser indiquer les informations sur la bi-clé ».</p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/07/image41.png"><img class="alignnone size-full wp-image-6506" title="image4" src="http://www.flashxpress.net/wp-content/uploads/2011/07/image41.png" alt="" width="616" height="436" /></a></p>
<p>2. Il vous sera ensuite demandé d’enregistrer le fichier sur votre disque dur. Le fichier créé est un <strong>« certificate signing request » (CSR)</strong>. Notez bien l’endroit où vous sauvegardez le fichier. Puis sur le panneau « <strong>Information de bi-clé</strong> », laisser les options « 2048 bits » et « RSA » par défaut et cliquer sur « <strong>Continuer </strong>».</p>
<p>3. Puis retournez sur la page « <a href="https://developer.apple.com/ios/manage/overview/index.action" target="_blank">iOS Provisioning Portal</a> » du Apple Developper Center et cliquer sur « <strong>Certificates </strong>» dans la colonne de gauche.</p>
<p>4. Sur le premier onglet (« Development ») cliquer sur le bouton « <strong>Request Certificates</strong> ».</p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/07/image5.png"><img class="alignnone size-full wp-image-6480" title="image5" src="http://www.flashxpress.net/wp-content/uploads/2011/07/image5.png" alt="" width="613" height="334" /></a></p>
<p>5. En bas de l’écran, cliquer sur « <strong>Choose File</strong> » et sélectionner le « <strong>certificate signing request</strong> » (CSR) créé précédemment avec le Trousseau. Le certificat doit apparaître dans la liste avec la mention « <em>Pending Approval</em> ». Cliquer sur le certificat et approuver votre certificat en cliquant sur le bouton « <strong>Approve </strong>».</p>
<p>6. Puis vous devez télécharger le certificat fraîchement approuvé (<strong>developer_identity.cer</strong>) ainsi que le « <strong>WWDR intermediate certificate</strong> » (ne vous souciez pas de ce que c’est, téléchargez-le avec le lien fourni à côté de la « * » note située sous la liste des certificats).</p>
<p>7. Une fois les deux fichiers téléchargés, double-cliquer sur chacun d’eux sur Mac. Le trousseau s’ouvrira automatiquement, choisissez « <strong>Ajouter à votre trousseau</strong> ».</p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/07/image6.png"><img class="alignnone size-full wp-image-6507" title="image6" src="http://www.flashxpress.net/wp-content/uploads/2011/07/image6.png" alt="" width="713" height="386" /></a></p>
<h4><span style="text-decoration: underline;">Création du fichier .p12 :</span></h4>
<p>1. Lancer l’application « <strong>Trousseau d’accès</strong> ».</p>
<p>2. Si vous n’avez pas ajouté le certificat (.cer) au trousseau (étape 7 de la création du .cer), sélectionner <strong>« Fichier &gt; Importer des éléments », </strong>puis naviguer jusqu’au .cer obtenu d’Apple.</p>
<p>3. Dans le bloc « Catégorie » situé à gauche, sélectionner « Clés ». Puis <strong>sélectionner la clé privée</strong> associée avec votre certificat de développeur.</p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/07/image7.png"><img class="alignnone size-full wp-image-6508" title="image7" src="http://www.flashxpress.net/wp-content/uploads/2011/07/image7.png" alt="" width="713" height="386" /></a></p>
<p>4. Sélectionner « <strong>Fichier &gt; Exporter des éléments</strong> » pour sauvegarder votre fichier .p12.</p>
<p>5. Il vous sera demandé de créer un mot de passe. <strong>C’est ce mot de passe qui vous sera demandé par Flash Builder ou Flash pour signer votre application avec votre .p12. </strong></p>
<p><strong>Autrement dit, ne l&#8217;oubliez pas !!</strong></p>
<p>Vous voilà enfin en possession de votre fichier .p12, vous pouvez maintenant passer à l&#8217;étape 4 : <strong>« Enregistrer un device ».<br />
</strong></p>
<p>&nbsp;</p>
<h3>Windows :</h3>
<p>Vous êtes sous Windows ? Pas de chance&#8230; tout sera un peu plus compliqué que sous Mac OS. Mais soyez persévérant !</p>
<p>Sous Windows, on ne peut pas utiliser l’appli Trousseau d’accès. Il faudra donc générer le certificat par d’autres moyens : <strong>en ligne de commande</strong>.</p>
<h4><span style="text-decoration: underline;">Création d’un fichier *.cer :</span></h4>
<p>1. Pour créer le fichier *.cer, nous avons besoin d’<strong>OpenSSL</strong>, téléchargeable ici : <a href="http://www.slproweb.com/products/Win32OpenSSL.html">http://www.slproweb.com/products/Win32OpenSSL.html</a> . Choisir la version <a href="http://www.slproweb.com/download/Win32OpenSSL_Light-1_0_0d.exe">Win32 OpenSSL v1.0.0d Light</a>.</p>
<p>Par défaut, OpenSSL s’installe à la racine du disque C : « C:\OpenSSL-Win32 ».</p>
<p>2. Ouvrir une session de commande Windows en allant dans <strong>Démarrer &gt; Accessoires &gt; Invite de commandes</strong> ou plus simplement en tapant « cmd » puis entrée dans le champ « Exécuter » (XP) ou dans le champ recherche (VISTA/7). Taper « cd » et le chemin du dossier bin de l’application OpenSSL, par exemple :</p>
<pre>cd C:\OpenSSL-Win32\bin</pre>
<p><strong>Astuce </strong>: sur <strong>XP</strong>, vous pouvez collez du texte dans la console de commande en faisant un clic-droit dans la barre supérieure de la fenêtre puis en choisissant « <strong>modifier &gt; coller</strong> » dans le menu déroulant.<br />
Sous <strong>Vista/7</strong>, un simple « <strong>clic-droit &gt; coller</strong> » vous permet de coller du texte.</p>
<p>3. Puis taper</p>
<pre>set RANDFILE=.rnd</pre>
<p>4. Nous allons créer une clé privée, nous en aurons besoin plus tard. Entrez le texte suivant sur la ligne de commande :</p>
<pre>openssl genrsa -out mykey.key 2048</pre>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/07/image8.png"><img class="alignnone size-full wp-image-6483" title="image8" src="http://www.flashxpress.net/wp-content/uploads/2011/07/image8.png" alt="" width="609" height="308" /></a></p>
<p>En principe, un fichier <strong>mykey.key</strong> a été crée dans le dossier bin d’OpenSSL.</p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/07/image9.png"><img class="alignnone size-full wp-image-6484" title="image9" src="http://www.flashxpress.net/wp-content/uploads/2011/07/image9.png" alt="" width="380" height="464" /></a></p>
<p>5. Créez le fichier <strong>.certSigningRequest (CSR)</strong> en entrant :</p>
<pre>openssl req -new -key mykey.key -out CertificateSigningRequest.certSigningRequest -subj "/emailAddress=&#101;&#109;ail&#64;&#101;&#120;&#97;mple&#46;&#99;&#111;&#109;, CN=Regart.net, C=FR"</pre>
<p>N’oubliez pas de remplacer l’<strong>emailAddress</strong>, la <strong>valeur CN</strong> (Company Name : nom de votre entreprise) et la <strong>valeur C</strong> (Country : pays) par vos coordonnées.</p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/07/image10.png"><img class="alignnone size-full wp-image-6510" title="image10" src="http://www.flashxpress.net/wp-content/uploads/2011/07/image10.png" alt="" width="609" height="308" /></a></p>
<p>Un fichier « <strong>CertificateSigningRequest.certSigningRequest</strong> » a été crée dans le dossier bin.</p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/07/image11.png"><img class="alignnone size-full wp-image-6486" title="image11" src="http://www.flashxpress.net/wp-content/uploads/2011/07/image11.png" alt="" width="391" height="477" /></a></p>
<p>6. Puis retournez sur la page « <a href="https://developer.apple.com/ios/manage/overview/index.action" target="_blank">iOS Provisioning Portal</a> » du Apple Developper Center et cliquer sur « <strong>Certificates </strong>» dans la colonne de gauche.</p>
<p>7. Sur le premier onglet (« <strong>Development </strong>») cliquer sur le bouton « <strong>Request Certificates</strong> ».</p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/07/image5.png"><img class="alignnone size-full wp-image-6480" title="image5" src="http://www.flashxpress.net/wp-content/uploads/2011/07/image5.png" alt="" width="613" height="334" /></a></p>
<p>8. En bas de l’écran, cliquer sur « <strong>Choose File </strong>» et sélectionner le « <strong>certificate signing request</strong> » (CSR) créé précédemment avec la ligne de commande. Le certificat doit apparaître dans la liste avec la mention « <em>Pending Approval</em> ». Cliquer sur le certificat et approuver votre certificat en cliquant sur le bouton « <strong>Approve </strong>».</p>
<p>9. Puis vous devez télécharger le certificat fraîchement approuvé : <strong>developer_identity.cer</strong>.</p>
<p>Il va nous permettre de créer le fameux fichier .p12 !</p>
<h4><span style="text-decoration: underline;">Création du fichier P12 :</span></h4>
<p>1. Copier <strong>le fichier .cer</strong> obtenu précédemment dans le dossier bin de l’application OpenSSL.</p>
<p>2. Dans l’invite de commande tapez :</p>
<pre>openssl x509 -in developer_identity.cer -inform DER -out developer_identity.pem -outform PEM</pre>
<p><strong>Un fichier *.pem</strong> a été créé dans le dossier bin :</p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/07/image12.png"><img class="alignnone size-full wp-image-6487" title="image12" src="http://www.flashxpress.net/wp-content/uploads/2011/07/image12.png" alt="" width="395" height="521" /></a></p>
<p>3. Pour <strong>créer le fichier *.p12</strong><strong>, taper</strong> :</p>
<pre>openssl pkcs12 -export -inkey mykey.key -in developer_identity.pem -out iphone_dev.p12</pre>
<p>Vous aurez un message vous demandant un mot de passe, <strong>c’est le <strong>mot de passe du certificat .p12</strong> utilisé dans Flash et Flash Builder. </strong></p>
<p><strong>Note : </strong>Les caractères du mot de passe que vous tapez n&#8217;apparaissent pas ? <strong>Pas de panique</strong>, c&#8217;est tout à fait normal.<strong><br />
</strong></p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/07/image13.png"><img class="alignnone size-full wp-image-6526" title="image13" src="http://www.flashxpress.net/wp-content/uploads/2011/07/image13.png" alt="" width="677" height="450" /></a></p>
<p>Vous pouvez être fier de vous : <strong>voyez ce beau fichier iphone_dev.p12</strong> présent dans le dossier bin ! Si vous lisez ces lignes, c&#8217;est que vous avez surmonté le plus difficile. Passons maintenant à l&#8217;enregistrement de vos iDevices.</p>
<h2>4)   Enregistrer un device</h2>
<p>Il faut ajouter au Provisioning Portal le <strong>« Unique Device ID » (UDID)</strong> de tout device sur lequel vous souhaitez tester vos applications, avec un maximum de 100 devices par an. Pour connaître l’UDID de votre device, vous pouvez utiliser <strong>iTunes</strong>. Connectez votre device et lancez iTunes. Sur l’onglet « <strong>résumé </strong>», <strong>cliquez sur le serial du device</strong> pour faire apparaître son identifiant de 40 caractères. <strong>Ne pas utiliser le numéro de série, cela ne fonctionnera pas !</strong></p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/07/image14.png"><img class="alignnone size-full wp-image-6489" title="image14" src="http://www.flashxpress.net/wp-content/uploads/2011/07/image14.png" alt="" width="618" height="260" /></a></p>
<p><strong>Note :</strong> chaque nouveau device ajouté requiert le téléchargement d’un nouveau « provisioning profile » dans lequel le device et l’ID de l’application (« app ID ») sont associés. <strong>Autrement dit, à chaque fois que vous ajoutez un device au provisioning portal, il faudra éventuellement regénérez le provisioning profile correspondant.</strong></p>
<h2>5)   Créer une App ID unique</h2>
<p>Une App ID est faite de 10 caractères générés par un <strong>Bundle seed ID d’Apple</strong> et par un <strong>Bundle Identifier</strong> spécifié par le développeur. Elle sera nécessaire pour installer une app sur votre device et utiliser certains services d’Apple (In App purchase, Game Center, iCloud…).</p>
<p><strong>Note : </strong>En principe, chaque application doit avoir sa propre App ID : il vous faudra donc créer une App ID par application, en utilisant l&#8217;identifiant unique de l&#8217;application spécifié dans le fichier Descriptor de votre application AIR. Toutefois, pour des application de test, il ne sera pas nécessaire de générer une App ID par application, vous pourrez utiliser une « <strong>Wild Card App ID</strong> » (voir note plus bas).</p>
<p>Pour créer une App ID, sélectionner la rubrique App ID’s à gauche et cliquer sur le bouton « <strong>New App ID</strong> ».</p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/07/image15.png"><img class="alignnone size-full wp-image-6490" title="image15" src="http://www.flashxpress.net/wp-content/uploads/2011/07/image15.png" alt="" width="687" height="148" /></a></p>
<p>A l&#8217;écran suivant, vous allez créer votre App ID.</p>
<p><strong>Le Bundle seed ID</strong> est généré par Apple et se compose de lettres et de chiffres. Par exemple : A12BC3D45E.<br />
<strong>Le Bundle Identifier</strong> utilise en général un nom de domaine inversé pour garantir son unicité.</p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/07/image16.png"><img class="alignnone size-full wp-image-6491" title="image16" src="http://www.flashxpress.net/wp-content/uploads/2011/07/image16.png" alt="" width="641" height="378" /></a></p>
<p>Au final, une App ID ressemble à cela : « <strong>A12BC3D45E.net.regart.monAppli</strong> ».</p>
<p><strong>Note</strong> : Si vous souhaitez faire des applis de test, je vous conseille d&#8217;utiliser une <strong>Wild Card App ID</strong>, par exemple : « <strong>A12BC3D45E.*</strong> » que vous pourrez associer à autant d&#8217;applis que vous le souhaiter, quelque soit leur Bundle Identifier (fr.kouma.app, net.regart.test, bob.groove.sonic&#8230;). <span style="text-decoration: underline;"><strong>Cela vous permettra de tester et d’installer plusieurs applications sans avoir à générer une App ID pour chaque appli.</strong></span></p>
<h2>6)   Créer et télécharger un provisioning profile</h2>
<p>Un « <strong>provisioning profile</strong> » est le second fichier nécessaire pour tester votre application sur un device iOS. En gros, il s’agit d’une entité légale qui vous relie à un certificat, une device ID et une application. <strong>C’est ce fichier, en plus du .p12, qui vous sera demandé par Flash Builder ou Flash pour signer votre application.</strong></p>
<p><strong>TIP</strong> : si vous avez une erreur dans iTunes en essayant d’installer une app disant que le « <strong>Signer is not Valid</strong> », c’est probablement parce que vous n’avez pas généré à nouveau votre provisioning profile après avoir ajouté l’UDID de votre device.</p>
<p><strong>Note</strong> : un device peut contenir plusieurs provisioning profiles liés à différents certificats, devices et app IDs. Il faut aussi se rendre compte que vous aller générer des tas de provisioning profiles, alors habituez-vous à cette étape ! Par ailleurs, chaque <strong>provisioning profile de développement</strong> expire après 90 jours, il faudra les renouveler (et oui !). Les <strong>profiles de distribution</strong> expirent plus tard (1 an).</p>
<h1>Etapes Distribution</h1>
<p><strong><em>Votre appli est prête, et vous souhaitez la distribuer&#8230; Il faudra regénérer un .p12 et provisioning file spécifique (non, ce n&#8217;est pas une blague !!).</em></strong></p>
<p>Vous utiliserez les mêmes sections « <strong>Certificates </strong>», « <strong>Devices </strong>» et « <strong>Provisioning </strong>» que précédemment, sauf que vous sélectionnerez l’onglet « <strong>Distribution </strong>» au lieu de l’onglet « Developement ».</p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/07/image17.png"><img class="alignnone size-full wp-image-6492" title="image17" src="http://www.flashxpress.net/wp-content/uploads/2011/07/image17.png" alt="" width="685" height="216" /></a></p>
<h3>Résumé des étapes :</h3>
<ul>
<li>Création et téléchargement d’un « <strong>iOS Distribution Certificate</strong> ».</li>
<li>Ajout d’un <strong>Device ID</strong></li>
<li>Création et téléchargement d’un « <strong>Distribution Provisioning Profile</strong> »</li>
<li>Soumission de votre application pour la distribution</li>
</ul>
<p>La plupart de ces étapes sont identiques à celle de la phase de développement. La chose la plus importante est le mode de distribution : <strong>Ad Hoc</strong> et <strong>App Store</strong>.</p>
<p><strong>Ad Hoc </strong>signifie que vous allez distribuer votre application à un nombre limité de personnes pour qu’il la teste sur leur device (limité à 100 devices).</p>
<p><strong>App Store</strong> est la phase finale lorsque votre application est prête pour l’App Store.</p>
<p>Chaque phase requiert un <strong>provisioning profile spécifique</strong>. L’application doit être recompilée avec ce nouveau provisioning profile après la création de celui-ci.</p>
<p><strong>NOTE</strong> : vous verrez une note disant « Only Team Agents are authorized to prepare and submit applications for distribution. » Ne vous inquiétez pas, puisque vous êtes votre propre Team Agent.</p>
<h2>1)   Création d’un « Distribution Certificate »</h2>
<p>Mêmes étapes que précédemment, sauf que vous pouvez utiliser le nom de votre entreprise au lieu de votre nom si vous le souhaitez. C’est ce nom qui sera utilisé pour signer votre application pour les autres personnes. Ce certificat est valide un an pour la distribution.</p>
<h2>2)   Enregistrement d’un Device</h2>
<p>Enregistrez les devices ID’s des utilisateurs qui seront vos testeurs. Vous devez faire cette étape <strong>avant de générer votre provisioning profile, </strong>pour garantir que les device ID’s seront incluses dans dans le provisioning profile fourni à Flash Builder ou Flash lors de la compilation.</p>
<p><strong>NOTE</strong> : à chaque fois que vous ajouterez un device ID, il faudra vous assurer de re-générer le provisioning profile de l’application et de le télécharger à nouveau.</p>
<h2>3)   Création d’un provisioning profile de distribution</h2>
<p>Vous choisirez <strong>Ad Hoc</strong> (pour distribuer à des testeurs) ou <strong>App Store</strong> (pour la release finale) en fonction de l’avancée de votre développement.</p>
<h2>4)   Compilation en mode release dans Flash Builder</h2>
<p>Recompiler votre application en mode release avec votre nouveau distribution provisioning profile et votre distribution certificate.</p>
<p>Vous pourrez choisir le « package type » : <strong>Ad Hoc ou Final Release</strong>.</p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/07/image18.png"><img class="alignnone size-full wp-image-6513" title="image18" src="http://www.flashxpress.net/wp-content/uploads/2011/07/image18.png" alt="" width="667" height="521" /></a></p>
<h2>5)   Distribution du fichier .ipa</h2>
<p><strong>Distribution Ad Hoc</strong> – vous pouvez envoyer votre .ipa à vos testeurs via un email ou un site web.</p>
<p><strong>Distribution App Store </strong>– Il faudra vous rendre sur le site iTunes Connect pour soumettre votre application. Il faudra remplir des formulaires et donner les informations les plus spécifiques possibles pour éviter le rejet de votre application. Il faudra également uploader votre application en la renommant en .zip et uploader une image de 512*512 pixels séparément en tant qu’icône de grande taille pour le store dans iTunes.</p>
<h1>Conclusion</h1>
<p>Que dire en conclusion ? Que oui, générer ces fichiers est pénible et prend du temps, et que non, vous n&#8217;avez pas le choix. Donc, prenez le temps de vous familiariser avec ces étapes et ces fichiers. Une fois tout cela fait, vous verrez que générer une App ID ou ajouter un nouveau device se fait en quelques clics indolores. C&#8217;est juste la mise en place qui est lourde, après tout roule.</p>
<p><em>En note finale, je remercie <strong>devgirl </strong>qui a sorti un tuto en anglais au moment même où j&#8217;ai commencé à écrire ce tuto. Son article étant extrêmement détaillé et complet (mais uniquement pour Mac OS), des pans entiers de cet article sont directement adaptés de son tuto. Un énorme merci à elle :</em></p>
<p><a href="http://devgirl.org/2011/06/20/flexair-for-ios-development-process-explained/" target="_blank">http://devgirl.org/2011/06/20/flexair-for-ios-development-process-explained/</a></p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashxpress.net/ressources-flash/applications-ios-avec-air-mobile-creation-de-certificats-p12-et-de-provisioning-files/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Nouvelles fonctionnalités de Flash CS5.5</title>
		<link>http://www.flashxpress.net/ressources-flash/nouvelles-fonctionnalitees-de-flash-cs5-5/</link>
		<comments>http://www.flashxpress.net/ressources-flash/nouvelles-fonctionnalitees-de-flash-cs5-5/#comments</comments>
		<pubDate>Thu, 14 Apr 2011 12:10:12 +0000</pubDate>
		<dc:creator>Olivier</dc:creator>
				<category><![CDATA[Flash général]]></category>
		<category><![CDATA[Tutoriels Flash]]></category>
		<category><![CDATA[CS5.5]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://www.flashxpress.net/?p=6325</guid>
		<description><![CDATA[Hello Flash world ! Après avoir listé quelques features de la CS5.5, nous allons dans cet article vous en dire davantage sur Flash CS 5.5. Pas besoin de le cacher, la plupart est en rapport avec le développement multi-écrans. Voici quelques-unes des nouveautés donc de Flash CS 5.5 : Aide à la gestion des calques [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/04/headerFlashCS55.png"><img class="alignnone size-full wp-image-6353" title="headerFlashCS55" src="http://www.flashxpress.net/wp-content/uploads/2011/04/headerFlashCS55.png" alt="" width="630" /></a></p>
<p>Hello Flash world !</p>
<p>Après avoir listé quelques features de la CS5.5, nous allons dans cet article vous en dire davantage sur Flash CS 5.5. Pas besoin de le cacher, la plupart est en rapport avec le développement multi-écrans.</p>
<p>Voici quelques-unes des nouveautés donc de Flash CS 5.5 :</p>
<p><strong>Aide à la gestion des calques simplifiée <span style="font-size: 9px;">(ENFIN :p)</span>.</strong></p>
<p>Flash CS5.5 nous permet de faire directement des couper / copier / coller / dupliquer de calque dans un même document voir même d&#8217;un document à un autre !</p>
<p>Le menu contextuel a été quelque peu modifié.</p>
<p>Voici ce que nous obtenons maintenant lors du clic droit sur un calque dans Flash CS5.5 :</p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/04/cliqueDroitCalqueCS552.png"><img class="alignnone size-full wp-image-6329" title="cliqueDroitCalqueCS552" src="http://www.flashxpress.net/wp-content/uploads/2011/04/cliqueDroitCalqueCS552.png" alt="" width="314" height="502" /></a></p>
<p>J&#8217;ai d&#8217;ailleurs effectué quelques tests et n&#8217;ai rencontré aucun problème.</p>
<p>Ces fonctionnalités simples et efficaces nous feront gagner un temps fou. Je me rappelle de ces longues animations image par image créées en oubliant de les imbriquer dans un clip. C&#8217;était quand même un peu galère de réorganiser l&#8217;imbrication du document. Et bien cette époque est révolue ! <img src='http://www.flashxpress.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>&nbsp;</p>
<p><strong>Une palanquée de nouveaux snippets de code</strong></p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/04/snippetCodecs55.png"><img class="alignnone size-full wp-image-6332" title="snippetCodecs55" src="http://www.flashxpress.net/wp-content/uploads/2011/04/snippetCodecs55.png" alt="" width="332" height="380" /></a></p>
<p>De supers nouveaux snippets, notamment pour les périphériques tactiles, AIR et AIR mobiles,  des actions simples mais très utiles que l&#8217;on retrouve dans la plupart des applications. On trouve des snippets pour par exemple :</p>
<p>- La fermeture de l&#8217;application</p>
<p>- La réduction de l&#8217;application</p>
<p>- La restauration de l&#8217;application</p>
<p>- Le chargement de fichier</p>
<p>- L&#8217;enregistrement de fichier</p>
<p>- La gestion de la géolocalisation</p>
<p>- La gestion d&#8217;évènements tactiles</p>
<p>- La gestion de l&#8217;accéléromètre</p>
<p>Bref, au total plus de 70 snippets plus efficaces les uns que les autres.</p>
<p>&nbsp;</p>
<p><strong>La transformation d&#8217;un symbole en bitmap</strong></p>
<p>Et on continu avec les killer features !</p>
<p>Flash CS5.5 nous donne la possibilité d&#8217;exporter un symbole tel qu&#8217;un Clip en bitmap, et cela en vue d&#8217;une optimisation mobile of course !</p>
<p>Nous avons le choix entre deux formats, le JPEG ou le PNG / GIF</p>
<p>Concrètement, comment ça se passe ?</p>
<p>Plusieurs possibilités :</p>
<p>- Soit un symbole contenant uniquement des formes vectorielles ou d&#8217;autres symboles, mais aucune animation n&#8217;est présente. Si l&#8217;on fait clic droit sur le symbole puis convertir en Bitmap, un bitmap sera créé dans la bibliothèque et le symbole sur la scène remplacé par ce nouveau bitmap.</p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/04/convertionSymboleBitmap.png"><img class="alignnone size-thumbnail wp-image-6336" title="convertionSymboleBitmap" src="http://www.flashxpress.net/wp-content/uploads/2011/04/convertionSymboleBitmap-e1302599149412-310x84.png" alt="" width="310" height="84" /></a></p>
<p>- Soit un symbole. Vous souhaitez le transformer en bitmap mais uniquement lors de la compilation de l&#8217;application.  Dans le panneau des Propriétés, un nouveau menu est maintenant disponible : &laquo;&nbsp;Exporter en temps que bitmap&nbsp;&raquo;. Dans ce cas, lors de l&#8217;export, le symbole sera directement exporté en bitmap ! Très bon.</p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/04/optionExportClip.png"><img class="alignnone size-full wp-image-6337" title="optionExportClip" src="http://www.flashxpress.net/wp-content/uploads/2011/04/optionExportClip.png" alt="" width="279" height="72" /></a></p>
<p>Le gros avantage de cette seconde technique est que votre objet est toujours un objet vectoriel et qu&#8217;il conserve tous les avantages de ce format puisque ce n&#8217;est qu&#8217;à l&#8217;export qu&#8217;il est &laquo;&nbsp;bitmapisé&nbsp;&raquo;.</p>
<p>&nbsp;</p>
<p><strong>Mise à l&#8217;échelle du contenu d&#8217;un document lors du redimensionnement de la scène</strong></p>
<p>Peut-être avez-vous déjà dû produire une application en plusieurs formats. Par exemple une version pour iPhone, une pour iPad, une pour un device  Android&#8230;Les résolutions d&#8217;écran sont différentes, et vous devrez  si vous n&#8217;utilisez pas de layout manager, dupliquer le projet et passer  un temps incalculable à redimensionner vos symboles, recaler vos  animations, etc.</p>
<p>Dans cette nouvelle  mouture de Flash CS5.5 cette longue et éprouvante expérience se réduit à  quelques secondes (notez qu&#8217;il faudra quand même retoucher deux, ou trois  choses derrière, mais globalement c&#8217;est plutôt pas mal) !</p>
<p>Voici la procédure :</p>
<p>1) Votre application est terminée. Vous vous apprêtez à faire les différentes versions</p>
<p>2) Vous dupliquez votre projet</p>
<p>3) Ouvrez une copie de ce projet et rendez-vous dans la boîte de dialogue &laquo;&nbsp;Paramètres du document&nbsp;&raquo;</p>
<p>4) Redimensionnez votre scène à votre convenance</p>
<p>5) Cochez la case &laquo;&nbsp;Mettre à l&#8217;échelle le contenu avec la scène&nbsp;&raquo;</p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/04/redimentionAppCS55.png"><img title="redimentionAppCS55" src="http://www.flashxpress.net/wp-content/uploads/2011/04/redimentionAppCS55-e1302601540281-310x52.png" alt="" width="310" height="52" /></a></p>
<p>6) Confirmez en cliquant sur OK</p>
<p>Flash  va redimensionner et replacer les différents élément de votre  application !</p>
<p>&nbsp;</p>
<p><strong>Boite de dialogue &laquo;&nbsp;Paramètres du publication&nbsp;&raquo; simplifiés</strong></p>
<p>Voici une toute petite feature qui fait quand même du bien !</p>
<p>La boite des paramètres de publication a été épurée et la petite case à cocher pour générer les SWC est bien plus accessible :</p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/04/boiteDialogueParametreDePublicationCS55.png"><img class="alignnone size-medium wp-image-6338" title="boiteDialogueParametreDePublicationCS55" src="http://www.flashxpress.net/wp-content/uploads/2011/04/boiteDialogueParametreDePublicationCS55-549x700.png" alt="" width="549" height="700" /></a></p>
<p>&nbsp;</p>
<p><strong>Sauvegarde automatique de vos précieux documents toute les x minutes</strong></p>
<p>Voila LA case anti-coupure de courant ! LA case qui vous aidera à ne pas frapper sur vos collègues lorsque par &laquo;&nbsp;inadvertance&nbsp;&raquo; ils ont appuyés sur le bouton rouge de la multiprise&#8230;bref, je vous présente la case à cocher de &laquo;&nbsp;Sauvegarde automatique&nbsp;&raquo;. Celle-ci est disponible dans la boite de dialogue &laquo;&nbsp;Paramètres du document&nbsp;&raquo;, juste en dessous de la cadence d&#8217;animation de votre document :</p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/04/paraDocCS55.png"><img class="alignnone size-full wp-image-6340" title="paraDocCS55" src="http://www.flashxpress.net/wp-content/uploads/2011/04/paraDocCS55.png" alt="" width="568" height="255" /></a></p>
<p>&nbsp;</p>
<p>Voila pour les features qui paraissent les plus juteuses !</p>
<p>Pour plus d&#8217;info :</p>
<p>- <a href="http://www.adobe.com/fr/products/flash.html" target="_blank">Présentation de Flash Professional CS5.5</a></p>
<p>- <a href="http://www.adobe.com/fr/products/flash/features.html" target="_blank">Nouvelles fonctionnalités de Flash Professional CS 5.5</a></p>
<p>Amicalement.</p>
<p>Olivier.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashxpress.net/ressources-flash/nouvelles-fonctionnalitees-de-flash-cs5-5/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Dopez votre frameRate avec les classes AnimatedBitmap et AnimatedBitmapData</title>
		<link>http://www.flashxpress.net/ressources-flash/dopez-votre-framerate-avec-les-classes-animatedbitmap-et-animatedbitmapdata/</link>
		<comments>http://www.flashxpress.net/ressources-flash/dopez-votre-framerate-avec-les-classes-animatedbitmap-et-animatedbitmapdata/#comments</comments>
		<pubDate>Wed, 30 Mar 2011 13:02:07 +0000</pubDate>
		<dc:creator>Nicolas Gans</dc:creator>
				<category><![CDATA[Flash ActionScript]]></category>
		<category><![CDATA[Flash mobile]]></category>
		<category><![CDATA[Tutoriels Flash]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Optimisation]]></category>

		<guid isPermaLink="false">http://www.flashxpress.net/?p=6246</guid>
		<description><![CDATA[C'est un fait avéré que l'animation de clips vectoriels peut être coûteuse en CPU et en mémoire. Ce phénomène s'accentue d'autant plus lors de développements sur mobile où le processeur et la mémoire vive sont extrêmement limités par rapport à des machines de bureau.]]></description>
			<content:encoded><![CDATA[<p>C&#8217;est un fait avéré que l&#8217;animation de clips vectoriels peut être coûteuse en CPU et en mémoire. Ce phénomène s&#8217;accentue d&#8217;autant plus lors de développements sur mobile où le processeur et la mémoire vive sont extrêmement limités par rapport à des machines de bureau.</p>
<p>Pour optimiser les animations et augmenter le frame rate de nos .swf, il existe des techniques de mise en cache natives des éléments vectoriels (cacheAsBitmap, cacheAsBitmapMatrix&#8230;) ou &laquo;&nbsp;manuelles&nbsp;&raquo; (méthode draw() de la classe BitmapData) qui sont efficaces. Le principe est toujours le même : il s&#8217;agit de faire un rendu bitmap (une rasterisation) à l&#8217;exécution, autrement dit de générer un png transparent à partir des données vectorielles, plus lourd en mémoire, mais beaucoup plus rapide à animer en terme de CPU.</p>
<p>J&#8217;ai dressé un panorama de ces techniques de mise en cache et des gains associés lors de ma <a title="Mise en cache des assets vectoriels pour AIR mobile" href="http://www.flashxpress.net/ressources-flash/mise-en-cache-des-assets-vectoriels-pour-air-mobile/">mini-conf des lightning talks</a>. Toutefois, lorsque l&#8217;on souhaite mettre en cache des éléments animés de type MovieClip, ces techniques sont totalement inefficaces &#8211; voire contre-performantes.</p>
<p>C&#8217;est pourquoi je vous livre ici deux classes, <strong>AnimatedBitmap </strong>et <strong>AnimatedBitmapData </strong>qui permettent de mettre en cache à l&#8217;exécution les movie clips animés <strong>pour un gain de performance spectaculaire</strong>.</p>
<p>Un petit benchmark pour commencer, décochez &laquo;&nbsp;use Cache&nbsp;&raquo; pour passer à la version vectorielle (beaucoup plus lente).</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_RetD_AnimatedBitmap_bench_1933052139"
			class="flashmovie"
			width="630"
			height="400">
	<param name="movie" value="http://www.flashxpress.net/wp-content/uploads/2011/03/RetD_AnimatedBitmap_bench.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.flashxpress.net/wp-content/uploads/2011/03/RetD_AnimatedBitmap_bench.swf"
			name="fm_RetD_AnimatedBitmap_bench_1933052139"
			width="630"
			height="400">
	<!--<![endif]-->
		<a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>Sur ma machine, je peux créer 2000 chiens animés et le <strong>frame rate reste à 30 ips</strong>. En mode vectoriel (use cache décoché), au-dessus de 100 chiens, le frame rate commence à diminuer.</p>
<h2>Classes AnimatedBitmap et AnimatedBitmapData</h2>
<p>Ces deux classes s&#8217;utilisent à la manière des classes <strong>Bitmap </strong>et <strong>BitmapData </strong>: une classe contient les data (AnimatedBitmapData) et l&#8217;autre gère l&#8217;affichage des data (AnimatedBitmap). De cette manière, on peut ré-utiliser les mêmes data pour x objets animés sans les dupliquer, d&#8217;où un gain de mémoire et de temps de rendu.</p>
<h2>AnimatedBitmapData</h2>
<p>La première chose à faire, avant tout rendu, c&#8217;est d&#8217;initialiser la classe en appelant dessus la méthode statique init() au moins une fois. La classe a en effet besoin d&#8217;une référence au Stage pour fonctionner.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p6246code7'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p62467"><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code" id="p6246code7"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #009900; font-style: italic;">// Initialisation de la classe</span>
AnimatedBitmapData<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">init</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">stage</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #009900; font-style: italic;">// le clip à mettre en cache</span>
<span style="color: #6699cc; font-weight: bold;">var</span> dog<span style="color: #000066; font-weight: bold;">:</span>Dog = <span style="color: #0033ff; font-weight: bold;">new</span> Dog<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #009900; font-style: italic;">// création des data</span>
<span style="color: #6699cc; font-weight: bold;">var</span> abd<span style="color: #000066; font-weight: bold;">:</span>AnimatedBitmapData = <span style="color: #0033ff; font-weight: bold;">new</span> AnimatedBitmapData<span style="color: #000000;">&#40;</span>dog<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></pre></td></tr></table></div>

<p>En interne, la classe va parcourir la time line du clip et faire un draw() sur chaque frame, puis stocker les bitmapData obtenus dans un Vector.</p>
<p>Quelques infos sur le fonctionnement de cette classe :</p>
<ul>
<li> Si le clip a des couleurs modifiées (teinte, alpha&#8230;), mais que vous ne souhaitez pas les conserver, il faudra passer le second param &laquo;&nbsp;preserveColor&nbsp;&raquo; du constructeur à false.</li>
<li>Dans certains cas, notamment avec des filtres flous, <strong>les images du rendu peuvent être coupées sur les bords</strong>.  Cela est dû aux méthodes getBounds() et generateFilterRect() de Flash  qui renvoient parfois des valeurs imprécises. Si cela arrive, vous  pouvez passer en 3e param du constructeur une marge en pixel qui  agrandira la zone de rendu.</li>
<li>Enfin, si votre clip possède des étiquettes (frameLabels) elles seront conservées et accessibles.</li>
<li>Les transformations &laquo;&nbsp;matricielles&nbsp;&raquo; du clips sont supportées (rotation, scale&#8230;), ainsi que les filtres.</li>
</ul>
<p>Lorsque vous souhaitez détruire l&#8217;instance, appelez dessus la méthode destroy(), qui libèrera automatiquement la mémoire occupée via la méthode dispose() de la classe BitmapData.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p6246code8'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p62468"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p6246code8"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #009900; font-style: italic;">// destruction des data et libération de la mémoire</span>
abd<span style="color: #000066; font-weight: bold;">.</span>destroy<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></pre></td></tr></table></div>

<h2>AnimatedBitmap</h2>
<p>C&#8217;est la classe d&#8217;affichage, qui a besoin d&#8217;un AnimatedBitmapData pour fonctionner.</p>
<p>On l&#8217;instancie de la façon suivante.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p6246code9'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p62469"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p6246code9"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #009900; font-style: italic;">// instanciation : on passe en 1er param un AnimatedBitmapData</span>
<span style="color: #6699cc; font-weight: bold;">var</span> ab<span style="color: #000066; font-weight: bold;">:</span>AnimatedBitmap = <span style="color: #0033ff; font-weight: bold;">new</span> AnimatedBitmap<span style="color: #000000;">&#40;</span>abd<span style="color: #000066; font-weight: bold;">,</span> AnimatedBitmap<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">ENTER_FRAME</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">30</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #009900; font-style: italic;">// affichage</span>
<span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>ab<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></pre></td></tr></table></div>

<p>Les params du constructeurs sont les suivants :</p>
<ul>
<li>source:AnimatedBitmapData &gt; une instance d&#8217;AnimatedBitmapData</li>
<li> ticker:String &gt; le type &laquo;&nbsp;d&#8217;horloge&nbsp;&raquo; utilisé pour animer l&#8217;instance. Vous avez le choix entre<strong> &laquo;&nbsp;timer&nbsp;&raquo;, &laquo;&nbsp;enterFrame&nbsp;&raquo; et &laquo;&nbsp;external&nbsp;&raquo;</strong>. Vous pouvez utiliser les constantes statiques de la classe pour renseigner ce param : AnimatedBitmap.TIMER, AnimatedBitmap.ENTER_FRAME ou AnimatedBitmap.EXTERNAL.</li>
<li>frameRate:uint &gt; la cadence d&#8217;animation de votre objet. <strong>Comme elle n&#8217;est pas liée au frameRate de votre swf, elle peut être différente de celui-ci (plus lente ou plus rapide).</strong></li>
<li>updateAfterEvent:Boolean &gt; passez true si vous utilisez un ticker de type &laquo;&nbsp;timer&nbsp;&raquo; et que la cadence de l&#8217;objet est plus rapide que celle du document. Cela forcera le rendu du player à chaque nouvelle image pour plus de fluidité (et plus de process).</li>
<li>pixelSnapping:Boolean &gt; pour que les coordonnées des bitmaps du cache soit ou non sur des pixels entiers.</li>
<li>smoothing:Boolean &gt; activation ou non du lissage, utile lorsque l&#8217;objet subit une rotation ou un scale.</li>
</ul>
<p>Quelques infos sur le type de ticker (2nd param) :</p>
<p><strong>AnimatedBitmap.TIMER (défaut)</strong> : une instance de Timer est utilisée. Pratique si l&#8217;on souhaite aller plus vite que le frame rate de l&#8217;animation, mais moins optimisé qu&#8217;un enterFrame.<br />
<strong>AnimatedBitmap.ENTER_FRAME</strong> : un enterFrame est utilisé. A choisir si votre objet animé doit avoir le même frameRate que votre animation.<br />
<strong>AnimatedBitmap.EXTERNAL</strong> : aucune horloge interne ne sera mise en place, ce sera à vous d&#8217;implémenter votre propre horloge externe et d&#8217;appeler la méthode update() sur vos AnimatedBitmap. C&#8217;est la méthode la plus optimisée (pas de multiplication des horloges), à choisir si vous avez beaucoup d&#8217;objets animés ou si vous faites du jeu.</p>
<p>Exemple pour le type &laquo;&nbsp;external&nbsp;&raquo; :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p6246code10'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p624610"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code" id="p6246code10"><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><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">ENTER_FRAME</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">loop</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">loop</span><span style="color: #000000;">&#40;</span>event<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><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: #6699cc; font-weight: bold;">var</span> lng<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a> = dogs<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">numChildren</span><span style="color: #000066; font-weight: bold;">;</span>
    <span style="color: #6699cc; font-weight: bold;">var</span> dog<span style="color: #000066; font-weight: bold;">:</span>AnimatedBitmap<span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
    <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><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a> = <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;">&amp;</span>lt<span style="color: #000066; font-weight: bold;">;</span> lng<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>
        dog = dogs<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">getChildAt</span><span style="color: #000000;">&#40;</span>i<span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> AnimatedBitmap<span style="color: #000066; font-weight: bold;">;</span>
        dog<span style="color: #000066; font-weight: bold;">.</span>update<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: #000000;">&#125;</span></pre></td></tr></table></div>

<h2>Méthodes et propriétés de la classe AnimatedBitmap</h2>
<p>J&#8217;ai repris l&#8217;API de la classe MovieClip, donc on retrouve toutes les méthodes et propriétés classiques d&#8217;un MC : totalFrames, currentFrame, currentLabel, currentFrameLabel, play(), stop(), gotoAndPlay(frame/label) &#8230;</p>
<p>Des méthodes spécifiques existent cependant :</p>
<ul>
<li><strong>playTo(frame/label)</strong> : la tête de lecture part de sa position actuelle et s&#8217;arrêtera à la frame/étiquette passée en paramètre.</li>
<li><strong>playFromTo(startFrame, endFrame)</strong> : joue la tête de lecture depuis une frame/étiquette de départ jusqu&#8217;à une frame/étiquette d&#8217;arrivée.</li>
<li><strong>replace(target:MovieClip)</strong> : une petite méthode qui permet de remplacer automatiquement un clip affiché par un AnimatedBitmap. Pratique pour faire du remplacement automatique.</li>
</ul>
<p>Des propriétés aussi :</p>
<ul>
<li><strong>frameRate:uint </strong>&gt; pour modifier à la volée le frameRate de votre instance.</li>
<li><strong>isPlaying:Boolean</strong> &gt; pour savoir si le clip est en cours de lecture ou non.</li>
</ul>
<p>Un petit aperçu :</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_RetD_AnimatedBitmap_223238125"
			class="flashmovie"
			width="630"
			height="400">
	<param name="movie" value="http://www.flashxpress.net/wp-content/uploads/2011/03/RetD_AnimatedBitmap.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.flashxpress.net/wp-content/uploads/2011/03/RetD_AnimatedBitmap.swf"
			name="fm_RetD_AnimatedBitmap_223238125"
			width="630"
			height="400">
	<!--<![endif]-->
		<a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>Pour l&#8217;exemple, voici le code du swf ci-dessus :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p6246code11'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p624611"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code" id="p6246code11"><pre class="actionscript3" style="font-family:monospace;">AnimatedBitmapData<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">init</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">stage</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #6699cc; font-weight: bold;">var</span> dog<span style="color: #000066; font-weight: bold;">:</span>Dog = <span style="color: #0033ff; font-weight: bold;">new</span> Dog<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
dog<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">scaleX</span> = dog<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">scaleY</span> = <span style="color: #000000; font-weight:bold;">2.2</span><span style="color: #000066; font-weight: bold;">;</span>
dog<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</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;">0.5</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>
dog<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</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;">0.5</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>dog<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #6699cc; font-weight: bold;">var</span> abd<span style="color: #000066; font-weight: bold;">:</span>AnimatedBitmapData = <span style="color: #0033ff; font-weight: bold;">new</span> AnimatedBitmapData<span style="color: #000000;">&#40;</span>dog<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #6699cc; font-weight: bold;">var</span> ab<span style="color: #000066; font-weight: bold;">:</span> = <span style="color: #0033ff; font-weight: bold;">new</span> AnimatedBitmap<span style="color: #000000;">&#40;</span>abd<span style="color: #000066; font-weight: bold;">,</span> AnimatedBitmap<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">TIMER</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;">frameRate</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
ab<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">replace</span><span style="color: #000000;">&#40;</span>dog<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></pre></td></tr></table></div>

<p><strong>Destruction des instances :</strong></p>
<p>La classe possède une méthode <strong>destroy()</strong>, qui supprime tous les écouteurs et retire l&#8217;instance de la display list.<br />
Par ailleurs, il existe une <strong>propriété statique destroyData:Boolean</strong>,  réglée par défaut sur false. Passée à true, elle met en place une  destruction automatique et générale des AnimatedBitmapData au moment de  la destruction d&#8217;un AnimatedBitmap ou lors de l&#8217;écrasement d&#8217;un  animatedBitmapData par un autre via la propriété du même nom.</p>
<h2>Conclusion</h2>
<p>Ces classes se montreront particulièrement utiles pour du dev AIR mobile. <strong>Lorsqu&#8217;elles sont couplées au mode GPU (renderMode) le frame rate bondit</strong> !<br />
Par contre les limites sont le temps de rendu et la mémoire occupée. Je vous renvoie aux slides de ma mini-conf pour cela. Je pense peut-être implémenter une classe SpriteSheet à coupler avec AnimatedBitmapData pour utiliser des sprite sheets et réduire le temps de rendu.</p>
<p>Faites-moi part de vos remarques, questions, et éventuels bugs.</p>
<p>La classe est documentée (en anglais) &gt; <a title="AnimatedBitmap doc" href="http://www.flashxpress.net/wp-content/animatedBitmap/doc/">accéder à la doc</a></p>
<p>Voici les sources : <a title="Télécharger les sources" href="http://www.flashxpress.net/wp-content/animatedBitmap/AnimatedBitmap_sources.zip">AnimatedBitmap_sources</a></p>
<p>Et merci à Thibault et son composant Banana Slice pour l&#8217;inspiration : <a href="http://www.bytearray.org/?p=117">http://www.bytearray.org/?p=117</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashxpress.net/ressources-flash/dopez-votre-framerate-avec-les-classes-animatedbitmap-et-animatedbitmapdata/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>HD Video Accélérée avec la classe StageVideo du Player 10.2</title>
		<link>http://www.flashxpress.net/ressources-flash/hd-video-acceleree-avec-la-classe-stagevideo-du-player-10-2/</link>
		<comments>http://www.flashxpress.net/ressources-flash/hd-video-acceleree-avec-la-classe-stagevideo-du-player-10-2/#comments</comments>
		<pubDate>Mon, 28 Mar 2011 09:33:10 +0000</pubDate>
		<dc:creator>alama</dc:creator>
				<category><![CDATA[Flash ActionScript]]></category>
		<category><![CDATA[Tutoriels Flash]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Direct]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[GPU]]></category>
		<category><![CDATA[HD]]></category>
		<category><![CDATA[Player 10.2]]></category>
		<category><![CDATA[StageVideo]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://www.flashxpress.net/?p=6167</guid>
		<description><![CDATA[A partir de la version <strong>10.2 du player Flash</strong>, Avec la possibilité de changer l'icône du mouseCursor, Adobe a introduit une couche supplémentaire permettant de lire de la vidéo de manière plus rapide et utilisant l'accélération matérielle des cartes graphique.

Cette couche se trouve au niveau de l'objet stage de votre animation, elle est directe et ne fait pas partie de la liste d'affichage à proprement parler, elle n'est pas un <code>DisplayObject</code>. En conséquence, elle ne bénéficie pas des méthodes et propriétés habituelles des <code>DisplayObjects</code>, elle ne gère pas non plus la couche alpha.]]></description>
			<content:encoded><![CDATA[<h3>La classe StageVideo</h3>
<p>A partir de la version <strong>10.2 du player Flash</strong>, avec la possibilité de changer l&#8217;icône du mouseCursor, Adobe a introduit une couche supplémentaire permettant de lire de la vidéo de manière plus rapide et utilisant l&#8217;accélération matérielle des cartes graphique.</p>
<p>Cette couche se trouve au niveau de l&#8217;objet stage de votre animation, elle est directe et ne fait pas partie de la liste d&#8217;affichage à proprement parler, elle n&#8217;est pas un <code>DisplayObject</code>. En conséquence, elle ne bénéficie pas des méthodes et propriétés habituelles des <code>DisplayObjects</code>, elle ne gère pas non plus la couche alpha.</p>
<p>Cette couche est une instance de la classe <code>StageVideo</code>, je dis une, mais en réalité, lors de l&#8217;initialisation de l&#8217;objet stage, une série d&#8217;objets stageVideos vont être créés allant de <strong>1</strong> à <strong>x</strong> suivant votre matériel, sur mon portable, j&#8217;ai <strong>16</strong> layers <code>stageVideo </code>disponibles. Ces layers sont référencés dans un <code>array</code> en tant que propriété de <code>stage</code>.</p>
<p>Cliquer sur la vidéo pour mettre en lecture / pause</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_stageVideo02_1847955381"
			class="flashmovie"
			width="600"
			height="400">
	<param name="movie" value="http://www.covergraph.com/blog/flash/stage_video/stageVideo02.swf" />
	<param name="wmode" value="direct" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.covergraph.com/blog/flash/stage_video/stageVideo02.swf"
			name="fm_stageVideo02_1847955381"
			width="600"
			height="400">
		<param name="wmode" value="direct" />
	<!--<![endif]-->
		
<p><a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<h3>Au banc d&#8217;essai</h3>
<p>Au départ, j&#8217;ai suivi le getting started rédigé par <a href="http://www.bytearray.org/" target="_blank">Thibault Imbert</a> sur le site d&#8217;Adobe:</p>
<p><a href="http://www.adobe.com/devnet/flashplayer/articles/stage_video.html">http://www.adobe.com/devnet/flashplayer/articles/stage_video.html</a></p>
<p>Sur mon portable, tout allait bien, mais sur une machine équipée d&#8217;une Matrox Parhélia 256 Tripple head, fini! Image noire! Elle pilote 3 écrans, mais ne possède pas de décodeur pour le <strong>H264 </strong>qui est la norme actuelle. Alors j&#8217;ai tout repris à partir de zéro.</p>
<p>Il est clair qu&#8217;il ne faut jamais implémenter un lecteur vidéo basé sur un stageVideo sans y ajouter une version normale de secours de type <code>DisplayObject </code>classique. Afin de s&#8217;assurer que l&#8217;objet stagevideo peut réellement prendre en charge la vidéo, il faut passer par 2 tests.</p>
<p>Il faut tester si un ou plusieurs objets stageVideos ont été créés par le player Flash, grâce à un <strong>Event  StageVideoAvailability</strong> généré par le stage au moment de l&#8217;initiation de l&#8217;anim. Si ce test est ok, il faut encore tester le type de décodage sur l&#8217;event <strong>RenderState </strong>généré par l&#8217;objet video, c&#8217;est à dire par l&#8217;objet qui affiche la vidéo (<strong>stageVideo </strong>ou <strong>video</strong>), car le player peut reconnaître un decodeur matériel et instancier des stageVideos tout en affichant une image noire. Si un des test retourne « <strong>unavailable </strong>», il faut switcher sur une version classique sofware.</p>
<p>Il est à noter que l&#8217;objet stageVideo s&#8217;affiche dans un <strong>viewport </strong>(comme en 3D) et non dans un displayObject classique, donc, les réglages de taille et de coordonées x,y ne se font pas de la même façon. Le viewport se règle sur base d&#8217;un objet <code>Rectangle</code>. L&#8217;Event <strong>renderState </strong>n&#8217;émane pas du même target.</p>
<p>L&#8217;intégration HTML doit se faire en <strong>wmode=&nbsp;&raquo;direct&nbsp;&raquo;</strong> ou éventuellement &laquo;&nbsp;gpu&nbsp;&raquo; si vous n&#8217;avez pas de vectoriel à traiter dans l&#8217;application.</p>
<h3>Le code AS3</h3>
<p>Voici le code de base permettant d&#8217;utiliser le stageVideo en intégrant une prise en charge par un objet vidéo classique comme solution de secours.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p6167code12'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p616712"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
</pre></td><td class="code" id="p6167code12"><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> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=sprite%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:sprite.html"><span style="color: #004993;">Sprite</span></a><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span><span style="color: #000066; font-weight: bold;">.</span>StageVideoAvailabilityEvent<span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span><span style="color: #000066; font-weight: bold;">.</span>StageVideoEvent<span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span><span style="color: #000066; font-weight: bold;">.</span>VideoEvent<span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.geom</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=point%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:point.html"><span style="color: #004993;">Point</span></a><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.geom</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=rectangle%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:rectangle.html"><span style="color: #004993;">Rectangle</span></a><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.media</span><span style="color: #000066; font-weight: bold;">.</span>StageVideo<span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.media</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=video%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:video.html"><span style="color: #004993;">Video</span></a><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.net</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=netconnection%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netconnection.html"><span style="color: #004993;">NetConnection</span></a><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.net</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=netstream%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstream.html"><span style="color: #004993;">NetStream</span></a><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.text</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=textfield%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textfield.html"><span style="color: #004993;">TextField</span></a><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.text</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=textfieldautosize%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textfieldautosize.html"><span style="color: #004993;">TextFieldAutoSize</span></a><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
	<span style="color: #3f5fbf;">/**
	 *
	 * @author Alama
	 *
	 */</span>
	<span style="color: #000000;">&#91;</span>SWF<span style="color: #000000;">&#40;</span><span style="color: #004993;">frameRate</span>=<span style="color: #990000;">&quot;1&quot;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">backgroundColor</span>=<span style="color: #990000;">&quot;#000000&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
	<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> <a href="http://www.google.com/search?q=sprite%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:sprite.html"><span style="color: #004993;">Sprite</span></a>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> static const FILE_NAME<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a> = <span style="color: #990000;">&quot;file.f4v&quot;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> nc<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=netconnection%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netconnection.html"><span style="color: #004993;">NetConnection</span></a><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> ns<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=netstream%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstream.html"><span style="color: #004993;">NetStream</span></a><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> rc<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=rectangle%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:rectangle.html"><span style="color: #004993;">Rectangle</span></a><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> video<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=video%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:video.html"><span style="color: #004993;">Video</span></a><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> stageVideo<span style="color: #000066; font-weight: bold;">:</span>StageVideo<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> ratioVideo<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a><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> videoObject<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a><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> renderType<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a><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> txtOut<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=textfield%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textfield.html"><span style="color: #004993;">TextField</span></a><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
		<span style="color: #3f5fbf;">/**
		 * Construct
		 *
		 */</span>
		<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: #000000;">&#123;</span>
			<span style="color: #009900; font-style: italic;">// On attend que la classe document soit complètement instanciée et dans la displayList.</span>
			<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">ADDED_TO_STAGE</span><span style="color: #000066; font-weight: bold;">,</span> onAddedToStage<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #3f5fbf;">/**
		 *
		 * @param event
		 *
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> onAddedToStage<span style="color: #000000;">&#40;</span>event<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><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;">// Connection</span>
			nc = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=netconnection%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netconnection.html"><span style="color: #004993;">NetConnection</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			nc<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">connect</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			ns = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=netstream%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstream.html"><span style="color: #004993;">NetStream</span></a><span style="color: #000000;">&#40;</span>nc<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			<span style="color: #009900; font-style: italic;">// client pour la fonction onMetaData</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> customClient<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=object%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:object.html"><span style="color: #004993;">Object</span></a><span style="color: #000066; font-weight: bold;">;</span>
			customClient = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=object%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:object.html"><span style="color: #004993;">Object</span></a><span style="color: #000066; font-weight: bold;">;</span>
			customClient<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">onMetaData</span> = onMetaDataHandler<span style="color: #000066; font-weight: bold;">;</span>
			ns<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">client</span> = customClient<span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			<span style="color: #009900; font-style: italic;">// on ecoute l'init des stageVideos sur le stage</span>
			<span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span>StageVideoAvailabilityEvent<span style="color: #000066; font-weight: bold;">.</span>STAGE_VIDEO_AVAILABILITY<span style="color: #000066; font-weight: bold;">,</span> stageVideoAvailabilityHandler<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			<span style="color: #009900; font-style: italic;">// text output</span>
			txtOut = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=textfield%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textfield.html"><span style="color: #004993;">TextField</span></a><span style="color: #000066; font-weight: bold;">;</span>
			txtOut<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">textColor</span> = 0xffffff<span style="color: #000066; font-weight: bold;">;</span>
			txtOut<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">autoSize</span> = <a href="http://www.google.com/search?q=textfieldautosize%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textfieldautosize.html"><span style="color: #004993;">TextFieldAutoSize</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">LEFT</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>txtOut<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;">private</span> <span style="color: #339966; font-weight: bold;">function</span> stageVideoAvailabilityHandler<span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span>StageVideoAvailabilityEvent<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;">// (facultatif) On peut vérifier l'existance de 1 à x StageVideos maximum en testant le array</span>
			<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Number of stageVideos: &quot;</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span>stageVideos<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">length</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #009900; font-style: italic;">// Nous n'avons plus besoin du listener</span>
			<span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">removeEventListener</span><span style="color: #000000;">&#40;</span>StageVideoAvailabilityEvent<span style="color: #000066; font-weight: bold;">.</span>STAGE_VIDEO_AVAILABILITY<span style="color: #000066; font-weight: bold;">,</span> stageVideoAvailabilityHandler<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #009900; font-style: italic;">// on teste si on a un objet stageVideo de dispo</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">.</span>availability == <span style="color: #990000;">&quot;available&quot;</span><span style="color: #000000;">&#41;</span>
			<span style="color: #000000;">&#123;</span>
				<span style="color: #009900; font-style: italic;">// si oui, on utilise le premier</span>
				stageVideo = <span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span>stageVideos<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">;</span>
				<span style="color: #009900; font-style: italic;">// on lui colle le stream video</span>
				stageVideo<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">attachNetStream</span><span style="color: #000000;">&#40;</span>ns<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
				<span style="color: #009900; font-style: italic;">// on ecoute l'etat du render qui sera déclenché au play()</span>
				stageVideo<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span>StageVideoEvent<span style="color: #000066; font-weight: bold;">.</span>RENDER_STATE<span style="color: #000066; font-weight: bold;">,</span> stageVideoRenderStateHandler<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
				<span style="color: #009900; font-style: italic;">// on lance le play pour déclencher le renderState</span>
				ns<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">play</span><span style="color: #000000;">&#40;</span>FILE_NAME<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: #009900; font-style: italic;">// Sinon, on utilise la méthode video normale (displayObject classique)</span>
				useDisplayObjectVideo<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: #000000;">&#125;</span>
&nbsp;
		<span style="color: #009900; font-style: italic;">// Handler du renderState StageVideo</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> stageVideoRenderStateHandler<span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span>StageVideoEvent<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;">// on vérifie si le décodage est bien réalisé ou pas</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span> e<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">status</span> == <span style="color: #990000;">&quot;unavailable&quot;</span><span style="color: #000000;">&#41;</span>
			<span style="color: #000000;">&#123;</span>
				<span style="color: #009900; font-style: italic;">// si pas de rendu, on libère les ressources</span>
				stageVideo<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">removeEventListener</span><span style="color: #000000;">&#40;</span>StageVideoEvent<span style="color: #000066; font-weight: bold;">.</span>RENDER_STATE<span style="color: #000066; font-weight: bold;">,</span> stageVideoRenderStateHandler<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
				stageVideo = <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000066; font-weight: bold;">;</span>
				useDisplayObjectVideo<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: #009900; font-style: italic;">// sinon, on garde l'objet stageVideo comme lecteur</span>
				videoObject = <span style="color: #990000;">&quot;stageVideo&quot;</span><span style="color: #000066; font-weight: bold;">;</span>
				renderType = e<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">status</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #009900; font-style: italic;">// video normale (DisplayObject)</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> useDisplayObjectVideo<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>
			video = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=video%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:video.html"><span style="color: #004993;">Video</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			video<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">smoothing</span> = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span>
			video<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">attachNetStream</span><span style="color: #000000;">&#40;</span>ns<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			video<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</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>
			video<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span>VideoEvent<span style="color: #000066; font-weight: bold;">.</span>RENDER_STATE<span style="color: #000066; font-weight: bold;">,</span> videoRenderStateHandler<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>video<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			ns<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">play</span><span style="color: #000000;">&#40;</span>FILE_NAME<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #009900; font-style: italic;">//Handler du renderState video classique</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> videoRenderStateHandler<span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span>VideoEvent<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>
			videoObject = <span style="color: #990000;">&quot;displayObjectVideo&quot;</span><span style="color: #000066; font-weight: bold;">;</span>
			renderType = e<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">status</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> onMetaDataHandler<span style="color: #000000;">&#40;</span><span style="color: #004993;">info</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=object%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:object.html"><span style="color: #004993;">Object</span></a><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;metadata: duration=&quot;</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #004993;">info</span><span style="color: #000066; font-weight: bold;">.</span>duration <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #990000;">&quot; width=&quot;</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #004993;">info</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #990000;">&quot; height=&quot;</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #004993;">info</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: #990000;">&quot; framerate=&quot;</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #004993;">info</span><span style="color: #000066; font-weight: bold;">.</span>framerate<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #009900; font-style: italic;">// on prend le rapport d'image</span>
			ratioVideo = <span style="color: #004993;">info</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: #004993;">info</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #009900; font-style: italic;">// le cadrage video ne se fait pas de la même manière, stageVideo est un viewPort et non un displayObject.</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>videoObject == <span style="color: #990000;">&quot;stageVideo&quot;</span><span style="color: #000000;">&#41;</span>
			<span style="color: #000000;">&#123;</span>
				<span style="color: #6699cc; font-weight: bold;">var</span> posY<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a> = <span style="color: #000000;">&#40;</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: #004993;">info</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> <span style="color: #000066; font-weight: bold;">*</span> ratioVideo<span style="color: #000000;">&#41;</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>
				stageVideo<span style="color: #000066; font-weight: bold;">.</span>viewPort = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=rectangle%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:rectangle.html"><span style="color: #004993;">Rectangle</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> posY<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;">stageWidth</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">info</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> <span style="color: #000066; font-weight: bold;">*</span> ratioVideo<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
				txtOut<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> = <span style="color: #990000;">&quot;Render Type: [StageVideo] - Decoder: &quot;</span> <span style="color: #000066; font-weight: bold;">+</span> renderType<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>
				video<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> = video<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000066; font-weight: bold;">*</span> ratioVideo<span style="color: #000066; font-weight: bold;">;</span>
				video<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = <span style="color: #000000;">&#40;</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> video<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span><span style="color: #000000;">&#41;</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>
				txtOut<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> = <span style="color: #990000;">&quot;Render Type: [DisplayObject] - Decoder: &quot;</span> <span style="color: #000066; font-weight: bold;">+</span> renderType<span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.flashxpress.net/ressources-flash/hd-video-acceleree-avec-la-classe-stagevideo-du-player-10-2/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Flash Player 11 – Charger un MP3 local avec FileReference et loadMp3FromByteArray</title>
		<link>http://www.flashxpress.net/ressources-flash/flash-player-11-%e2%80%93-charger-un-mp3-local-avec-filereference/</link>
		<comments>http://www.flashxpress.net/ressources-flash/flash-player-11-%e2%80%93-charger-un-mp3-local-avec-filereference/#comments</comments>
		<pubDate>Mon, 28 Mar 2011 09:25:55 +0000</pubDate>
		<dc:creator>alama</dc:creator>
				<category><![CDATA[Flash ActionScript]]></category>
		<category><![CDATA[Flash dynamique]]></category>
		<category><![CDATA[Tutoriels Flash]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[FlashDevelop]]></category>
		<category><![CDATA[incubator]]></category>
		<category><![CDATA[load]]></category>
		<category><![CDATA[loadFromByteArray]]></category>
		<category><![CDATA[local]]></category>
		<category><![CDATA[mp3]]></category>
		<category><![CDATA[Player 11]]></category>
		<category><![CDATA[sound]]></category>

		<guid isPermaLink="false">http://www.flashxpress.net/?p=6184</guid>
		<description><![CDATA[La classe <code>FileReference </code>permet de charger un MP3 depuis le disque dur local (client) via la méthode <code>load()</code>. Cependant, le fichier reçu se trouve dans un byteArray, nous recevons un RAW. Évidemment, la classe <code>Sound</code> ne permet pas de charger ce type de données, il faut alors passer par du code écrit sois même qui devra parser le MP3, gerer la partie ID3 et créer une classe <code>Sound</code> qui contient le son MP3. Ce genre de mini Framework existe, notamment AudioFx.]]></description>
			<content:encoded><![CDATA[<h3>Charger un fichier MP3 local</h3>
<p>La classe <code>FileReference </code>permet de charger un MP3 depuis le disque dur local (client) via la méthode <code>load()</code>. Cependant, le fichier reçu se trouve dans un byteArray, nous recevons un RAW. Évidemment, la classe <code>Sound</code> ne permet pas de charger ce type de données, il faut alors passer par du code écrit sois même qui devra parser le MP3, gerer la partie ID3 et créer une classe <code>Sound</code> qui contient le son MP3. Ce genre de mini Framework existe, notamment AudioFx.</p>
<h3>La méthode loadMp3FromByteArray de la classe Sound</h3>
<p>J&#8217;avais posté sur la branche jira de bugs.adobe à ce propos, je me suis d&#8217;ailleurs trompé, j&#8217;ai publié un bug post au lieu d&#8217;un request feature, mais bon, ça n&#8217;a apparemment pas porté à préjudice.. lol<br />
<a href="https://bugs.adobe.com/jira/browse/FP-5920" target="_blank">https://bugs.adobe.com/jira/browse/FP-5920 </a></p>
<p>Toujours est-il qu&#8217;une nouvelle feature à été ajoutée à la classe <code>Sound</code> afin de résoudre ce souci, elle est en <strong>préview </strong>sur le <strong>player 11 bêta</strong> et il n&#8217;y aurait <strong>aucune certitude</strong> que cette feature restera pour la sortie RC.  Alors, j&#8217;invite tous les lecteurs de mon tuto à appuyer cette demande en votant ou en laissant un message sur mon post chez Adobe. Il y a un lien <strong>Voting</strong> dans la colonne gauche. <img src='http://www.flashxpress.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>Afin de tester cette feature, vous devez installer les versions beta du <strong>plugin</strong> et <strong>activeX du player 11</strong>, vous pouvez les télécharger ici: <a href="http://labs.adobe.com/downloads/flashplatformruntimes_incubator.html" target="_blank">http://labs.adobe.com/downloads/flashplatformruntimes_incubator.html </a></p>
<p>Une fois installé, pour <strong>Chrome</strong>, vous devez le sélectionner de la manière suivante:<br />
Dans la barre d&#8217;adresse de chrome, tapez: <strong>about:plugins</strong> ensuite, cliquer sur <strong>details</strong>.</p>
<p>Dans la liste des plugins, il doit y avoir celui installé par chrome lui même et le 11 bêta installé dans votre système. Il suffit de désactiver celui installé par chrome et il prendra par défaut celui du système.</p>
<p>Si c&#8217;est réussi, vous devez voir lors de la lecture d&#8217;un SWF la mention <strong>Flash Player 11 (incubator build)</strong> en bas de l&#8217;animation.</p>
<p>Clic on black rectangle for load mp3.<br />

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_testLoadMp3FromByteArray_619367731"
			class="flashmovie"
			width="400"
			height="150">
	<param name="movie" value="http://www.covergraph.com/blog/flash/load_local_mp3/testLoadMp3FromByteArray.swf" />
	<param name="wmode" value="direct" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.covergraph.com/blog/flash/load_local_mp3/testLoadMp3FromByteArray.swf"
			name="fm_testLoadMp3FromByteArray_619367731"
			width="400"
			height="150">
		<param name="wmode" value="direct" />
	<!--<![endif]-->
		
<p><a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a><br />

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<h3>Tester l&#8217;API du beta player 11 sous FlashDevelop</h3>
<p>Afin de tester une <strong>API bêta</strong>, il faut préparer <strong>FlashDevelop</strong> en suivant les étapes suivantes:</p>
<ul>
<li>Télécharger le dernier <strong>SDK</strong> préconisé par Adobe Labs:<br />
<a href="http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+Hero" target="_blank">http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+Hero</a></li>
<li>Téléchager le <strong>playerglobal.swc</strong> du player beta:<br />
<a href="http://download.macromedia.com/pub/labs/flashplatformruntimes/incubator/flashplayer_inc_playerglobal_022711.swc" target="_blank">http://download.macromedia.com/pub/labs/flashplatformruntimes/incubator/flashplayer_inc_playerglobal_022711.swc</a></li>
<li>Créer un nouveau projet AS3 sous FD, ensuite, aller dans <strong>AS3Context</strong> et cibler le <strong>SDK</strong> téléchargé.</li>
<li>Aller dans le répertoire <strong>framework/libs/players/10.1</strong> du sdk et remplacer le playerGlobal présent par celui qu&#8217;on vient de télécharger. (en le renommant <strong>playerglobal.swc</strong>). C&#8217;est ce fichier qui contient toutes les références de classes de l&#8217;API que FlashDevelop utilise pour l&#8217;autoCompletion et que le mxmlc utilise pour compiler en mode strict.</li>
<li>Aller dans les propriétés du projet, cibler le <strong>player 10.1</strong>, ensuite, aller dans l&#8217;onglet <strong>compiler options</strong>, et dans <strong>Additional Compiler Options</strong>, ajouter <strong>-swf-version=13</strong>.</li>
</ul>
<p>Voilà, nous sommes prêt à programmer.</p>
<p><strong>FD4</strong> proposera <strong>peut être</strong> une auto reconnaissance des versions player par analyse du SDK ciblé, cela demandera moins de manipulation quand on devra tester des versions bêta et on ne devra plus attendre de mise à jour de FD pour cibler les nouveaux players. Là aussi, j&#8217;ai déposé une demande de feature, libre à vous de la soutenir également.. <img src='http://www.flashxpress.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
<a href="http://www.flashdevelop.org/community/viewtopic.php?f=5&amp;t=8050" target="_blank"> http://www.flashdevelop.org/community/viewtopic.php?f=5&amp;t=8050</a></p>
<h3>Au banc d&#8217;essai &#8211; code AS3</h3>
<p>Voici le code minimum de base afin d&#8217;exploiter cette nouvelle fonctionnalité.<br />
Il est a noté que la méthode <code>close()</code> et l&#8217;événement <code>complete</code> de la classe <code>Sound</code> ne fonctionne pas dans cette implémentation, ils ne s&#8217;appliquent apparemment qu&#8217;en cas de loading distant. Il ne faudra donc pas chercher a les utiliser pour un chargement local via <code>FileReference</code>.</p>
<p>Pour les <strong>ID3</strong>, AS3 propose les propriétés de base (songName, etc..) Mais je conseille d&#8217;utiliser directement les vrais identifiants définis par l&#8217;<strong>ID3 Org</strong> (les classiques sont les frames 4.2 serie): <a href="http://www.id3.org/d3v2.3.0" target="_blank"> http://www.id3.org/d3v2.3.0</a></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p6184code13'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p618413"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
</pre></td><td class="code" id="p6184code13"><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> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=sprite%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:sprite.html"><span style="color: #004993;">Sprite</span></a><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=mouseevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:mouseevent.html"><span style="color: #004993;">MouseEvent</span></a><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.media</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=sound%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:sound.html"><span style="color: #004993;">Sound</span></a><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.media</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=soundchannel%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:soundchannel.html"><span style="color: #004993;">SoundChannel</span></a><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.net</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=filefilter%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:filefilter.html"><span style="color: #004993;">FileFilter</span></a><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.net</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=filereference%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:filereference.html"><span style="color: #004993;">FileReference</span></a><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.text</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=textfield%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textfield.html"><span style="color: #004993;">TextField</span></a><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.text</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=textfieldautosize%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textfieldautosize.html"><span style="color: #004993;">TextFieldAutoSize</span></a><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
	<span style="color: #3f5fbf;">/**
	 * ...
	 * @author Alama
	 */</span>
	<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> <a href="http://www.google.com/search?q=sprite%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:sprite.html"><span style="color: #004993;">Sprite</span></a>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> fileRef<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=filereference%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:filereference.html"><span style="color: #004993;">FileReference</span></a><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> sound<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=sound%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:sound.html"><span style="color: #004993;">Sound</span></a><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> channel<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=soundchannel%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:soundchannel.html"><span style="color: #004993;">SoundChannel</span></a><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> txt<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=textfield%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textfield.html"><span style="color: #004993;">TextField</span></a><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>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">stage</span><span style="color: #000000;">&#41;</span> <span style="color: #004993;">init</span><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;">else</span> <span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">ADDED_TO_STAGE</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">init</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;">private</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">init</span><span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a> = <span style="color: #0033ff; font-weight: bold;">null</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;">removeEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">ADDED_TO_STAGE</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">init</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #009900; font-style: italic;">// entry point</span>
&nbsp;
			<span style="color: #009900; font-style: italic;">// button test</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> btn<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=sprite%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:sprite.html"><span style="color: #004993;">Sprite</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=sprite%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:sprite.html"><span style="color: #004993;">Sprite</span></a><span style="color: #000066; font-weight: bold;">;</span>
			btn<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">beginFill</span><span style="color: #000000;">&#40;</span>0x000000<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			btn<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">drawRect</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">50</span><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> <span style="color: #000000; font-weight:bold;">150</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">40</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			btn<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">endFill</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>btn<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			btn<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">buttonMode</span> = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span>
			btn<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=mouseevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:mouseevent.html"><span style="color: #004993;">MouseEvent</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">CLICK</span><span style="color: #000066; font-weight: bold;">,</span> btnClickHandler<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			<span style="color: #009900; font-style: italic;">// output text</span>
			txt = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=textfield%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textfield.html"><span style="color: #004993;">TextField</span></a><span style="color: #000066; font-weight: bold;">;</span>
			txt<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">autoSize</span> = <a href="http://www.google.com/search?q=textfieldautosize%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textfieldautosize.html"><span style="color: #004993;">TextFieldAutoSize</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">LEFT</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>txt<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;">private</span> <span style="color: #339966; font-weight: bold;">function</span> btnClickHandler<span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=mouseevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:mouseevent.html"><span style="color: #004993;">MouseEvent</span></a><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>
			fileRef = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=filereference%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:filereference.html"><span style="color: #004993;">FileReference</span></a><span style="color: #000066; font-weight: bold;">;</span>
			fileRef<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">SELECT</span><span style="color: #000066; font-weight: bold;">,</span> fileRefSelectHandler<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: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			fileRef<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">browse</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=array%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:array.html"><span style="color: #004993;">Array</span></a><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=filefilter%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:filefilter.html"><span style="color: #004993;">FileFilter</span></a><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Music: *.mp3&quot;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #990000;">&quot;*.mp3&quot;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #990000;">&quot;*.MP3&quot;</span><span style="color: #000000;">&#41;</span><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>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> fileRefSelectHandler<span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><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>
			fileRef<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">COMPLETE</span><span style="color: #000066; font-weight: bold;">,</span> fileRefCompleteHandler<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: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			fileRef<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">load</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;">private</span> <span style="color: #339966; font-weight: bold;">function</span> fileRefCompleteHandler<span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><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>
			fileRef = <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>channel <span style="color: #000066; font-weight: bold;">!</span>= <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span>
			<span style="color: #000000;">&#123;</span>
				channel<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">stop</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
				channel = <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000066; font-weight: bold;">;</span>
				sound = <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #000000;">&#125;</span>
			sound = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=sound%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:sound.html"><span style="color: #004993;">Sound</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			sound<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">ID3</span><span style="color: #000066; font-weight: bold;">,</span> soundID3Handler<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: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			sound<span style="color: #000066; font-weight: bold;">.</span>loadMP3FromByteArray<span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">target</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">data</span><span style="color: #000066; font-weight: bold;">,</span> e<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">target</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">data</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">length</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			channel = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=soundchannel%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:soundchannel.html"><span style="color: #004993;">SoundChannel</span></a><span style="color: #000066; font-weight: bold;">;</span>
			channel = sound<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">play</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;">private</span> <span style="color: #339966; font-weight: bold;">function</span> soundID3Handler<span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><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;">// sometimes, on fisrt load, this handler is invoked twice!!??</span>
			<span style="color: #009900; font-style: italic;">// it's a light bug, but not serious..</span>
			<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">target</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">id3</span><span style="color: #000066; font-weight: bold;">.</span>TIT2<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			txt<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> = sound<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">id3</span><span style="color: #000066; font-weight: bold;">.</span>TIT2<span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>Voilà, espérons que cette feature restera définitivement au sein de l&#8217;APPI AS3.. car elle est bien plus simple et rapide que des classes de parsing.</p>
<h3>Soutenez une autre request feature pour la gestion du son</h3>
<p>A propos du son dans Flash, depuis le player 10, nous pouvons fabriquer nos propres sons de façon binaire et l&#8217;envoyer à la lecture grâce à l&#8217;événement <code>SampleData</code>. C&#8217;est super, mais celui ci souffre d&#8217;un problème majeur! La taille minimum du buffer (le byteArray des samples) est de <strong>2048 samples</strong> !! cela introduit inévitablement une latence audible qui peut aller jusqu&#8217;à <strong>+/- 300 ms</strong> avec les pertes du modèle événementiel etc.. J&#8217;ai donc également introduit une demande de révision du principe en proposant d&#8217;autres solutions.. Cette tâche incombe à la partie <strong>Core Player</strong>, donc, impossible à régler via <strong>l&#8217;AVMplus</strong>, donc, à priori, seul <strong>Adobe</strong> peut changer cela.</p>
<p><strong>Je vous invite également à soutenir cette demande en votant et éventuellement en participant à la discussion ici:</strong><br />
<a href="https://bugs.adobe.com/jira/browse/FP-5655" target="_blank"> https://bugs.adobe.com/jira/browse/FP-5655</a></p>
<p>Enjoy <img src='http://www.flashxpress.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashxpress.net/ressources-flash/flash-player-11-%e2%80%93-charger-un-mp3-local-avec-filereference/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Mise en cache des assets vectoriels pour AIR mobile</title>
		<link>http://www.flashxpress.net/ressources-flash/mise-en-cache-des-assets-vectoriels-pour-air-mobile/</link>
		<comments>http://www.flashxpress.net/ressources-flash/mise-en-cache-des-assets-vectoriels-pour-air-mobile/#comments</comments>
		<pubDate>Fri, 25 Mar 2011 16:15:28 +0000</pubDate>
		<dc:creator>Nicolas Gans</dc:creator>
				<category><![CDATA[Flash ActionScript]]></category>
		<category><![CDATA[Flash mobile]]></category>
		<category><![CDATA[Tutoriels Flash]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[iPad]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Playbook]]></category>

		<guid isPermaLink="false">http://www.flashxpress.net/?p=6201</guid>
		<description><![CDATA[Je vous mets en ligne mes slides de la mini-conf de 10 minutes que j'ai présenté lors de l'événement "Lightning talks" organisé par Adobe, les Tontons Flexeurs et Flashxpress le 24 mars 2011.

J'y ai présenté un aperçu des techniques et bonnes pratiques en matière de cache des éléments vectoriels d'un jeu ou d'une application AS3 pour AIR mobile. Toutes ces techniques permettent de faire grimper significativement le framerate de vos applications.]]></description>
			<content:encoded><![CDATA[<p>Je vous mets en ligne les slides de la mini-conf de 10 minutes que j&#8217;ai présenté lors de l&#8217;événement <a href="http://www.flashxpress.net/focus/evenement-a-paris-lightning-talks/" target="_self">&laquo;&nbsp;Lightning talks&nbsp;&raquo;</a> organisé par Adobe, les Tontons Flexeurs et Flashxpress le 24 mars 2011.</p>
<p>J&#8217;y ai présenté un aperçu des techniques et bonnes pratiques en matière de cache des éléments vectoriels pour un jeu ou une application AS3 pour AIR mobile. Toutes ces techniques permettent de faire grimper significativement le framerate de vos applications. Cliquez sur les slides, puis flèche droite/gauche du clavier pour se déplacer.</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_slides_627898486"
			class="flashmovie"
			width="630"
			height="400">
	<param name="movie" value="http://www.flashxpress.net/wp-content/uploads/2011/03/slides.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.flashxpress.net/wp-content/uploads/2011/03/slides.swf"
			name="fm_slides_627898486"
			width="630"
			height="400">
	<!--<![endif]-->
		<a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>En bonus, une petite vidéo des démos que j&#8217;ai présenté à cette soirée, pour vous donner une idée des performances si vous appliquez ces techniques.</p>
<p><div id="cache_air_mobile">
<video controls="controls" width="630" height="473">
<source src="http://ks358667.kimsufi.com/~video/webtv/iPhone/cache_air_mobile.mp4" type="video/mp4" />
</video>
</div>
<script type="text/javascript">
jwplayer("cache_air_mobile").setup({
flashplayer: "http://www.flashxpress.net/wp-content/uploads/jw-player-plugin-for-wordpress/player/player.swf",
file: "http://ks358667.kimsufi.com/~video/webtv/cache_air_mobile.f4v",
image: "http://ks358667.kimsufi.com/~video/webtv/posters/cache_air_mobile.f4v.jpg",
width: 630,
height: 473
});
</script>
<p>&nbsp;</p>
</p>
<p>Merci à tous ceux qui étaient présents, à bientôt pour une prochaine édition !</p>
<p><span style="text-decoration: underline;"><strong>MAJ 28 mars</strong></span><br />
Voici les sources de ces démos, ce sont des &laquo;&nbsp;ActionScript mobile projects&nbsp;&raquo; faits dans Flash Builder Burrito. <a title="Flash Builder Burrito" href="http://labs.adobe.com/technologies/flashbuilder_burrito/" target="_blank">Il faut télécharger et installer Burrito</a> (preview de Flash Builder 4.5) pour les importer.</p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/03/exemples_lightning_talks.zip">Télécharger les sources</a></p>
<p>Je n&#8217;ai pas inclus l&#8217;exemple qui utilise mes classes AnimatedBitmapData et AnimatedBitmap. Je dois cleaner un peu le code avant de les poster. Stay tuned !!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashxpress.net/ressources-flash/mise-en-cache-des-assets-vectoriels-pour-air-mobile/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Création d’un lecteur de FLUX RSS en AIR avec Flash</title>
		<link>http://www.flashxpress.net/ressources-flash/creation-d%e2%80%99un-lecteur-de-flux-rss-en-air-avec-flash/</link>
		<comments>http://www.flashxpress.net/ressources-flash/creation-d%e2%80%99un-lecteur-de-flux-rss-en-air-avec-flash/#comments</comments>
		<pubDate>Thu, 27 Jan 2011 14:15:14 +0000</pubDate>
		<dc:creator>Olivier</dc:creator>
				<category><![CDATA[Flash dynamique]]></category>
		<category><![CDATA[Tutoriels Flash]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://www.flashxpress.net/?p=5555</guid>
		<description><![CDATA[Salut à tous. Pour mon premier petit tuto sur Flashxpress, je vous propose de réaliser un lecteur de Flux RSS, en AIR, sous Flash. La but de ce tuto est donc de vous apprendre à récupérer un flux RSS en AS3 et instancier à la volée un MovieClip par article qui contiendra le titre de [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/01/presentationTutoReaderRSS.png"><img class="alignnone size-full wp-image-5592" title="presentationTutoReaderRSS" src="http://www.flashxpress.net/wp-content/uploads/2011/01/presentationTutoReaderRSS.png" alt="" width="630" height="187" /></a></p>
<p>Salut à tous. Pour mon premier petit tuto sur Flashxpress, je vous propose de réaliser un lecteur de Flux RSS, en AIR, sous Flash.</p>
<p>La but de ce tuto est donc de vous apprendre à récupérer un flux RSS en AS3 et  instancier à la volée un MovieClip par article qui contiendra le titre de l’article ainsi qu’un bouton, qui, lorsqu’il sera cliqué, ouvrira le navigateur et affichera la page de l’article choisi.</p>
<h1>Création du projet</h1>
<p>Ouvrez Flash et sur l’écran d’accueil choisissez un fichier de type « Adobe AIR 2 ».</p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/01/01.jpg"><img class="alignnone size-full wp-image-5556" title="01" src="http://www.flashxpress.net/wp-content/uploads/2011/01/01.jpg" alt="" width="630" /></a></p>
<p>Enregistrer le fichier. Personnellement, je l’appelle « LecteurRSS ».</p>
<p>A partir de là, si on compile, on a bien une application AIR.</p>
<h1>Préparation des éléments graphiques</h1>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/01/02.jpg"><img class="alignnone size-full wp-image-5557" title="02" src="http://www.flashxpress.net/wp-content/uploads/2011/01/02.jpg" alt="" width="566" height="438" /></a></p>
<p>Niveau design nous allons rester simples car ce n’est pas le but du tuto.</p>
<p>Pour commencer, je ne souhaite pas que mon application s’ouvre dans une fenêtre de type Windows. Je souhaite ici designer moi-même le type de fenêtre et ses contrôles de gestion (le bouton réduire et le bouton fermer l’application).</p>
<p>Afin de ne plus avoir cette fenêtre, rendons nous dans le panneau Propriétés, dans Flash, et cliquons sur le bouton « Modifier » correspondant aux paramètres d’Adobe AIR 2.</p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/01/03.jpg"><img class="alignnone size-full wp-image-5558" title="03" src="http://www.flashxpress.net/wp-content/uploads/2011/01/03.jpg" alt="" width="304" height="465" /></a></p>
<p>Dans la fenêtre qui vient de s’ouvrir, sélectionnons dans le menu déroulant « Style de fenêtre », « Chrome personnalisé (transparent) ».</p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/01/04.jpg"><img class="alignnone size-full wp-image-5559" title="04" src="http://www.flashxpress.net/wp-content/uploads/2011/01/04.jpg" alt="" width="500" height="702" /></a></p>
<p>Si l’on recompile l’application, nous ne voyons plus rien apparaitre… mais l’application est belle et bien lancée, en témoigne le petit icône d’Adobe AIR dans la barre des tâches.</p>
<p>Si rien n’est visible c’est simplement par ce que notre application est vide.</p>
<p>Attelons-nous à présent au design d’une des lignes du lecteur.</p>
<p>Commençons par tracer un rectangle de 300 pixels de largeur par 50 de hauteur.</p>
<p>Remplissons-le d’un dégradé allant d’un gris foncé (#666666) vers le noir (#000000).</p>
<p>Grace à l’outil de transformation de dégradé, orientons ce remplissage verticalement.</p>
<p>Voici le résultat :</p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/01/05.jpg"><img class="alignnone size-full wp-image-5560" title="05" src="http://www.flashxpress.net/wp-content/uploads/2011/01/05.jpg" alt="" width="301" height="50" /></a></p>
<p>Pour le bouton « Lire », qui lorsqu’il sera cliqué ouvrira le navigateur sur la page de l’article, dessinons simplement un rectangle de 50 pixels par 50 pixels et alignons-le à droite du premier rectangle dessiné. Inversons la direction du dégradé. Voici le résultat :</p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/01/06.jpg"><img class="alignnone size-full wp-image-5561" title="06" src="http://www.flashxpress.net/wp-content/uploads/2011/01/06.jpg" alt="" width="348" height="50" /></a></p>
<p>Nous devons à présent ajouter deux champs texte. L’un contiendra le titre de l’article et le second simplement le texte « Lire».</p>
<p>Grace à l’outil Texte, dessinons donc les deux champs.</p>
<p>Le champ pour le titre doit être de type « Classique » / « Dynamique ». Pendant que nous y sommes, donnons-lui comme nom d’occurrence « titreArticle ».</p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/01/07.jpg"><img class="alignnone size-full wp-image-5562" title="07" src="http://www.flashxpress.net/wp-content/uploads/2011/01/07.jpg" alt="" width="304" height="99" /></a></p>
<p>Le champ texte contenant le mot « Lire » quant à lui n’a pas besoin d’être dynamique. Je choisis donc comme type de champ « Classique » et « Statique ».</p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/01/08.jpg"><img class="alignnone size-full wp-image-5563" title="08" src="http://www.flashxpress.net/wp-content/uploads/2011/01/08.jpg" alt="" width="304" height="98" /></a></p>
<p>Voici comment j’ai placé mes textes :</p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/01/09.jpg"><img class="alignnone size-full wp-image-5564" title="09" src="http://www.flashxpress.net/wp-content/uploads/2011/01/09.jpg" alt="" width="351" height="51" /></a></p>
<p>Nous allons maintenant sélectionner le rectangle et le texte composant le bouton « Lire » et appuyer sur F8 afin de convertir le tout en symbole.</p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/01/10.jpg"><img class="alignnone size-full wp-image-5565" title="10" src="http://www.flashxpress.net/wp-content/uploads/2011/01/10.jpg" alt="" width="449" height="165" /></a></p>
<p>Nommons le symbole « boutonLire », sélectionnons le type « Bouton » dans le menu déroulant du même nom, laissons l’alignement par défaut et validons en pressant le bouton « OK ». Entrons dans le symbole et insérons une image clé pour l’etat « Dessus » ainsi que pour l’état « Abaissé ». Sur l’état « Dessus », sélectionnons le rectangle de fond et intervertissons la position des deux couleurs (on revient donc au même dégradé que celui que l’on a sur le rectangle sous le titre).</p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/01/21.jpg"><img class="alignnone size-full wp-image-5575" title="21" src="http://www.flashxpress.net/wp-content/uploads/2011/01/21.jpg" alt="" width="630" /></a></p>
<p>Une fois le symbole crée, sélectionnons l’occurrence de celui-ci présente sur la scène et donnons-lui pour nom d’occurrence « btnLire ».</p>
<p><img class="alignnone size-full wp-image-5566" title="11" src="http://www.flashxpress.net/wp-content/uploads/2011/01/11.jpg" alt="" width="303" height="115" /></p>
<p>La dernière étape consiste tout simplement à sélectionner l’occurrence du bouton, le rectangle de fond du titre de l’article ainsi que le champ de texte « titreArticle » et à convertir le tout en symbole de type Clip.</p>
<p>Nommez le « Ligne ». Lors de la création du symbole, choisissons donc comme type dans le menu déroulant « Clip ». Nous devons en plus de cela, cocher la case « Exporter pour ActionScript » ainsi que « Exporter dans l’image 1 » (cette dernière se coche normalement de façon automatique).</p>
<p>Cela va nous permettre d’instancier ce clip directement par code. Veillez en revanche à bien mettre une majuscule au nom du symbole car ici nous créons une classe et que, par convention, les noms de classe commencent par une majuscule.</p>
<p>Le champ « Classe de base » doit en principe directement pointer vers la classe MovieClip, du fait que nous ayons choisi comme type de symbole « Clip ».</p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/01/12.jpg"><img class="alignnone size-full wp-image-5567" title="12" src="http://www.flashxpress.net/wp-content/uploads/2011/01/12.jpg" alt="" width="498" height="601" /></a></p>
<p>Validons ensuite la création de ce symbole en cliquant sur le bouton « OK ».</p>
<p>Si l’on regarde à présent dans notre bibliothèque, nous avons donc deux symboles, un bouton (boutonLire) et un MovieClip (Ligne).</p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/01/14.jpg"><img class="alignnone size-full wp-image-5568" title="14" src="http://www.flashxpress.net/wp-content/uploads/2011/01/14.jpg" alt="" width="304" height="165" /></a></p>
<p>La colonne « Liaison » du bouton lire doit en principe être remplie avec comme mention « Ligne ».</p>
<p>Notre premier élément graphique est prêt. Nous pouvons à présent supprimer l’occurrence du MovieClip présent sur la scène.</p>
<p>Bien, je vais maintenant importer le logo que je souhaite placer dans mon application. Histoire de faire bien original, je vais utiliser le logo Flashxpress (super site, vous connaissez ? ^_^).</p>
<p>Je me contenterais ici de faire un copier / coller depuis Illustrator.</p>
<p>Une fois importé et redimensionné (il fait maintenant  100 pixels de largeur pour 30 de hauteur), je le convertis en symbole de type Clip, sans cocher cette fois ci l’option « Exporter pour ActionScript » et le nomme « logoFXP ». Je place enfin l’occurrence du clip « logoFXP » sur la scène à une position en X et en Y de 0. Notre logo est prêt.</p>
<p>Il nous reste deux petits éléments à préparer. En effet, ayant choisi de ne pas afficher mon application dans une fenêtre classique, je dois quand même donner la possibilité aux utilisateurs de la réduire et de la fermer. Nous allons donc dessiner une petite croix ainsi qu’un petit tiret.</p>
<p>Avec l’outil rectangle, je dessine un rectangle et lui donne des dimensions de 12 par 5 avec des coins arrondis. Voici ce que j’obtiens :</p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/01/15.jpg"><img class="alignnone size-full wp-image-5569" title="15" src="http://www.flashxpress.net/wp-content/uploads/2011/01/15.jpg" alt="" width="152" height="32" /></a></p>
<p>Pour créer la croix nous allons nous servir de ce trait d&#8217;union. Sélectionnons-le et dupliquons-le (CTRL + C / CTRL + V).</p>
<p>A l’aide de l’Outil de Transformation, faisons pivoter de 45° (donc en maintenant la touche SHIFT pour nous simplifier la tâche) le tiret. Dupliquons ce tiret et faisons le pivoter de 90°. Notre croix est prête.</p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/01/16.jpg"><img class="alignnone size-full wp-image-5570" title="16" src="http://www.flashxpress.net/wp-content/uploads/2011/01/16.jpg" alt="" width="187" height="33" /></a></p>
<p>Nous devons à présent convertir nos deux icônes en symbole. Une fois de plus nous choisirons comme type « Bouton » et nommerons nos symboles respectivement « traitUnion » pour l’icône de réduction de l’application et « croix » pour l’icône de fermeture.</p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/01/17.jpg"><img class="alignnone size-full wp-image-5571" title="17" src="http://www.flashxpress.net/wp-content/uploads/2011/01/17.jpg" alt="" width="449" height="165" /></a></p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/01/18.jpg"><img class="alignnone size-full wp-image-5572" title="18" src="http://www.flashxpress.net/wp-content/uploads/2011/01/18.jpg" alt="" width="449" height="165" /></a></p>
<p>Profitons-en pour attribuer le nom d’occurrence à nos icônes. Utiliser pour chaque icône le nom du symbole.</p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/01/19.jpg"><img class="alignnone size-full wp-image-5573" title="19" src="http://www.flashxpress.net/wp-content/uploads/2011/01/19.jpg" alt="" width="303" height="116" /></a></p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/01/20.jpg"><img class="alignnone size-full wp-image-5574" title="20" src="http://www.flashxpress.net/wp-content/uploads/2011/01/20.jpg" alt="" width="303" height="114" /></a></p>
<p>Pour finaliser nos boutons, ouvrons chacun des deux symboles, et insérons une image clé sur les états « Dessus » et « Abaissé ». Sur l’état « Dessus » changeons la couleur de l’objet. Je vais pour ma part choisir du rouge.</p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/01/21.jpg"><img title="21" src="http://www.flashxpress.net/wp-content/uploads/2011/01/21.jpg" alt="" width="630" /></a></p>
<p>Il ne nous reste plus qu’à positionner les boutons sur la scène.  Pour cela je glisse depuis la bibliothèque une occurrence du MovieClip « Ligne ». Et le positionne juste sous le logo. Je place en suite mes deux icones.</p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/01/22.jpg"><img class="alignnone size-full wp-image-5576" title="22" src="http://www.flashxpress.net/wp-content/uploads/2011/01/22.jpg" alt="" width="351" height="88" /></a></p>
<p>Et voilà, tous nos éléments graphiques sont prêts. Nous allons compiler l’application afin de tester l’interaction sur les boutons.</p>
<p>Nous pouvons supprimer l’occurrence du MovieClip, sauvegarder, aller prendre un café, fumer une cigarette et nous passerons ensuite à la partie code…</p>
<h1>Le code</h1>
<p>Dans cette seconde partie nous allons passer au code. Créons donc un nouveau calque et nommons-le AS.</p>
<p>Nous devons dans un premier temps récupérer notre flux RSS. Pour cela, nous utiliserons un URLLoader. L’URLRequest de l’URLLoader est simplement l’url du flux. Pour la récupérer, cliquons-droit sur le lien « S’abonner au flux RSS » présent en bas du site FlashXPress et sélectionnons « Copier l’adresse du lien ».</p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/01/24.jpg"><img class="alignnone size-full wp-image-5578" title="24" src="http://www.flashxpress.net/wp-content/uploads/2011/01/24.jpg" alt="" width="358" height="57" /></a></p>
<p>Voici l’url que j’obtiens : <a href="http://www.flashxpress.net/feed/">http://www.flashxpress.net/feed/</a></p>
<p>Le code de mon URLLoader est donc :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p5555code34'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p555534"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p5555code34"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> chargeur<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=urlloader%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:urlloader.html"><span style="color: #004993;">URLLoader</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=urlloader%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:urlloader.html"><span style="color: #004993;">URLLoader</span></a><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=urlrequest%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:urlrequest.html"><span style="color: #004993;">URLRequest</span></a><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;http://www.flashxpress.net/feed/&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></pre></td></tr></table></div>

<p>Afin de récupérer le contenu de l’URLLoader une fois qu’il aura fini de le charger, nous devons ajouter un écouteur sur ce dernier pour l’évènement « Event.COMPLETE »:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p5555code35'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p555535"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p5555code35"><pre class="actionscript3" style="font-family:monospace;">chargeur<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">COMPLETE</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">init</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></pre></td></tr></table></div>

<p>Ici j’ai choisi de nommer la fonction “init”.</p>
<p>Cette fonction va avoir plusieurs rôles :</p>
<ul>
<li>lire le RSS</li>
</ul>
<ul>
<li>instancier à chaque fois qu’un article est repéré le MovieClip « Ligne »</li>
</ul>
<ul>
<li>remplir le champ « titreArticle » avec le titre de l’article</li>
</ul>
<ul>
<li>ajouter sur le MovieClip une propriété dynamique urlArticle et la remplir avec l’url de l’article</li>
</ul>
<ul>
<li>ajouter un écouteur sur ce bouton pour que lorsqu’il est cliqué, l’article s’ouvre dans le navigateur</li>
</ul>
<ul>
<li>positionner la ligne</li>
</ul>
<p>Pour faire cela nous utiliserons une boucle.</p>
<p>Créons donc notre fonction :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p5555code36'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p555536"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p5555code36"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">init</span><span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><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>
&nbsp;
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>Nous avons besoin d’un objet de type XML pour stoquer les données présente dans l’URLLoader :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p5555code37'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p555537"><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code" id="p5555code37"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">init</span><span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><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>
&nbsp;
           <span style="color: #6699cc; font-weight: bold;">var</span> monFlux<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=xml%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:xml.html"><span style="color: #004993;">XML</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=xml%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:xml.html"><span style="color: #004993;">XML</span></a><span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">target</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">data</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>Comme source de données pour l’objet XML nous choisissons ici e.target.data. Cela nous renvoie les données présentes dans l’URLLoader « chargeur » du fait que l’écouteur est placé dessus.</p>
<p>Afin de nous assurer que les données arrivent bien a destination, réalisons un petit trace de notre objet XML « monFlux ».</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p5555code38'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p555538"><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code" id="p5555code38"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">init</span><span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><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>
&nbsp;
<span style="color: #6699cc; font-weight: bold;">var</span> monFlux<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=xml%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:xml.html"><span style="color: #004993;">XML</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=xml%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:xml.html"><span style="color: #004993;">XML</span></a><span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">target</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">data</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>monFlux<span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>Exécuter le programme. Rien ne se passe ? Mais si, guettez votre panneau de sortie et attendez quelques secondes…magie, les données envahissent votre petit panneau !</p>
<p>Bien. Si on observe ces données on voit que le titre des articles est contenu dans le nœud <code>&lt;title&gt;</code> et que l’url de notre article ce trouve dans le nœud <code>&lt;link&gt;</code>. Ces deux nœuds sont tous deux contenus dans le nœud <code>&lt;item&gt;</code>. Le nœud <code>&lt;item&gt;</code> quant à lui se trouve dans le nœud <code>&lt;channel&gt;</code>, lui-même étant dans le nœud <code>&lt;xml&gt;</code>.</p>
<p>Voici une version quelques peu raccourcie du contenu de l’objet XML :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p5555code39'); return false;">View Code</a> XML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p555539"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
</pre></td><td class="code" id="p5555code39"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;rss</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;2.0&quot;</span> <span style="color: #000066;">xmlns:content</span>=<span style="color: #ff0000;">&quot;http://purl.org/rss/1.0/modules/content/&quot;</span> <span style="color: #000066;">xmlns:wfw</span>=<span style="color: #ff0000;">&quot;http://wellformedweb.org/CommentAPI/&quot;</span> …<span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;channel<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
…
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;item<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Graphic Live Session à Meudon-la-Forêt<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;link<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>http://feedproxy.google.com/~r/flashxpress/~3/O0doqsfPls8/<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/link<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;comments<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>http://www.flashxpress.net/news/graphic-live-session-a-meudon-la-foret/#comments<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/comments<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;pubDate<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Tue, 25 Jan 2011 14:35:51 +0000<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/pubDate<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dc:creator<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Olivier<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dc:creator<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;category<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><span style="color: #339933;">&lt;![CDATA[News]]&gt;</span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/category<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;guid</span> <span style="color: #000066;">isPermaLink</span>=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>http://www.flashxpress.net/?p=5543<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/guid<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
…
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/item<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/channel<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/rss<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>Pour récupérer notre titre nous devrons donc faire : channel.item.title</p>
<p>Et pour le lien : channel.item.link</p>
<p>Créons donc notre boucle. Celle-ci va devoir parcourir chaque nœud item et effectuer pour chacun d’eux toutes les tâches décrite ci-dessus.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p5555code40'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p555540"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code" id="p5555code40"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">init</span><span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><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>
&nbsp;
<span style="color: #6699cc; font-weight: bold;">var</span> monFlux<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=xml%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:xml.html"><span style="color: #004993;">XML</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=xml%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:xml.html"><span style="color: #004993;">XML</span></a><span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">target</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">data</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
           <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><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a><span style="color: #000066; font-weight: bold;">;</span> i<span style="color: #000066; font-weight: bold;">&lt;</span>monFlux<span style="color: #000066; font-weight: bold;">.</span>channel<span style="color: #000066; font-weight: bold;">.</span>item<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">length</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><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>
&nbsp;
           <span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>Commençons par essayer de récupérer dans le panneau de sortie tous les titres des articles :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p5555code41'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p555541"><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code" id="p5555code41"><pre class="actionscript3" style="font-family:monospace;"><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><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a><span style="color: #000066; font-weight: bold;">;</span> i<span style="color: #000066; font-weight: bold;">&lt;</span>monFlux<span style="color: #000066; font-weight: bold;">.</span>channel<span style="color: #000066; font-weight: bold;">.</span>item<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">length</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><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>
&nbsp;
           <span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>monFlux<span style="color: #000066; font-weight: bold;">.</span>channel<span style="color: #000066; font-weight: bold;">.</span>item<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span>title<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>Cela fonctionne. En effet à chaque itération de la boucle « i » s’incrémentant, et récupérant le titre présent dans le nœud item[i], on arrive a tracer le nœud titre de chacun des nœuds item. Chaque nœud item correspondant a un article, on récupère bien le titre de tous les articles.</p>
<p>Bien. Supprimons ce trace, et maintenant nous voulons qu’à chaque itération de la boucle une occurrence de notre MovieClip soit instanciée et qu’elle soit remplie.</p>
<p>Dans notre boucle on crée donc une instance :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p5555code42'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p555542"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p5555code42"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> ligneArticle<span style="color: #000066; font-weight: bold;">:</span>Ligne = <span style="color: #0033ff; font-weight: bold;">new</span> Ligne<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></pre></td></tr></table></div>

<p>On va remplir le champ titre juste après avec les informations du RSS :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p5555code43'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p555543"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p5555code43"><pre class="actionscript3" style="font-family:monospace;">ligneArticle<span style="color: #000066; font-weight: bold;">.</span>titreArticle<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> = monFlux<span style="color: #000066; font-weight: bold;">.</span>channel<span style="color: #000066; font-weight: bold;">.</span>item<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span>title<span style="color: #000066; font-weight: bold;">;</span></pre></td></tr></table></div>

<p>Rappelez-vous, titreArticle c’est le nom d’occurrence du champ texte dans le MovieClip « Ligne ».</p>
<p>On crée une propriété urlArticle sur le MovieClip de la ligne en cour de création :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p5555code44'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p555544"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p5555code44"><pre class="actionscript3" style="font-family:monospace;">ligneArticle<span style="color: #000066; font-weight: bold;">.</span>urlArticle = monFlux<span style="color: #000066; font-weight: bold;">.</span>channel<span style="color: #000066; font-weight: bold;">.</span>item<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">link</span><span style="color: #000066; font-weight: bold;">;</span></pre></td></tr></table></div>

<p>On ajoute un écouteur sur le click du bouton de la ligne pour qu’au clic il ouvre la navigateur et affiche la page de l’article :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p5555code45'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p555545"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p5555code45"><pre class="actionscript3" style="font-family:monospace;">ligneArticle<span style="color: #000066; font-weight: bold;">.</span>btnLire<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=mouseevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:mouseevent.html"><span style="color: #004993;">MouseEvent</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">CLICK</span><span style="color: #000066; font-weight: bold;">,</span> ouvrirArticle<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></pre></td></tr></table></div>

<p>Nous créons la fonction ouvrir article sous la fonction init :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p5555code46'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p555546"><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code" id="p5555code46"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #339966; font-weight: bold;">function</span> ouvrirArticle<span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=mouseevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:mouseevent.html"><span style="color: #004993;">MouseEvent</span></a><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>
&nbsp;
           <span style="color: #004993;">navigateToURL</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=urlrequest%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:urlrequest.html"><span style="color: #004993;">URLRequest</span></a><span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">target</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">parent</span><span style="color: #000066; font-weight: bold;">.</span>urlArticle<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>Cette fonction contient un simple navigateToURL. L’URLRequest à pour valeur e.target(donc le bouton).parent(le MovieClip en somme).urlArticle(la propriété dynamique crée dans la boucle) .</p>
<p>Bien. Nous pouvons à présent nous occuper de placer notre occurrence sur la scène.</p>
<p>Nous lui donnons une position en x de 0, et en y de la hauteur du MovieClip * i. Comme à la première itération de la boucle i à pour valeur 0, la première ligne ce placera alors à 0*50. A la seconde itération, i aura une valeur de 1 donc le Movie clip sera placé à 50 pixels en y et ainsi de suite. A cela nous devons ajouter un décalage de la hauteur du logo car celui-ci se trouve en haut de la liste plus une petite marge. J’ajouterais donc 35. J’aimerais aussi laisser 1 pixel entre chaque MovieClip. J’ajout donc 1 à la hauteur du Movie clip.</p>
<p>En synthèse :</p>
<p>MovieClip.y = (i * (hauteur du MovieClip + 1(pour espacer de 1))) + 35 (pour laisser la place au logo).</p>
<p>Voilà tout ce charabia traduit en AS3 :p :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p5555code47'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p555547"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p5555code47"><pre class="actionscript3" style="font-family:monospace;">ligneArticle<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
ligneArticle<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = <span style="color: #000000;">&#40;</span>i<span style="color: #000066; font-weight: bold;">*</span><span style="color: #000000; font-weight:bold;">51</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #000000; font-weight:bold;">35</span><span style="color: #000066; font-weight: bold;">;</span></pre></td></tr></table></div>

<p>On l’ajoute à la liste d’affichage :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p5555code48'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p555548"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p5555code48"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>ligneArticle<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></pre></td></tr></table></div>

<p>Voici donc le code final de notre boucle :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p5555code49'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p555549"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre></td><td class="code" id="p5555code49"><pre class="actionscript3" style="font-family:monospace;"><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><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a><span style="color: #000066; font-weight: bold;">;</span> i<span style="color: #000066; font-weight: bold;">&lt;</span>monFlux<span style="color: #000066; font-weight: bold;">.</span>channel<span style="color: #000066; font-weight: bold;">.</span>item<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">length</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><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>
&nbsp;
           <span style="color: #6699cc; font-weight: bold;">var</span> ligneArticle<span style="color: #000066; font-weight: bold;">:</span>Ligne = <span style="color: #0033ff; font-weight: bold;">new</span> Ligne<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
           ligneArticle<span style="color: #000066; font-weight: bold;">.</span>titreArticle<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> = monFlux<span style="color: #000066; font-weight: bold;">.</span>channel<span style="color: #000066; font-weight: bold;">.</span>item<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span>title<span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
           ligneArticle<span style="color: #000066; font-weight: bold;">.</span>urlArticle = monFlux<span style="color: #000066; font-weight: bold;">.</span>channel<span style="color: #000066; font-weight: bold;">.</span>item<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">link</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
           ligneArticle<span style="color: #000066; font-weight: bold;">.</span>btnLire<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=mouseevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:mouseevent.html"><span style="color: #004993;">MouseEvent</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">CLICK</span><span style="color: #000066; font-weight: bold;">,</span> ouvrirArticle<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
           ligneArticle<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
           ligneArticle<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = <span style="color: #000000;">&#40;</span>i<span style="color: #000066; font-weight: bold;">*</span><span style="color: #000000; font-weight:bold;">51</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #000000; font-weight:bold;">35</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
           <span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>ligneArticle<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>Compilons. Ça fonctionne ! Merveilleux. Si on clique sur l’un des boutons lire, le navigateur s’ouvre a la page de l’article relatif au bouton cliqué !</p>
<p>Alors peut être, selon la hauteur de vos éléments (pour ne pas dire « si vous avez utilisez les mêmes dimensions que moi » ^_^ ‘), une partie de votre application sera tronquée (vers le bas). Pour remédier à cela, changez les dimensions de la scène de Flash. Pour ma par j’ai fini par mettre 500px de large par 1000px de haut.</p>
<p>Bien. Nous sommes presque au bout. Il ne nous reste plus qu’à faire une fonction pour permettre le drag de l’application, une pour la réduire dans la barre des tâches ou le dock selon le système d’exploitation et une pour la fermer.</p>
<p>Commençons par nous occuper du drag.</p>
<p>Ajoutons un écouteur sur le stage et créons la fonction dragAPP sous la fonction ouvrirArticle:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p5555code50'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p555550"><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code" id="p5555code50"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=mouseevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:mouseevent.html"><span style="color: #004993;">MouseEvent</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">MOUSE_DOWN</span><span style="color: #000066; font-weight: bold;">,</span> dragAPP<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #339966; font-weight: bold;">function</span> dragAPP<span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=mouseevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:mouseevent.html"><span style="color: #004993;">MouseEvent</span></a><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>
&nbsp;
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>Dans la fonction dragAPP nous allons utilizer la methode startMove() de la class nativeWindows afin de drager notre application.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p5555code51'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p555551"><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code" id="p5555code51"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #339966; font-weight: bold;">function</span> dragAPP<span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=mouseevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:mouseevent.html"><span style="color: #004993;">MouseEvent</span></a><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>
&nbsp;
           <span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span>nativeWindow<span style="color: #000066; font-weight: bold;">.</span>startMove<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>Si l’on compile et que l’on drag l’application en la prenant par le logo ou tout autre point, on arrive à la déplacer. Formidable.</p>
<p>Maintenant la fonction pour la réduire dans le dock ou dans la barre des tâches. On doit ajouter un écouteur sur l’icône réduire et créer la fonction minimizeAPP:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p5555code52'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p555552"><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code" id="p5555code52"><pre class="actionscript3" style="font-family:monospace;">traitUnion<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=mouseevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:mouseevent.html"><span style="color: #004993;">MouseEvent</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">CLICK</span><span style="color: #000066; font-weight: bold;">,</span> minimizeAPP<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #339966; font-weight: bold;">function</span> minimizeAPP<span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=mouseevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:mouseevent.html"><span style="color: #004993;">MouseEvent</span></a><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>
&nbsp;
           <span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span>nativeWindow<span style="color: #000066; font-weight: bold;">.</span>minimize<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>Nous faisons de nouveau appel à la classe nativeWindows, mais cette fois ci à sa méthode minimize() afin d’effectuer cette action.</p>
<p>Ajoutons un écouteur sur le bouton de fermeture de l’application et créons la fonction closeAPP :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p5555code53'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p555553"><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code" id="p5555code53"><pre class="actionscript3" style="font-family:monospace;">croix<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=mouseevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:mouseevent.html"><span style="color: #004993;">MouseEvent</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">CLICK</span><span style="color: #000066; font-weight: bold;">,</span> closeAPP<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #339966; font-weight: bold;">function</span> closeAPP<span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=mouseevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:mouseevent.html"><span style="color: #004993;">MouseEvent</span></a><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>
&nbsp;
           NativeApplication<span style="color: #000066; font-weight: bold;">.</span>nativeApplication<span style="color: #000066; font-weight: bold;">.</span>exit<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>Compilons et testons.</p>
<p>L’application est fonctionnelle. Nous pouvons donc préparer le fichier .air que vous distribuerez.</p>
<p>Dans le panneau des propriétés, cliquons sur le bouton « Modifier » des Paramètres d’Adobe AIR 2.</p>
<p>Dans l’onglet « Général » saisissons nos informations.</p>
<p>Notez que pour ID APP la convention veux que l’on retourne son nom de domaine et, qu’après un slash, on mette le nom de l’application.</p>
<p>A présent nous allons configurer l’icône de notre application. Pour cela, rendez-vous dans l’onglet « Icônes ». Vous devez avoir au préalable créé 4 tailles d’icône. Une en 16*16px, une autre en 32*32px, une troisième en 48*48 et une dernière en 128*128px. Indiquons donc en cliquant sur le petit bouton parcourir la path vers l’icône correspondante à la taille sélectionnée.</p>
<p>Pour terminer, rendons nous dans l’onglet « Signature ».</p>
<p>Dans celui-ci nous allons devoir cibler un certificat au format p12 et saisir son mot de passe.</p>
<p>Dans le cas ou vous n’avez pas de certificat, vous pouvez en générer un en cliquant sur le bouton « Créer » et en remplissant le champ de la fenêtre qui viens de s’ouvrir.</p>
<p>Cliquons maintenant sur le bouton « Publier ».</p>
<p>Notre fichier AIR est généré et prêt à être distribué.</p>
<p>Le but de ce didacticiel est atteint, je pense donc que nous arrivons au terme de ce tuto.</p>
<p>En espérant qu’il vous aura servi.</p>
<p>Amicalement,</p>
<p>Olivier.</p>
<p><a href="http://www.flashxpress.net/wp-content/uploads/2011/01/LecteurRSS-app.zip">Télécharger les sources</a> <span style="text-decoration: underline;"><span style="color: #ff0000;">! Flash CS5 est nécessaire pour ouvrir le .fla !</span><br />
</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashxpress.net/ressources-flash/creation-d%e2%80%99un-lecteur-de-flux-rss-en-air-avec-flash/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

