<?xml version="1.0" encoding="ISO-8859-1"?>

<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
	<channel>
		<title>FlashFocus.nl - Weblogs</title>
		<link>http://www.flashfocus.nl/forum/blog.php</link>
		<description><![CDATA[De Beste Nederlandstalige Flash Resource Site - FlashFocus.nl Download hier je Flash files (fla's) om van te leren en lees hier het laatste Flash- en webdevelopment nieuws!]]></description>
		<language>nl</language>
		<lastBuildDate>Sat, 04 Feb 2012 16:39:00 GMT</lastBuildDate>
		<generator>vBulletin</generator>
		<ttl>60</ttl>
		<image>
			<url>http://flashfocus.nl/forum/images/misc/rss.jpg</url>
			<title>FlashFocus.nl - Weblogs</title>
			<link>http://www.flashfocus.nl/forum/blog.php</link>
		</image>
		<item>
			<title>Waarom reageert niemand op mijn vraag?</title>
			<link>http://www.flashfocus.nl/forum/blog.php?b=46</link>
			<pubDate>Wed, 12 Oct 2011 09:19:17 GMT</pubDate>
			<description>Er worden wel eens vragen gesteld op FlashFocus, waar niemand een antwoord op geeft. Je kunt dan de vraag stellen: waarom reageert niemand? 
 
Het komt gelukkig maar zelden voor dat niemand het antwoord weet, of je in ieder geval flink op weg kan helpen. FlashFocus kent een aantal fanatieke, intelligente leden die graag met je meedenken wanneer je vast zit. 
 
Toch komt het dus ook geregeld voor dat er niemand reageert op een gestelde vraag, wat frustrerend kan zijn voor degene die de vraag...</description>
			<content:encoded><![CDATA[<div>Er worden wel eens vragen gesteld op FlashFocus, waar niemand een antwoord op geeft. Je kunt dan de vraag stellen: waarom reageert niemand?<br />
<br />
Het komt gelukkig maar zelden voor dat niemand het antwoord weet, of je in ieder geval flink op weg kan helpen. FlashFocus kent een aantal fanatieke, intelligente leden die graag met je meedenken wanneer je vast zit.<br />
<br />
Toch komt het dus ook geregeld voor dat er niemand reageert op een gestelde vraag, wat frustrerend kan zijn voor degene die de vraag stelt: je loopt vast en wilt verder, komt er zelf niet uit en niemand wil je helpen.<br />
<br />
De redenen voor niet reageren kunnen vrij uiteenlopend zijn. Vaak ligt de reden bij de vraagstelling, en daar wil ik het kort over hebben: <b>zorg ervoor dat je een vraag stelt die gaat over een probleem op je eigen niveau of net daarboven</b>. Daarnaast is het belangrijk dat je de vraag goed stelt, dus zoveel mogelijk informatie geeft over de situatie, je kennis, de foutmeldingen, enzovoorts.<br />
<br />
De vragen &quot;<i>Hoe maak ik dit?</i>&quot; en &quot;<i>Waarom werkt dit niet?</i>&quot; zijn veel te breed en missen teveel belangrijke informatie. Ga bij het stellen van je vraag een aantal stappen bij langs: wat is het probleem, wat heb je geprobeerd, welke foutmeldingen krijg je, welke verschillende situaties heb je geprobeerd, welke informatie kreeg je terug bij traces op bepaalde plekken, en ga zo maar door. Wanneer je dit allemaal bij je vraag hebt opgenomen, is er al een kans dat je het probleem zelf ineens ziet. Zo niet, dan post je en kan een behulpzaam FlashFocus-lid snel zien wat niet werkt, wat er geprobeerd is en waar het probleem dan nog kan liggen.<br />
<br />
<font size="3"><b><font face="Courier New">TEMPLATES</font></b></font><br />
Een onderdeel wat speciale aandacht verdient, zijn vragen over templates. Mensen die niet zoveel verstand hebben van Flash/Actionscript, kopen wel eens een template of downloaden er gratis een. Een in mijn ogen goede oplossing, je krijgt een mooie website of applicatie, voor weinig geld en het kost je weinig moeite. Goede templates zijn zo gemaakt dat de <b>content</b> makkelijk aan te passen is. Je kunt teksten aanpassen, grafische onderdelen makkelijk vervangen, menu's aanvullen en ga zo maar door.<br />
<br />
Belangrijk is om te onthouden dat een template daar stopt. Er zit een grens op hoeveel content er aan te passen is. En dan hebben we het nog niet over <b>functionaliteit</b>. Je template kan iets, niets meer, niets minder. Wanneer je een website template gebruikt en besluit dat je er een gastenboek in wilt hebben, dan zul je die er zelf in moeten bouwen. Ook geen probleem, zolang je maar weet wat je doet. Die kans is echter vrij klein als je de template in de eerste instantie gebruikt omdat je kennis van Flash/Actionscript niet toereikend is om zelf iets te maken.<br />
<br />
Maar al te vaak proberen mensen toch een template aan te passen. Wederom geen ramp, ik denk zelfs dat het wel een goede manier is om meer te leren over Flash/Actionscript. Maar vergeet hierbij niet dat je iets aan gaat pakken waar jezelf geen verstand van hebt. De meest triviale zaken zullen je ontgaan. Daarnaast is een vraag stellen lastig als je zelf niet kunt aangeven waar het mis gaat en hoe je code in elkaar zit, aangezien je het niet zelf geschreven hebt. Op dat moment vraag je aan iemand die je wil helpen erg veel. Diegene moet de template induiken en uitpluizen hoe deze in elkaar steekt. Dit is érg veel werk, en valt in mijn ogen onder &quot;<i>kant en klare code vragen</i>&quot;, wat volgens de regels niet mag.<br />
<br />
Ik heb dit weblog item geschreven, omdat het herhaaldelijk uitleggen aan mensen dat ze niet op een antwoord hoeven te wachten, begon te vervelen. Ik hoop dat, als dit verhaal bij jou van toepassing is, je je niet laat ontmoedigen om met Flash bezig te gaan. Wil je een complex, niet zelf geschreven stuk code aanpassen, begin dan bij de basis. Begin bij een stuk wat je nog snapt, en ga verder vanaf daar. Je loopt dan tegen vragen aan die op je niveau of net daarboven zitten, en zult in staat zijn daar heldere vragen over te stellen. Zulke vragen krijgen binnen een dag, of zelfs een paar uur of minuten, vaak al een antwoord.</div>

]]></content:encoded>
			<dc:creator>e.l.dam</dc:creator>
			<guid isPermaLink="true">http://www.flashfocus.nl/forum/blog.php?b=46</guid>
		</item>
		<item>
			<title>Tic-Tac-Toe Tutorial</title>
			<link>http://www.flashfocus.nl/forum/blog.php?b=45</link>
			<pubDate>Thu, 11 Aug 2011 14:40:56 GMT</pubDate>
			<description>Een tijdje terug heb ik een tutorial geschreven over hoe je een boter-kaas-en-eieren spel kunt schrijven. Geen hoogstaand iets, maar zeker de moeite waard voor iemand die net begint met AS3 en iets wil leren over het gebruik van een document class en het maken van je eigen classes. 
 
De tutorial bekijken doe je hier (http://active.tutsplus.com/tutorials/games/build-an-intelligent-tic-tac-toe-game-with-as3/).</description>
			<content:encoded><![CDATA[<div>Een tijdje terug heb ik een tutorial geschreven over hoe je een boter-kaas-en-eieren spel kunt schrijven. Geen hoogstaand iets, maar zeker de moeite waard voor iemand die net begint met AS3 en iets wil leren over het gebruik van een document class en het maken van je eigen classes.<br />
<br />
De tutorial bekijken doe je <a href="http://active.tutsplus.com/tutorials/games/build-an-intelligent-tic-tac-toe-game-with-as3/" target="_blank">hier</a>.</div>

]]></content:encoded>
			<dc:creator>e.l.dam</dc:creator>
			<guid isPermaLink="true">http://www.flashfocus.nl/forum/blog.php?b=45</guid>
		</item>
		<item>
			<title>Debuggen in FlashDevelop</title>
			<link>http://www.flashfocus.nl/forum/blog.php?b=44</link>
			<pubDate>Sun, 20 Feb 2011 09:58:35 GMT</pubDate>
			<description>Sinds enige tijd heeft FlashDevelop support voor het echte debug werk. Dus niet debuggen met alleen een trace, maar met breakpoints, watches, locals, stack en een echte profiler. 
Afgelopen week heb ik voor mezelf uitgezocht hoe het precies werkt aangezien het echt heel veel ontwikkeltijd scheelt als je goed kan testen/debuggen.zeker als je eenmaal met Visual Studio hebt gewerkt 
Toen ik het aan het uitzoeken was viel me op dat er veel dingen fout kunnen gaan en er niet echt veel resources zijn...</description>
			<content:encoded><![CDATA[<div>Sinds enige tijd heeft FlashDevelop support voor het echte debug werk. Dus niet debuggen met alleen een trace, maar met breakpoints, watches, locals, stack en een echte profiler.<br />
Afgelopen week heb ik voor mezelf uitgezocht hoe het precies werkt aangezien het echt heel veel ontwikkeltijd scheelt als je goed kan testen/debuggen.<font size="1">zeker als je eenmaal met Visual Studio hebt gewerkt</font><br />
Toen ik het aan het uitzoeken was viel me op dat er veel dingen fout kunnen gaan en er niet echt veel resources zijn waar het goed staat uitgelegd. <br />
Hieronder een beknopte uitleg hoe je FlashDevelop moet instellen om goed te kunnen debuggen.<br />
<br />
<b>Voor je begint</b><br />
Voor je alles aan de praat kan krijgen moet je eerst de goede tools gedownload hebben. :)<br />
- <a href="http://opensource.adobe.com/wiki/display/flexsdk/download?build=4.1.0.16076&amp;pkgtype=1" target="_blank">download de Flex sdk 4.1</a><br />
- <a href="http://kb2.adobe.com/cps/142/tn_14266.html" target="_blank">download de laatste versie FlashPlayer Debugger (de link bevat alle players)</a><font size="1">download het zipje van 8 feb 2011</font><br />
- <a href="http://www.flashdevelop.org/community/viewtopic.php?f=11&amp;t=7943&amp;sid=2d88a0197bf8a8bb547897b0a03a542e" target="_blank">download de allerlaatste build van FlashDevelop 3.3.4</a><br />
<br />
<b>Installatie Flex</b><br />
De Flex sdk kan je uitpakken en op een locatie naar keuze zetten. Als je FlashBuilder hebt kan je de sdk het beste daarin zetten. In het mapje sdk's maak je een folder aan 4.1.0 en daarin kopieer je de sdk. <br />
Voorbeeld: <i>C:\Program Files (x86)\Adobe\Adobe Flash Builder 4\sdks\4.1.0\</i><br />
Als je geen FlashBuilder gebruikt kan je de sdk gewoon ergens anders neerzetten. <br />
Voorbeeld:<br />
<i>C:\Program Files(x86)\Adobe\Flexsdks\4.1.0\</i><br />
Het Flex framework staat klaar voor gebruik volgende stap is de FlashPlayers.<br />
<br />
<b>Installatie FlashPlayer</b><br />
In het zipje met de FlashPlayers zitten alle players. Er van uitgaande dat je de laatste player geïnstalleerd hebt (FlashPlayer 10.2) hoef je alleen de debug players te installeren. In het debug mapje zitten alle debug players. Het ligt eraan hoe je straks gaat debuggen, maar waarschijnlijk doe je dit via een standalone player. Maak een nieuw mapje aan in de player map, genaamd <i>"10.2</i>" en daarin maak je een mapje win, vervolgens kopieer je de player die eindigt op "win_sa_debug". <br />
<i>Voorbeeld: C:\Program Files(x86)\Adobe\Flex\4.1.0\runtimes\player\10.2\w  in</i><br />
Daarna rename je het bestand naar<i>"FlashDebugger.exe"</i>.<br />
<br />
<b>Configureer FlashDevelop</b><br />
Nadat je FlashDevelop hebt geupdate moet je een aantal dingen instellen.<br />
Druk op F10 waardoor je in het instellingen scherm komt.<br />
Ga naar het tabje <i>"FlashDebugger"</i>. Vervolgens stel je een source path in naar de <i>FlashDebugger.exe</i> die je net vervangen hebt in de Flex sdk. In het tabje "FlashDebugger" kan je nog een aantal dingen instellen zoals shortcuts voor next step, step into &amp; finish en een aantal instellingen wat er gebeurt als je gaat debuggen. <font size="1">Ik heb nog niet de perfecte knoppen combo gevonden aangezien er niet echt een overzicht is van de shortcuts van FlashDevelop. Deze hou je nog van me te goed.<br />
</font><br />
Mocht je nog niet eerder mbv FlashDevelop gecompileerd hebben(dus altijd via Flash/Flashbuilder) kan het zijn dat de je de FlashViewer nog moet instellen. <br />
Ga in het configuratiescherm naar het tabje <i>"FlashViewer"</i> en vul het path in naar een FlashDebugPlayer. <br />
<i>Voorbeeld: C:\Program Files(x86)\Adobe\Flex\4.1.0\runtimes\player\10.2\w  in</i><br />
<br />
Nu ben je klaar met de instellingen en kan je beginnen met debuggen. :D<br />
Persoonlijk gebruikte ik altijd Flash om mijn projecten te compilen(dus liet FlashDevelop Flash openen die het vervolgens compileerde). Als je FlashDevelop wilt gebruiken om te debuggen kan dat niet meer en stiekem is dat beter ook. FlashDevelop dwingt je om met swc-jes te gaan werken waardoor een designer en een programmeur makkelijker los van elkaar kunnen werken. Tweede voordeel is dat het compile een stuk sneller gaat en je hoeft een programma minder te draaien.<br />
<br />
Ik hoop dat alles duidelijk is. Als er behoefte aan is zal ik mijn post nog update met screenies.</div>

]]></content:encoded>
			<dc:creator>PsK</dc:creator>
			<guid isPermaLink="true">http://www.flashfocus.nl/forum/blog.php?b=44</guid>
		</item>
		<item>
			<title>Motion Tracking in ActionScript 3.0</title>
			<link>http://www.flashfocus.nl/forum/blog.php?b=43</link>
			<pubDate>Sat, 22 Jan 2011 13:20:57 GMT</pubDate>
			<description>Hallo FlashFocus! 
 
Vele dagen geleden heb ik ergens op ons forum beloofd te bloggen over een schoolproject dat ik een aantal dagen geleden heb afgerond. Het was het zogenaamde profielwerkstuk, een soort verdieping op een bepaald onderwerp (vrije keuze) waar je dus een verslag van moet schrijven. In mijn geval was het onderwerp motion-tracking, met als vak informatica. En daarbij moet natuurlijk geprogrammeerd worden! 
 
Ok, laten we dan eerst eens beginnen met een filmpje van het...</description>
			<content:encoded><![CDATA[<div>Hallo FlashFocus!<br />
<br />
Vele dagen geleden heb ik ergens op ons forum beloofd te bloggen over een schoolproject dat ik een aantal dagen geleden heb afgerond. Het was het zogenaamde profielwerkstuk, een soort verdieping op een bepaald onderwerp (vrije keuze) waar je dus een verslag van moet schrijven. In mijn geval was het onderwerp motion-tracking, met als vak informatica. En daarbij moet natuurlijk geprogrammeerd worden!<br />
<br />
Ok, laten we dan eerst eens beginnen met een filmpje van het eindresultaat. "Waarom een filmpje?" hoor ik u vragen. Nou, omdat dit project nogal wat finetuning heeft voordat het op elke PC (of Mac, voor de andersdenkenden onder ons ;)) werkt. Daarbij gaat het vooral over de instellingen van je webcam, die weer in verband staan met de verlichting in de kamer waar je mijn programmeersel draait. Daarom zal het dus niet (meteen) bij iedereen werken, dus een filmpje leek me op zijn plaats. Voila:<br />
<br />
<iframe title="YouTube video player" class="youtube-player" type="text/html" src="http://www.youtube.com/embed/4v3U6s12xM4" allowfullscreen="" frameborder="0" height="390" width="640"></iframe><br />
<br />
P.S.: Instructies voor gebruik: hoofd draaien en niet op de rommel letten.<br />
<br />
Ok, zoals jullie zien werkt het redelijk. Even wat uitleg:<br />
<br />
Om te beginnen werkt mijn motion-tracking op basis van RGB-kleuren. Dus een object dat volledig rood is, kan worden getrackt, net als een blauw en groen ding. Iets dat een combinatie van die twee kleuren is, werkt niet, omdat dat in mijn (simpele) programma voor ruis zou zorgen. <br />
<br />
Daarna worden door middel van de handige BitmapData klasse in ActionScript 3.0 nog wat extra dingen gefilterd, en wordt er een rechthoek gemaakt van alle plekken waar zich rood, groen of blauw bevindt. Vervolgens tekenen we die rechthoek ook echt op het scherm en we hebben (min of meer) motion-tracking voor elkaar.<br />
<br />
Voor de duidelijkheid, hier eerst maar eens de sourcecode:<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">ActionScript 3 Code:</div>
	<pre class="alt2" style="margin:0px; padding:5px; border: 1px solid #B1B6C2; width:700px; height:516px; overflow:auto"><div dir="ltr" style="text-align:left;"><div class="actionscript3" style="font-family:monospace;"><pre><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: #000000; font-weight: bold;">.*;</span>	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.media</span><span style="color: #000000; font-weight: bold;">.*;</span>	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span><span style="color: #000000; font-weight: bold;">.*;</span>	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.geom</span><span style="color: #000000; font-weight: bold;">.*;</span>	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.filters</span><span style="color: #000000; font-weight: bold;">.</span><a target="_blank" href="http://www.google.com/search?q=colormatrixfilter%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:colormatrixfilter.html"><span style="color: #004993;">ColorMatrixFilter</span></a><span style="color: #000000; font-weight: bold;">;</span>		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> MotionTracker <span style="color: #0033ff; font-weight: bold;">extends</span> <a target="_blank" href="http://www.google.com/search?q=sprite%20inurl:http://livedocs.adobe.com/flex/3/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> cam<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=camera%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:camera.html"><span style="color: #004993;">Camera</span></a><span style="color: #000000; 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: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=video%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:video.html"><span style="color: #004993;">Video</span></a><span style="color: #000000; font-weight: bold;">;</span>		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> videoHolder<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=movieclip%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:movieclip.html"><span style="color: #004993;">MovieClip</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a target="_blank" href="http://www.google.com/search?q=movieclip%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:movieclip.html"><span style="color: #004993;">MovieClip</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> holder<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=movieclip%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:movieclip.html"><span style="color: #004993;">MovieClip</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a target="_blank" href="http://www.google.com/search?q=movieclip%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:movieclip.html"><span style="color: #004993;">MovieClip</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> graph<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=movieclip%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:movieclip.html"><span style="color: #004993;">MovieClip</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a target="_blank" href="http://www.google.com/search?q=movieclip%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:movieclip.html"><span style="color: #004993;">MovieClip</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> bmd<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=bitmapdata%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:bitmapdata.html"><span style="color: #004993;">BitmapData</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a target="_blank" href="http://www.google.com/search?q=bitmapdata%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:bitmapdata.html"><span style="color: #004993;">BitmapData</span></a><span style="color: #000000;">&#40;</span>550<span style="color: #000000; font-weight: bold;">,</span> 400<span style="color: #000000; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000000; font-weight: bold;">,</span> 0x000000<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> bm<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=bitmap%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:bitmap.html"><span style="color: #004993;">Bitmap</span></a><span style="color: #000000; font-weight: bold;">;</span>				<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> allfilter<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=colormatrixfilter%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:colormatrixfilter.html"><span style="color: #004993;">ColorMatrixFilter</span></a><span style="color: #000000; font-weight: bold;">;</span>		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> allcmx<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=array%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:array.html"><span style="color: #004993;">Array</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span>		<a target="_blank" href="http://www.google.com/search?q=array%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:array.html"><span style="color: #004993;">Array</span></a><span style="color: #000000;">&#40;</span>1<span style="color: #000000; font-weight: bold;">,-</span>1<span style="color: #000000; font-weight: bold;">,-</span>1<span style="color: #000000; font-weight: bold;">,</span>0<span style="color: #000000; font-weight: bold;">,</span>		0<span style="color: #000000; font-weight: bold;">,-</span>1<span style="color: #000000; font-weight: bold;">,</span>1<span style="color: #000000; font-weight: bold;">.</span>5<span style="color: #000000; font-weight: bold;">,-</span>1<span style="color: #000000; font-weight: bold;">,</span>		0<span style="color: #000000; font-weight: bold;">,</span>0<span style="color: #000000; font-weight: bold;">,-</span>1<span style="color: #000000; font-weight: bold;">,-</span>1<span style="color: #000000; font-weight: bold;">,</span>		1<span style="color: #000000; font-weight: bold;">,</span>0<span style="color: #000000; font-weight: bold;">,</span>0<span style="color: #000000; font-weight: bold;">,</span>0<span style="color: #000000; font-weight: bold;">,</span>		0<span style="color: #000000; font-weight: bold;">,</span>0<span style="color: #000000; font-weight: bold;">,</span>1<span style="color: #000000; font-weight: bold;">,</span>0<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>				<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> trackingRed<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=boolean%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:boolean.html"><span style="color: #004993;">Boolean</span></a> = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000000; font-weight: bold;">;</span>				<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> oldRedX<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a target="_blank" href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> oldRedY<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a target="_blank" href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> deltaRedX<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a target="_blank" href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> deltaRedY<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a target="_blank" href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>				<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> tekstveld<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=textfield%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:textfield.html"><span style="color: #004993;">TextField</span></a><span style="color: #000000; font-weight: bold;">;</span>		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> MotionTracker<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; 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 target="_blank" href="http://www.google.com/search?q=video%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:video.html"><span style="color: #004993;">Video</span></a><span style="color: #000000;">&#40;</span>550<span style="color: #000000; font-weight: bold;">,</span>400<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>			cam = <a target="_blank" href="http://www.google.com/search?q=camera%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:camera.html"><span style="color: #004993;">Camera</span></a><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">getCamera</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>			cam<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">setMode</span><span style="color: #000000;">&#40;</span>550<span style="color: #000000; font-weight: bold;">,</span>400<span style="color: #000000; font-weight: bold;">,</span>30<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>			video<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">attachCamera</span><span style="color: #000000;">&#40;</span>cam<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>			videoHolder<span style="color: #000000; 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: #000000; font-weight: bold;">;</span>			bm = <span style="color: #0033ff; font-weight: bold;">new</span> <a target="_blank" href="http://www.google.com/search?q=bitmap%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:bitmap.html"><span style="color: #004993;">Bitmap</span></a><span style="color: #000000;">&#40;</span>bmd<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>			holder<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>bm<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>			<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>holder<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>			<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>graph<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>						allfilter = <span style="color: #0033ff; font-weight: bold;">new</span> <a target="_blank" href="http://www.google.com/search?q=colormatrixfilter%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:colormatrixfilter.html"><span style="color: #004993;">ColorMatrixFilter</span></a><span style="color: #000000;">&#40;</span>allcmx<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>						<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a target="_blank" href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">ENTER_FRAME</span><span style="color: #000000; font-weight: bold;">,</span> <span style="color: #004993;">loop</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>			holder<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a target="_blank" href="http://www.google.com/search?q=mouseevent%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:mouseevent.html"><span style="color: #004993;">MouseEvent</span></a><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">CLICK</span><span style="color: #000000; font-weight: bold;">,</span> clickHandler<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>						tekstveld = <span style="color: #0033ff; font-weight: bold;">new</span> <a target="_blank" href="http://www.google.com/search?q=textfield%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:textfield.html"><span style="color: #004993;">TextField</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>			tekstveld<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">width</span> = <span style="color: #000000; font-weight:bold;">550</span><span style="color: #000000; font-weight: bold;">;</span>			tekstveld<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">height</span> = <span style="color: #000000; font-weight:bold;">30</span><span style="color: #000000; font-weight: bold;">;</span>			tekstveld<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">textColor</span> = 0xFFFFFFFF<span style="color: #000000; font-weight: bold;">;</span>			tekstveld<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">y</span> = <span style="color: #000000; font-weight:bold;">370</span><span style="color: #000000; font-weight: bold;">;</span>			tekstveld<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">text</span> = <span style="color: #009900;">&quot;tekst&quot;</span><span style="color: #000000; font-weight: bold;">;</span>			<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>tekstveld<span style="color: #000000;">&#41;</span><span style="color: #000000; 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;">loop</span><span style="color: #000000;">&#40;</span>e<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span>			bmd<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">draw</span><span style="color: #000000;">&#40;</span>videoHolder<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>			bmd<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">applyFilter</span><span style="color: #000000;">&#40;</span>bmd<span style="color: #000000; font-weight: bold;">,</span> bmd<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">rect</span><span style="color: #000000; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">new</span> <a target="_blank" href="http://www.google.com/search?q=point%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:point.html"><span style="color: #004993;">Point</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">,</span> allfilter<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>						graph<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">clear</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>			bmd<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">threshold</span><span style="color: #000000;">&#40;</span>bmd<span style="color: #000000; font-weight: bold;">,</span>bmd<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">rect</span><span style="color: #000000; font-weight: bold;">,</span><span style="color: #0033ff; font-weight: bold;">new</span> <a target="_blank" href="http://www.google.com/search?q=point%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:point.html"><span style="color: #004993;">Point</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">,</span> <span style="color: #009900;">&quot;&gt;&quot;</span><span style="color: #000000; font-weight: bold;">,</span> 0xFF330000<span style="color: #000000; font-weight: bold;">,</span> 0xFFFF0000<span style="color: #000000; font-weight: bold;">,</span> 0xFFFF0000<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>			bmd<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">threshold</span><span style="color: #000000;">&#40;</span>bmd<span style="color: #000000; font-weight: bold;">,</span>bmd<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">rect</span><span style="color: #000000; font-weight: bold;">,</span><span style="color: #0033ff; font-weight: bold;">new</span> <a target="_blank" href="http://www.google.com/search?q=point%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:point.html"><span style="color: #004993;">Point</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">,</span> <span style="color: #009900;">&quot;&gt;&quot;</span><span style="color: #000000; font-weight: bold;">,</span> 0xFF003300<span style="color: #000000; font-weight: bold;">,</span> 0xFF00FF00<span style="color: #000000; font-weight: bold;">,</span> 0xFF00FF00<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>			bmd<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">threshold</span><span style="color: #000000;">&#40;</span>bmd<span style="color: #000000; font-weight: bold;">,</span>bmd<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">rect</span><span style="color: #000000; font-weight: bold;">,</span><span style="color: #0033ff; font-weight: bold;">new</span> <a target="_blank" href="http://www.google.com/search?q=point%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:point.html"><span style="color: #004993;">Point</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">,</span> <span style="color: #009900;">&quot;&gt;&quot;</span><span style="color: #000000; font-weight: bold;">,</span> 0xFF000033<span style="color: #000000; font-weight: bold;">,</span> 0xFF0000FF<span style="color: #000000; font-weight: bold;">,</span> 0xFF0000FF<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>									<span style="color: #6699cc; font-weight: bold;">var</span> redrect<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=rectangle%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:rectangle.html"><span style="color: #004993;">Rectangle</span></a> = bmd<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">getColorBoundsRect</span><span style="color: #000000;">&#40;</span>0xFFFFFFFF<span style="color: #000000; font-weight: bold;">,</span> 0xFF0000<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>			<span style="color: #6699cc; font-weight: bold;">var</span> bluerect<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=rectangle%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:rectangle.html"><span style="color: #004993;">Rectangle</span></a> = bmd<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">getColorBoundsRect</span><span style="color: #000000;">&#40;</span>0xFFFFFFFF<span style="color: #000000; font-weight: bold;">,</span> 0x0000FF<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>			<span style="color: #6699cc; font-weight: bold;">var</span> greenrect<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=rectangle%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:rectangle.html"><span style="color: #004993;">Rectangle</span></a> = bmd<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">getColorBoundsRect</span><span style="color: #000000;">&#40;</span>0xFFFFFFFF<span style="color: #000000; font-weight: bold;">,</span> 0x00FF00<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>			<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>redrect<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000000; font-weight: bold;">!</span>= 0 <span style="color: #000000; font-weight: bold;">||</span> bluerect<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000000; font-weight: bold;">!</span>= 0 <span style="color: #000000; font-weight: bold;">||</span> greenrect<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000000; font-weight: bold;">!</span>= 0<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>				drawColorBoundsRect<span style="color: #000000;">&#40;</span>greenrect<span style="color: #000000; font-weight: bold;">,</span> 0x00FF00<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>				drawColorBoundsRect<span style="color: #000000;">&#40;</span>redrect<span style="color: #000000; font-weight: bold;">,</span> 0xFF0000<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>				drawColorBoundsRect<span style="color: #000000;">&#40;</span>bluerect<span style="color: #000000; font-weight: bold;">,</span> 0x0000FF<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>								<span style="color: #6699cc; font-weight: bold;">var</span> distances<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=object%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:object.html"><span style="color: #004993;">Object</span></a> = colorDistances<span style="color: #000000;">&#40;</span>redrect<span style="color: #000000; font-weight: bold;">,</span> greenrect<span style="color: #000000; font-weight: bold;">,</span> bluerect<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>								<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>distances<span style="color: #000000; font-weight: bold;">.</span>redToGreen <span style="color: #000000; font-weight: bold;">&lt;</span> 50<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>					<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #009900;">&quot;click&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>					<span style="color: #999999; font-style: italic;">//stuur data naar socket</span>				<span style="color: #000000;">&#125;</span>				<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>distances<span style="color: #000000; font-weight: bold;">.</span>redToBlue <span style="color: #000000; font-weight: bold;">&lt;</span> 50<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>					<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #009900;">&quot;right click&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>				<span style="color: #000000;">&#125;</span>			<span style="color: #000000;">&#125;</span>						<span style="color: #999999; font-style: italic;">// Deze code (de if-statement) is alleen nodig als je met een socket werkt die de data vervolgens verwerkt.</span>			<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>redrect<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000000; font-weight: bold;">!</span>= 0<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>				<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>trackingRed<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>					deltaRedX = <a target="_blank" href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>redrect<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">x</span> <span style="color: #000000; font-weight: bold;">+</span> redrect<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000000; font-weight: bold;">/</span> 2<span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">-</span> oldRedX<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>					deltaRedY = <a target="_blank" href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>redrect<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">y</span> <span style="color: #000000; font-weight: bold;">+</span> redrect<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">height</span> <span style="color: #000000; font-weight: bold;">/</span> 2<span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">-</span> oldRedY<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>					<span style="color: #999999; font-style: italic;">//stuur ook deze data naar de socket</span>				<span style="color: #000000;">&#125;</span>				trackingRed = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000; font-weight: bold;">;</span>				oldRedX = redrect<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">x</span> <span style="color: #000000; font-weight: bold;">+</span> redrect<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000; font-weight: bold;">;</span>				oldRedY = redrect<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">y</span> <span style="color: #000000; font-weight: bold;">+</span> redrect<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">height</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000; 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>				trackingRed = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000000; font-weight: bold;">;</span>				deltaRedX = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000; font-weight: bold;">;</span>				deltaRedY = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000; font-weight: bold;">;</span>			<span style="color: #000000;">&#125;</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> colorDistances<span style="color: #000000;">&#40;</span>redrect<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=rectangle%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:rectangle.html"><span style="color: #004993;">Rectangle</span></a><span style="color: #000000; font-weight: bold;">,</span> greenrect<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=rectangle%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:rectangle.html"><span style="color: #004993;">Rectangle</span></a><span style="color: #000000; font-weight: bold;">,</span> bluerect<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=rectangle%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:rectangle.html"><span style="color: #004993;">Rectangle</span></a><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=object%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:object.html"><span style="color: #004993;">Object</span></a><span style="color: #000000;">&#123;</span>			<span style="color: #6699cc; font-weight: bold;">var</span> greenRectCenter<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=point%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:point.html"><span style="color: #004993;">Point</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a target="_blank" href="http://www.google.com/search?q=point%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:point.html"><span style="color: #004993;">Point</span></a><span style="color: #000000;">&#40;</span>greenrect<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">x</span> <span style="color: #000000; font-weight: bold;">+</span> greenrect<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000000; font-weight: bold;">/</span>2<span style="color: #000000; font-weight: bold;">,</span> greenrect<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">y</span> <span style="color: #000000; font-weight: bold;">+</span> greenrect<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">height</span> <span style="color: #000000; font-weight: bold;">/</span>2<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>			<span style="color: #6699cc; font-weight: bold;">var</span> redRectCenter<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=point%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:point.html"><span style="color: #004993;">Point</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a target="_blank" href="http://www.google.com/search?q=point%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:point.html"><span style="color: #004993;">Point</span></a><span style="color: #000000;">&#40;</span>redrect<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">x</span> <span style="color: #000000; font-weight: bold;">+</span> redrect<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000000; font-weight: bold;">/</span>2<span style="color: #000000; font-weight: bold;">,</span> redrect<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">y</span> <span style="color: #000000; font-weight: bold;">+</span> redrect<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">height</span> <span style="color: #000000; font-weight: bold;">/</span>2<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>			<span style="color: #6699cc; font-weight: bold;">var</span> blueRectCenter<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=point%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:point.html"><span style="color: #004993;">Point</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a target="_blank" href="http://www.google.com/search?q=point%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:point.html"><span style="color: #004993;">Point</span></a><span style="color: #000000;">&#40;</span>bluerect<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">x</span> <span style="color: #000000; font-weight: bold;">+</span> bluerect<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000000; font-weight: bold;">/</span>2<span style="color: #000000; font-weight: bold;">,</span> bluerect<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">y</span> <span style="color: #000000; font-weight: bold;">+</span> bluerect<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">height</span> <span style="color: #000000; font-weight: bold;">/</span>2<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>						graph<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">lineStyle</span><span style="color: #000000;">&#40;</span>1<span style="color: #000000; font-weight: bold;">,</span> 0xFFFF00<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>			graph<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">moveTo</span><span style="color: #000000;">&#40;</span>greenRectCenter<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000000; font-weight: bold;">,</span> greenRectCenter<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>			graph<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">lineTo</span><span style="color: #000000;">&#40;</span>redRectCenter<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">x</span> <span style="color: #000000; font-weight: bold;">,</span> redRectCenter<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>			graph<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">lineStyle</span><span style="color: #000000;">&#40;</span>1<span style="color: #000000; font-weight: bold;">,</span> 0xFF00FF<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>			graph<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">moveTo</span><span style="color: #000000;">&#40;</span>redRectCenter<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000000; font-weight: bold;">,</span> redRectCenter<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>			graph<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">lineTo</span><span style="color: #000000;">&#40;</span>blueRectCenter<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">x</span> <span style="color: #000000; font-weight: bold;">,</span> blueRectCenter<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>			graph<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">lineStyle</span><span style="color: #000000;">&#40;</span>1<span style="color: #000000; font-weight: bold;">,</span> 0x00FFFF<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>			graph<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">moveTo</span><span style="color: #000000;">&#40;</span>blueRectCenter<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000000; font-weight: bold;">,</span> blueRectCenter<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>			graph<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">lineTo</span><span style="color: #000000;">&#40;</span>greenRectCenter<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">x</span> <span style="color: #000000; font-weight: bold;">,</span> greenRectCenter<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>						<span style="color: #6699cc; font-weight: bold;">var</span> distances<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=object%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:object.html"><span style="color: #004993;">Object</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a target="_blank" href="http://www.google.com/search?q=object%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:object.html"><span style="color: #004993;">Object</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>						distances<span style="color: #000000; font-weight: bold;">.</span>redToGreen = calculateDistance<span style="color: #000000;">&#40;</span>greenRectCenter<span style="color: #000000; font-weight: bold;">,</span> redRectCenter<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>			distances<span style="color: #000000; font-weight: bold;">.</span>redToBlue = calculateDistance<span style="color: #000000;">&#40;</span>blueRectCenter<span style="color: #000000; font-weight: bold;">,</span> redRectCenter<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>						<span style="color: #0033ff; font-weight: bold;">return</span><span style="color: #000000;">&#40;</span>distances<span style="color: #000000;">&#41;</span><span style="color: #000000; 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> calculateDistance<span style="color: #000000;">&#40;</span>p1<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=point%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:point.html"><span style="color: #004993;">Point</span></a><span style="color: #000000; font-weight: bold;">,</span> p2<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=point%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:point.html"><span style="color: #004993;">Point</span></a><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a><span style="color: #000000;">&#123;</span>			<span style="color: #0033ff; font-weight: bold;">return</span><span style="color: #000000;">&#40;</span><a target="_blank" href="http://www.google.com/search?q=math%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:math.html"><span style="color: #004993;">Math</span></a><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">sqrt</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>p1<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">x</span> <span style="color: #000000; font-weight: bold;">-</span> p2<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000;">&#40;</span>p1<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">x</span> <span style="color: #000000; font-weight: bold;">-</span> p2<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #000000;">&#40;</span>p1<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">y</span> <span style="color: #000000; font-weight: bold;">-</span> p2<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000;">&#40;</span>p1<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">y</span> <span style="color: #000000; font-weight: bold;">-</span> p2<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; 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> drawColorBoundsRect<span style="color: #000000;">&#40;</span><span style="color: #004993;">rect</span><span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=rectangle%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:rectangle.html"><span style="color: #004993;">Rectangle</span></a><span style="color: #000000; font-weight: bold;">,</span> <span style="color: #004993;">color</span><span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=uint%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:uint.html"><span style="color: #004993;">uint</span></a><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>			graph<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">lineStyle</span><span style="color: #000000;">&#40;</span>1<span style="color: #000000; font-weight: bold;">,</span> <span style="color: #004993;">color</span><span style="color: #000000; font-weight: bold;">,</span> 1<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>			graph<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">beginFill</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">color</span><span style="color: #000000; font-weight: bold;">,</span> 0<span style="color: #000000; font-weight: bold;">.</span>3<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>			graph<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">drawRect</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">rect</span><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000000; font-weight: bold;">,</span> <span style="color: #004993;">rect</span><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000000; font-weight: bold;">,</span> <span style="color: #004993;">rect</span><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">width</span><span style="color: #000000; font-weight: bold;">,</span> <span style="color: #004993;">rect</span><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">height</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>			graph<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000000; 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: #000000; font-weight: bold;">;</span>		<span style="color: #000000;">&#125;</span>	<span style="color: #000000;">&#125;</span><span style="color: #000000;">&#125;</span></div></div></pre>
</div>Pfoeh, een redelijke lap code voor een blogpost, maar achteraf viel dit deel van de code me eigenlijk 300% mee qua lengte. Daarbij moet ik zeggen dat ik een heel aantal verschillende versies van dit project, onder andere werkende voorbeelden die met licht werken in plaats van kleuren, en één die nog meer vertrouwt op de instellingen van de camera.<br />
<br />
Eerst even wat extra uitleg over een aantal moeilijkere zaken. Om maar even te beginnen met die rare array die je ziet staan: dat is een eigenlijk een ColorMatrix, waarmee de kleuren van de webcambeelden worden gemanipuleerd. Om bijvoorbeeld de rode kleuren te tracken, trek ik in dit geval dus de groen- en blauwwaarden van het de roodwaarde af. Wanneer een object dus alleen rood bevat, zal er niks mee gebeuren. Is het object echter een mengeling van verschillende kleuren (bijvoorbeeld bruin, of helemaal wit), zal dit resulteren in een donkerdere versie van de kleur rood (of zelfs helemaal zwart). Op die manier is het enige dat je dus terugziet in de uiteindelijke beelden de echt felgekleurde objecten in één van de drie primaire RGB-kleuren. Dit is waarschijnlijk een onbegrijpelijk verhaal voor de mensen die hiermee nog nooit eerder hebben gewerkt, en die verwijs ik dan ook graag door naar <a href="http://active.tutsplus.com/tutorials/effects/manipulate-visual-effects-with-the-colormatrixfilter-and-convolutionfilter/" target="_blank">http://active.tutsplus.com/tutorials...olutionfilter/</a> , waar ik zowat al mijn info vandaan heb over dit onderwerp.<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">ActionScript 3 Code:</div>
	<pre class="alt2" style="margin:0px; padding:5px; border: 1px solid #B1B6C2; width:700px; height:132px; overflow:auto"><div dir="ltr" style="text-align:left;"><div class="actionscript3" style="font-family:monospace;"><pre><span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> allcmx<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=array%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:array.html"><span style="color: #004993;">Array</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a target="_blank" href="http://www.google.com/search?q=array%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:array.html"><span style="color: #004993;">Array</span></a><span style="color: #000000;">&#40;</span>1<span style="color: #000000; font-weight: bold;">,-</span>1<span style="color: #000000; font-weight: bold;">,-</span>1<span style="color: #000000; font-weight: bold;">,</span>0<span style="color: #000000; font-weight: bold;">,</span>&nbsp; &nbsp; &nbsp; &nbsp; 0<span style="color: #000000; font-weight: bold;">,-</span>1<span style="color: #000000; font-weight: bold;">,</span>1<span style="color: #000000; font-weight: bold;">.</span>5<span style="color: #000000; font-weight: bold;">,-</span>1<span style="color: #000000; font-weight: bold;">,</span>&nbsp; &nbsp; &nbsp; &nbsp; 0<span style="color: #000000; font-weight: bold;">,</span>0<span style="color: #000000; font-weight: bold;">,-</span>1<span style="color: #000000; font-weight: bold;">,-</span>1<span style="color: #000000; font-weight: bold;">,</span>&nbsp; &nbsp; &nbsp; &nbsp; 1<span style="color: #000000; font-weight: bold;">,</span>0<span style="color: #000000; font-weight: bold;">,</span>0<span style="color: #000000; font-weight: bold;">,</span>0<span style="color: #000000; font-weight: bold;">,</span>&nbsp; &nbsp; &nbsp; &nbsp; 0<span style="color: #000000; font-weight: bold;">,</span>0<span style="color: #000000; font-weight: bold;">,</span>1<span style="color: #000000; font-weight: bold;">,</span>0<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span></div></div></pre>
</div>Vervolgens bepalen we de positie van deze kleuren door middel van de BitmapData.getColorBoundsRect functie. Deze functie heeft een aantal verschillende parameters, waarover <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/BitmapData.html" target="_blank">http://livedocs.adobe.com/flash/9.0/...itmapData.html</a> je meer kan vertellen. Het belangrijkste is dat deze functie je een Rectangle geeft waaruit je kunt aflezen waar een bepaalde kleur zicht bevindt. Om het wat makkelijker te maken voor die functie heb ik een threshold toegevoegd, die ervoor zorgt dat bijvoorbeeld alle rode pixels lichter dan #330000 worden omgezet in #FF0000, zodat de functie alleen hoeft te zoeken op volledig rood.<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">ActionScript 3 Code:</div>
	<pre class="alt2" style="margin:0px; padding:5px; border: 1px solid #B1B6C2; width:700px; height:68px; overflow:auto"><div dir="ltr" style="text-align:left;"><div class="actionscript3" style="font-family:monospace;"><pre>bmd<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">threshold</span><span style="color: #000000;">&#40;</span>bmd<span style="color: #000000; font-weight: bold;">,</span>bmd<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">rect</span><span style="color: #000000; font-weight: bold;">,</span><span style="color: #0033ff; font-weight: bold;">new</span> <a target="_blank" href="http://www.google.com/search?q=point%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:point.html"><span style="color: #004993;">Point</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">,</span> <span style="color: #009900;">&quot;&gt;&quot;</span><span style="color: #000000; font-weight: bold;">,</span> 0xFF330000<span style="color: #000000; font-weight: bold;">,</span> 0xFFFF0000<span style="color: #000000; font-weight: bold;">,</span> &nbsp;0xFFFF0000<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span><span style="color: #6699cc; font-weight: bold;">var</span> redrect<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=rectangle%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:rectangle.html"><span style="color: #004993;">Rectangle</span></a> = bmd<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">getColorBoundsRect</span><span style="color: #000000;">&#40;</span>0xFFFFFFFF<span style="color: #000000; font-weight: bold;">,</span> 0xFF0000<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span></div></div></pre>
</div>Daarmee houdt de uitleg voor nu even op. Om alles uit te leggen in deze blogpost zou wat mij betreft enigszins overdreven zijn, dus ik laat het er voorlopig bij. Mocht je echter nog vragen hebben, stel ze dan in de comments!<br />
<br />
Zoals je ook ziet hoort er af en toe data te worden verstuurd naar een socket. Deze code heb ik er voor nu even uitgeknipt, maar werkt in het gehele programmeersel wel. Met het eindresultaat is het dan ook mogelijk om de positie van de muiscursor te veranderen door iets in de lucht te zwaaien. Erg leuk, al zeg ik het zelf! Misschien dat ik er later nog wel iets meer over blog, maar ik kan je alvast vertellen dat het deel dat hierboven staat een stuk interessanter is (en zelfs dat is al best langdradig ;))<br />
<br />
<br />
Voor de mensen die langs die enorme lap tekst zijn gescrold in de hoop hier een demo te vinden: <a href="http://ath92.nl/pws/MotionTracker/main.html" target="_blank">Klik hier!</a> en speel er eens mee. Voor als je niets ziet na de camera te hebben geactiveerd: er is waarschijnlijk te weinig licht, of je houdt geen object met de juiste kleur voor de camera. Als je heel veel gekleurde vierkantjes ziet zonder iets felgekleurds voor de camera te houden: je kamer is waarschijnlijk te licht, of de kleurverzadiging van je camera staat te hoog.<br />
<br />
Nogmaals: Vragen? Stel ze in de comments. Nog bedankt aan Ronny voor de inspiratie en ik hoop dat jullie het kunnen lezen ;)</div>

]]></content:encoded>
			<dc:creator>ath92</dc:creator>
			<guid isPermaLink="true">http://www.flashfocus.nl/forum/blog.php?b=43</guid>
		</item>
		<item>
			<title>Realtime light painting in Flash!</title>
			<link>http://www.flashfocus.nl/forum/blog.php?b=42</link>
			<pubDate>Thu, 16 Sep 2010 02:47:38 GMT</pubDate>
			<description>Image: http://shots.nocreativity.com/99df199789ac0f5e14fc492a99c8ea09.jpg  
 
Een tijdje geleden wou ik eens proberen om realtime light painting in Flash mogelijk te maken. Het leek me niet zo moeilijk om te doen, en tjah... Dat was het ook niet :D 
 
Ik wou het jullie even laten zien en zien wat jullie ervan denken :D 
 
(Je moet in een donkere ruimte zijn om hiermee te spelen, anders mislukt het grandioos ;) ) 
 
Demo (http://vimeo.com/14983265)</description>
			<content:encoded><![CDATA[<div><img src="http://shots.nocreativity.com/99df199789ac0f5e14fc492a99c8ea09.jpg" border="0" alt="" /><br />
<br />
Een tijdje geleden wou ik eens proberen om realtime light painting in Flash mogelijk te maken. Het leek me niet zo moeilijk om te doen, en tjah... Dat was het ook niet :D<br />
<br />
Ik wou het jullie even laten zien en zien wat jullie ervan denken :D<br />
<br />
(Je moet in een donkere ruimte zijn om hiermee te spelen, anders mislukt het grandioos ;) )<br />
<br />
<a href="http://vimeo.com/14983265" target="_blank">Demo</a><br />
<br />
<a href="http://nocreativity.com/blog/realtime-painting-with-light" target="_blank">Zelf testen!</a><br />
<br />
<a href="http://nocreativity.com/blog/wp-content/plugins/download-monitor/download.php?id=10" target="_blank">Source</a></div>

]]></content:encoded>
			<dc:creator>Ea.Z</dc:creator>
			<guid isPermaLink="true">http://www.flashfocus.nl/forum/blog.php?b=42</guid>
		</item>
		<item>
			<title>Performance tips</title>
			<link>http://www.flashfocus.nl/forum/blog.php?b=41</link>
			<pubDate>Tue, 25 May 2010 21:18:47 GMT</pubDate>
			<description><![CDATA[Het leek me handig om een artikel te plaatsen met wat kleine performance tips. 
Je performance in de gaten houden is een belangrijk onderdeel bij het maken van goede applicaties. 
Bij de gemiddelde fotogallery of portfolio site is dit misschien niet zo'n big deal. Maar wanneer je met particles of games aan de slag gaat en je bepaalde code uitvoert in onEnterFrame handlers en veel door loops loopt, is het zeker de moeite waard om zo efficiënt mogelijk te programmeren. 
Vaak zijn het kleine...]]></description>
			<content:encoded><![CDATA[<div>Het leek me handig om een artikel te plaatsen met wat kleine performance tips.<br />
Je performance in de gaten houden is een belangrijk onderdeel bij het maken van goede applicaties.<br />
Bij de gemiddelde fotogallery of portfolio site is dit misschien niet zo'n big deal. Maar wanneer je met particles of games aan de slag gaat en je bepaalde code uitvoert in onEnterFrame handlers en veel door loops loopt, is het zeker de moeite waard om zo efficiënt mogelijk te programmeren.<br />
Vaak zijn het kleine handigheidjes die je jezelf even aan moet wennen.<br />
<br />
<br />
Als jullie toevoegingen hebben of onjuistheden opmerken. Dan hoor ik het graag.<br />
<br />
<br />
<b>Math.max en Math.min zijn traag</b><br />
<br />
Het gebruik van Math.max en Math.min is erg traag in vergelijking met een if statement.<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">ActionScript 3 Code:</div>
	<pre class="alt2" style="margin:0px; padding:5px; border: 1px solid #B1B6C2; width:700px; height:212px; overflow:auto"><div dir="ltr" style="text-align:left;"><div class="actionscript3" style="font-family:monospace;"><pre><span style="color: #999999; font-style: italic;">//In plaats van</span><span style="color: #6699cc; font-weight: bold;">var</span> v1<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = <span style="color: #000000; font-weight:bold;">10</span><span style="color: #000000; font-weight: bold;">;</span><span style="color: #6699cc; font-weight: bold;">var</span> v2<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = <span style="color: #000000; font-weight:bold;">20</span><span style="color: #000000; font-weight: bold;">;</span><span style="color: #6699cc; font-weight: bold;">var</span> v3<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = <a target="_blank" href="http://www.google.com/search?q=math%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:math.html"><span style="color: #004993;">Math</span></a><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">max</span><span style="color: #000000;">&#40;</span>v1<span style="color: #000000; font-weight: bold;">,</span>v2<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span><span style="color: #999999; font-style: italic;">//prefereer ik (± 8.5x zo snel)</span><span style="color: #6699cc; font-weight: bold;">var</span> v1<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = <span style="color: #000000; font-weight:bold;">10</span><span style="color: #000000; font-weight: bold;">;</span><span style="color: #6699cc; font-weight: bold;">var</span> v2<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = <span style="color: #000000; font-weight:bold;">20</span><span style="color: #000000; font-weight: bold;">;</span><span style="color: #6699cc; font-weight: bold;">var</span> v3<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = <span style="color: #000000;">&#40;</span>v1 <span style="color: #000000; font-weight: bold;">&gt;</span>= v2<span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">?</span> v1 <span style="color: #000000; font-weight: bold;">:</span> v2<span style="color: #000000; font-weight: bold;">;</span></div></div></pre>
</div><br />
<b>Math.abs is traag.</b><br />
<br />
Het gebruik van Math.abs is erg traag in vergelijking met een if statement.<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">ActionScript 3 Code:</div>
	<pre class="alt2" style="margin:0px; padding:5px; border: 1px solid #B1B6C2; width:700px; height:180px; overflow:auto"><div dir="ltr" style="text-align:left;"><div class="actionscript3" style="font-family:monospace;"><pre><span style="color: #999999; font-style: italic;">//In plaats van</span><span style="color: #6699cc; font-weight: bold;">var</span> v1<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = <span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">10</span><span style="color: #000000; font-weight: bold;">;</span><span style="color: #6699cc; font-weight: bold;">var</span> v2<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = <a target="_blank" href="http://www.google.com/search?q=math%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:math.html"><span style="color: #004993;">Math</span></a><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">abs</span><span style="color: #000000;">&#40;</span>v1<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span><span style="color: #999999; font-style: italic;">//prefereer ik (± 7.5x zo snel)</span><span style="color: #6699cc; font-weight: bold;">var</span> v1<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = <span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">10</span><span style="color: #000000; font-weight: bold;">;</span><span style="color: #6699cc; font-weight: bold;">var</span> v2<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = <span style="color: #000000;">&#40;</span>v1 <span style="color: #000000; font-weight: bold;">&lt;</span> 0<span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">?</span> <span style="color: #000000; font-weight: bold;">-</span>v1 <span style="color: #000000; font-weight: bold;">:</span> v1<span style="color: #000000; font-weight: bold;">;</span></div></div></pre>
</div><br />
<b>Math.floor is trager dan casten naar int.</b><br />
<br />
Je kunt Math.floor eenvoudig vermijden door te casten naar int.<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">ActionScript 3 Code:</div>
	<pre class="alt2" style="margin:0px; padding:5px; border: 1px solid #B1B6C2; width:700px; height:164px; overflow:auto"><div dir="ltr" style="text-align:left;"><div class="actionscript3" style="font-family:monospace;"><pre><span style="color: #6699cc; font-weight: bold;">var</span> v1<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = <span style="color: #000000; font-weight:bold;">10.5</span><span style="color: #000000; font-weight: bold;">;</span><span style="color: #6699cc; font-weight: bold;">var</span> v2<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a><span style="color: #000000; font-weight: bold;">;</span><span style="color: #999999; font-style: italic;">//In plaats van</span>v2 = <a target="_blank" href="http://www.google.com/search?q=math%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:math.html"><span style="color: #004993;">Math</span></a><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">floor</span><span style="color: #000000;">&#40;</span>v1<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span><span style="color: #999999; font-style: italic;">//prefereer ik (± 3.5x zo snel)</span>v2 = <a target="_blank" href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a><span style="color: #000000;">&#40;</span>v1<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span></div></div></pre>
</div><br />
Er is nog een snellere methode. Deze is wat minder leesbaar, maar 1.5x sneller dan de int(value) methode.<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">ActionScript 3 Code:</div>
	<pre class="alt2" style="margin:0px; padding:5px; border: 1px solid #B1B6C2; width:700px; height:100px; overflow:auto"><div dir="ltr" style="text-align:left;"><div class="actionscript3" style="font-family:monospace;"><pre><span style="color: #6699cc; font-weight: bold;">var</span> v1<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = <span style="color: #000000; font-weight:bold;">10.5</span><span style="color: #000000; font-weight: bold;">;</span><span style="color: #6699cc; font-weight: bold;">var</span> v2<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a><span style="color: #000000; font-weight: bold;">;</span>v2 = v1<span style="color: #000000; font-weight: bold;">&gt;&gt;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000; font-weight: bold;">;</span></div></div></pre>
</div><br />
<br />
<b><i>Bovenstaande methodes  werken alleen bij positieve getallen!<br />
Als het getal ook negatief kan zijn moet je hier een check voor maken.<br />
Dit is iets trager, maar nog steeds veel sneller dan Math.floor.</i></b><br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">ActionScript 3 Code:</div>
	<pre class="alt2" style="margin:0px; padding:5px; border: 1px solid #B1B6C2; width:700px; height:52px; overflow:auto"><div dir="ltr" style="text-align:left;"><div class="actionscript3" style="font-family:monospace;"><pre>v2 = <span style="color: #000000;">&#40;</span>v1<span style="color: #000000; font-weight: bold;">&gt;</span>0<span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">?</span> v1 <span style="color: #000000; font-weight: bold;">&gt;&gt;</span>0 <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000;">&#40;</span>v1<span style="color: #000000; font-weight: bold;">&gt;&gt;</span>0<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000; font-weight: bold;">;</span></div></div></pre>
</div><br />
<b>Math.ceil is ook trager dan casten naar int.</b><br />
<br />
Voor Math.ceil geldt eigenlijk hetzelfde als voor Math.floor.<br />
Alleen kun je niet zomaar naar int casten en er 1 bij optellen:<br />
<br />
Math.ceil(1.2) == 2;<br />
int(1.2)+1 == 2;<br />
Math.ceil(1) == 1;<br />
int(1)+1 == 2;<br />
<br />
Daarom gebruiken we een inline if statement.<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">ActionScript 3 Code:</div>
	<pre class="alt2" style="margin:0px; padding:5px; border: 1px solid #B1B6C2; width:700px; height:164px; overflow:auto"><div dir="ltr" style="text-align:left;"><div class="actionscript3" style="font-family:monospace;"><pre><span style="color: #6699cc; font-weight: bold;">var</span> v1<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = <span style="color: #000000; font-weight:bold;">10.5</span><span style="color: #000000; font-weight: bold;">;</span><span style="color: #6699cc; font-weight: bold;">var</span> v2<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a><span style="color: #000000; font-weight: bold;">;</span><span style="color: #999999; font-style: italic;">//In plaats van</span>v2 = <a target="_blank" href="http://www.google.com/search?q=math%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:math.html"><span style="color: #004993;">Math</span></a><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">ceil</span><span style="color: #000000;">&#40;</span>v1<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span><span style="color: #999999; font-style: italic;">//prefereer ik (± 2.5x zo snel)</span>v2 = <span style="color: #000000;">&#40;</span><a target="_blank" href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a><span style="color: #000000;">&#40;</span>v1<span style="color: #000000;">&#41;</span> == v1<span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">?</span> v1 <span style="color: #000000; font-weight: bold;">:</span> <a target="_blank" href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a><span style="color: #000000;">&#40;</span>v1<span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000; font-weight: bold;">;</span></div></div></pre>
</div><br />
En de bitwise methode zoals bij Math.floor geeft hier zelfs nog iets meer winst dan bij Math.floor het geval is. <br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">ActionScript 3 Code:</div>
	<pre class="alt2" style="margin:0px; padding:5px; border: 1px solid #B1B6C2; width:700px; height:100px; overflow:auto"><div dir="ltr" style="text-align:left;"><div class="actionscript3" style="font-family:monospace;"><pre><span style="color: #6699cc; font-weight: bold;">var</span> v1<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = <span style="color: #000000; font-weight:bold;">10.5</span><span style="color: #000000; font-weight: bold;">;</span><span style="color: #6699cc; font-weight: bold;">var</span> v2<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a><span style="color: #000000; font-weight: bold;">;</span>v2 = <span style="color: #000000;">&#40;</span>v1 <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> 0 == v1<span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">?</span> v1 <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000;">&#40;</span>v1 <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> 0<span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000; font-weight: bold;">;</span></div></div></pre>
</div><br />
<br />
<b><i>Bovenstaande methodes  werken alleen bij positieve getallen!<br />
Als het getal ook negatief kan zijn moet je hier een check voor maken.<br />
Dit is iets trager, maar nog steeds veel sneller dan Math.ceil.</i></b><br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">ActionScript 3 Code:</div>
	<pre class="alt2" style="margin:0px; padding:5px; border: 1px solid #B1B6C2; width:700px; height:52px; overflow:auto"><div dir="ltr" style="text-align:left;"><div class="actionscript3" style="font-family:monospace;"><pre>v2 = <span style="color: #000000;">&#40;</span>v1 <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> 0 == v1<span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">?</span> v1 <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000;">&#40;</span>v1 <span style="color: #000000; font-weight: bold;">&lt;</span> 0<span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">?</span> <span style="color: #000000;">&#40;</span>v1 <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> 0<span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #000000;">&#40;</span>v1 <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> 0<span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000; font-weight: bold;">;</span></div></div></pre>
</div><br />
<b>Vermenigvuldigen is sneller dan delen.</b><br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">ActionScript 3 Code:</div>
	<pre class="alt2" style="margin:0px; padding:5px; border: 1px solid #B1B6C2; width:700px; height:84px; overflow:auto"><div dir="ltr" style="text-align:left;"><div class="actionscript3" style="font-family:monospace;"><pre><span style="color: #000000; font-weight:bold;">20</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">2</span> <span style="color: #999999; font-style: italic;">//is ± 7% langzamer dan </span>20 <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">.</span>5<span style="color: #000000; font-weight: bold;">;</span></div></div></pre>
</div><br />
<b>Bitwise operations zijn super snel!</b><br />
<br />
Het gebruik van bitwise operations kan je project een flinke performanceboost geven.<br />
Deze zijn echt super snel mits ze gebruikt worden in combinatie met integers.<br />
Als je Numbers gebruikt kun je zomaar voor verrassingen komen te staan.<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">ActionScript 3 Code:</div>
	<pre class="alt2" style="margin:0px; padding:5px; border: 1px solid #B1B6C2; width:700px; height:132px; overflow:auto"><div dir="ltr" style="text-align:left;"><div class="actionscript3" style="font-family:monospace;"><pre><span style="color: #6699cc; font-weight: bold;">var</span> v1<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = <span style="color: #000000; font-weight:bold;">20</span><span style="color: #000000; font-weight: bold;">;</span><span style="color: #6699cc; font-weight: bold;">var</span> v2<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a><span style="color: #000000; font-weight: bold;">;</span>v2 = v1 <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">.</span>5<span style="color: #000000; font-weight: bold;">;</span><span style="color: #999999; font-style: italic;">//is ± 1.4x zo snel als</span>v2 = v1 <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000; font-weight: bold;">;</span></div></div></pre>
</div><br />
Maar als we integers gebruiken:<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">ActionScript 3 Code:</div>
	<pre class="alt2" style="margin:0px; padding:5px; border: 1px solid #B1B6C2; width:700px; height:132px; overflow:auto"><div dir="ltr" style="text-align:left;"><div class="actionscript3" style="font-family:monospace;"><pre><span style="color: #6699cc; font-weight: bold;">var</span> v1<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a> = <span style="color: #000000; font-weight:bold;">20</span><span style="color: #000000; font-weight: bold;">;</span><span style="color: #6699cc; font-weight: bold;">var</span> v2<span style="color: #000000; font-weight: bold;">:</span> <a target="_blank" href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a><span style="color: #000000; font-weight: bold;">;</span>v2 = v1 <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000; font-weight: bold;">;</span><span style="color: #999999; font-style: italic;">//is ± 1.6x zo snel als</span>v2 = v1 <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">.</span>5<span style="color: #000000; font-weight: bold;">;</span></div></div></pre>
</div><br />
<br />
Bitwise operations ronden je getallen wel af op hele getallen. Maar dat zie ik vaker als een voordeel dan een nadeel.<br />
Bijvoorbeeld bij het uitlijnen van textfields. Je wilt textfields altijd op hele pixels plaatsen.<br />
Vaak wil je een textfield in het midden van een knop zetten. Ik gebruik daarvoor de volgende code:<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">ActionScript 3 Code:</div>
	<pre class="alt2" style="margin:0px; padding:5px; border: 1px solid #B1B6C2; width:700px; height:52px; overflow:auto"><div dir="ltr" style="text-align:left;"><div class="actionscript3" style="font-family:monospace;"><pre>_txt<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">x</span> = width<span style="color: #000000; font-weight: bold;">-</span>_txt<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000; font-weight: bold;">;</span></div></div></pre>
</div><br />
<b>Een aantal bitwise tricks die in je voordeel kunnen werken mits je ze gebruikt met integers:</b><br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">ActionScript 3 Code:</div>
	<pre class="alt2" style="margin:0px; padding:5px; border: 1px solid #B1B6C2; width:700px; height:212px; overflow:auto"><div dir="ltr" style="text-align:left;"><div class="actionscript3" style="font-family:monospace;"><pre><span style="color: #999999; font-style: italic;">//delen door 2</span><span style="color: #004993;">value</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000; font-weight: bold;">;</span><span style="color: #999999; font-style: italic;">//vermenigvuldigen met 2</span><span style="color: #004993;">value</span> <span style="color: #000000; font-weight: bold;">&lt;&lt;</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000; font-weight: bold;">;</span><span style="color: #999999; font-style: italic;">//positief/negatief omdraaien (± 1.2x zo snel)</span><span style="color: #000000; font-weight: bold;">~</span><span style="color: #004993;">value</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000; font-weight: bold;">;</span> <span style="color: #999999; font-style: italic;">// is gelijk aan: value * -1; //en is gelijk aan: &nbsp;-value</span><span style="color: #999999; font-style: italic;">//even/oneven controleren</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">value</span> <span style="color: #000000; font-weight: bold;">&amp;</span> 1<span style="color: #000000;">&#41;</span> == <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000; font-weight: bold;">;</span> <span style="color: #999999; font-style: italic;">//is gelijk aan: (value % 2) == 0;</span></div></div></pre>
</div><br />
<b>Integers zijn sneller dan Numbers.<br />
</b><br />
Sommige van de hierboven beschreven methode gaan uit van een bepaald datatype.<br />
De behaalde resultaten kunnen namelijk nogal verschillen tussen bepaalde datatypen.<br />
<br />
<i>Voorbeeld:</i><br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">ActionScript 3 Code:</div>
	<pre class="alt2" style="margin:0px; padding:5px; border: 1px solid #B1B6C2; width:700px; height:132px; overflow:auto"><div dir="ltr" style="text-align:left;"><div class="actionscript3" style="font-family:monospace;"><pre><span style="color: #6699cc; font-weight: bold;">var</span> v1<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a> = <span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">11</span><span style="color: #000000; font-weight: bold;">;</span><span style="color: #6699cc; font-weight: bold;">var</span> v2<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a><span style="color: #000000; font-weight: bold;">;</span><span style="color: #999999; font-style: italic;">//dit:</span>v2 = v1<span style="color: #000000; font-weight: bold;">*-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000; font-weight: bold;">;</span><span style="color: #999999; font-style: italic;">//is sneller dan</span>v2 = <span style="color: #000000; font-weight: bold;">-</span>v1<span style="color: #000000; font-weight: bold;">;</span></div></div></pre>
</div><br />
Maar, als je ditzelfde met Numbers doet:<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">ActionScript 3 Code:</div>
	<pre class="alt2" style="margin:0px; padding:5px; border: 1px solid #B1B6C2; width:700px; height:132px; overflow:auto"><div dir="ltr" style="text-align:left;"><div class="actionscript3" style="font-family:monospace;"><pre><span style="color: #6699cc; font-weight: bold;">var</span> v1<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = <span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">11</span><span style="color: #000000; font-weight: bold;">;</span><span style="color: #6699cc; font-weight: bold;">var</span> v2<span style="color: #000000; font-weight: bold;">:</span> <a target="_blank" href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a><span style="color: #000000; font-weight: bold;">;</span><span style="color: #999999; font-style: italic;">//is dit ± 15% sneller:</span>v2 = <span style="color: #000000; font-weight: bold;">-</span>v1<span style="color: #000000; font-weight: bold;">;</span><span style="color: #999999; font-style: italic;">//dan:</span>v2 = v1<span style="color: #000000; font-weight: bold;">*-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000; font-weight: bold;">;</span></div></div></pre>
</div><br />
Over het algemeen zijn integers sneller.<br />
Gebruik daarom ook altijd integers in loops en bij voorkeur uints als de loop optelt.<br />
In flash player 9 was de performance van uints belachelijk slecht. In veel gevallen waren uints zelfs trager dan Numbers.<br />
Hierom kozen veel developers voor ints als loop counter. Ik ben hier eigenlijk nooit in mee gegaan, omdat het meer sense maakt om uints te gebruiken in een positieve loop. Daar zijn ze immers voor.<br />
Gelukkig is de performance van uints in flash player 10 zoals deze moet zijn. (hetzelfde of zelfs iets sneller dan ints)<br />
<br />
<i>loop voorbeeld:</i><br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">ActionScript 3 Code:</div>
	<pre class="alt2" style="margin:0px; padding:5px; border: 1px solid #B1B6C2; width:700px; height:116px; overflow:auto"><div dir="ltr" style="text-align:left;"><div class="actionscript3" style="font-family:monospace;"><pre><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: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=uint%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:uint.html"><span style="color: #004993;">uint</span></a> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000; font-weight: bold;">;</span> i<span style="color: #000000; font-weight: bold;">&lt;</span><span style="color: #000000; font-weight:bold;">100</span><span style="color: #000000; font-weight: bold;">;</span> i<span style="color: #000000; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span>ipv<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: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000; font-weight: bold;">;</span> i<span style="color: #000000; font-weight: bold;">&lt;</span><span style="color: #000000; font-weight:bold;">100</span><span style="color: #000000; font-weight: bold;">;</span> i<span style="color: #000000; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span>en ipv<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: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000; font-weight: bold;">;</span> i<span style="color: #000000; font-weight: bold;">&lt;</span><span style="color: #000000; font-weight:bold;">100</span><span style="color: #000000; font-weight: bold;">;</span> i<span style="color: #000000; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span></div></div></pre>
</div><br />
Als je loop counter negatief kan worden gebruik je natuurlijk ints.<br />
<br />
<b>Gebruik geen array.push als dit niet nodig is.</b><br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">ActionScript 3 Code:</div>
	<pre class="alt2" style="margin:0px; padding:5px; border: 1px solid #B1B6C2; width:700px; height:132px; overflow:auto"><div dir="ltr" style="text-align:left;"><div class="actionscript3" style="font-family:monospace;"><pre><span style="color: #6699cc; font-weight: bold;">var</span> arr<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=array%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:array.html"><span style="color: #004993;">Array</span></a> = <span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span><span style="color: #000000; 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> a<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=uint%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:uint.html"><span style="color: #004993;">uint</span></a> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000; font-weight: bold;">;</span> a <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight:bold;">10000000</span><span style="color: #000000; font-weight: bold;">;</span> a<span style="color: #000000; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>	arr<span style="color: #000000;">&#91;</span>a<span style="color: #000000;">&#93;</span> = a <span style="color: #000000; font-weight: bold;">;</span><span style="color: #000000;">&#125;</span></div></div></pre>
</div><br />
is eens zo snel als:<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">ActionScript 3 Code:</div>
	<pre class="alt2" style="margin:0px; padding:5px; border: 1px solid #B1B6C2; width:700px; height:132px; overflow:auto"><div dir="ltr" style="text-align:left;"><div class="actionscript3" style="font-family:monospace;"><pre><span style="color: #6699cc; font-weight: bold;">var</span> arr<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=array%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:array.html"><span style="color: #004993;">Array</span></a> = <span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span><span style="color: #000000; 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> a<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=uint%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:uint.html"><span style="color: #004993;">uint</span></a> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000; font-weight: bold;">;</span> a <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight:bold;">10000000</span><span style="color: #000000; font-weight: bold;">;</span> a<span style="color: #000000; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>	arr<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span>a<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span><span style="color: #000000;">&#125;</span></div></div></pre>
</div><br />
<b>Gebruik Vectors waar je maar kunt.</b><br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">ActionScript 3 Code:</div>
	<pre class="alt2" style="margin:0px; padding:5px; border: 1px solid #B1B6C2; width:700px; height:132px; overflow:auto"><div dir="ltr" style="text-align:left;"><div class="actionscript3" style="font-family:monospace;"><pre><span style="color: #6699cc; font-weight: bold;">var</span> arr<span style="color: #000000; font-weight: bold;">:</span>Vector<span style="color: #000000; font-weight: bold;">.&lt;</span>uint<span style="color: #000000; font-weight: bold;">&gt;</span> = <span style="color: #0033ff; font-weight: bold;">new</span> Vector<span style="color: #000000; font-weight: bold;">.&lt;</span>uint<span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; 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> a<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=uint%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:uint.html"><span style="color: #004993;">uint</span></a> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000; font-weight: bold;">;</span> a <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight:bold;">10000000</span><span style="color: #000000; font-weight: bold;">;</span> a<span style="color: #000000; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>	arr<span style="color: #000000;">&#91;</span>a<span style="color: #000000;">&#93;</span> = a <span style="color: #000000; font-weight: bold;">;</span><span style="color: #000000;">&#125;</span></div></div></pre>
</div><br />
is eens zo snel als:<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">ActionScript 3 Code:</div>
	<pre class="alt2" style="margin:0px; padding:5px; border: 1px solid #B1B6C2; width:700px; height:132px; overflow:auto"><div dir="ltr" style="text-align:left;"><div class="actionscript3" style="font-family:monospace;"><pre><span style="color: #6699cc; font-weight: bold;">var</span> arr<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=array%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:array.html"><span style="color: #004993;">Array</span></a> = <span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span><span style="color: #000000; 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> a<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=uint%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:uint.html"><span style="color: #004993;">uint</span></a> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000; font-weight: bold;">;</span> a <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight:bold;">10000000</span><span style="color: #000000; font-weight: bold;">;</span> a<span style="color: #000000; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>	arr<span style="color: #000000;">&#91;</span>a<span style="color: #000000;">&#93;</span> = a<span style="color: #000000; font-weight: bold;">;</span><span style="color: #000000;">&#125;</span></div></div></pre>
</div><br />
<b>Sla de length van je array/vector op in een variable voor je gaat loopen.</b><br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">ActionScript 3 Code:</div>
	<pre class="alt2" style="margin:0px; padding:5px; border: 1px solid #B1B6C2; width:700px; height:116px; overflow:auto"><div dir="ltr" style="text-align:left;"><div class="actionscript3" style="font-family:monospace;"><pre><span style="color: #6699cc; font-weight: bold;">var</span> l<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = arr<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">length</span><span style="color: #000000; 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: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=uint%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:uint.html"><span style="color: #004993;">uint</span></a> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000; font-weight: bold;">;</span> i <span style="color: #000000; font-weight: bold;">&lt;</span> l<span style="color: #000000; font-weight: bold;">;</span> i<span style="color: #000000; font-weight: bold;">++</span> <span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>	v2 = arr<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000000; font-weight: bold;">;</span><span style="color: #000000;">&#125;</span></div></div></pre>
</div><br />
is 5x! sneller dan:<br />
<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">ActionScript 3 Code:</div>
	<pre class="alt2" style="margin:0px; padding:5px; border: 1px solid #B1B6C2; width:700px; height:100px; overflow:auto"><div dir="ltr" style="text-align:left;"><div class="actionscript3" style="font-family:monospace;"><pre><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: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=uint%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:uint.html"><span style="color: #004993;">uint</span></a> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000; font-weight: bold;">;</span> i <span style="color: #000000; font-weight: bold;">&lt;</span> arr<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">length</span><span style="color: #000000; font-weight: bold;">;</span> i<span style="color: #000000; font-weight: bold;">++</span> <span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>	v2 = arr<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000000; font-weight: bold;">;</span><span style="color: #000000;">&#125;</span></div></div></pre>
</div><br />
<b>De 'one dot' regel.</b><br />
<br />
Als je meerdere keren een property aan wilt spreken waar je meer dan één . voor nodig hebt, sla hem dan op in een lokale variable.<br />
<br />
<i>Voorbeeld:</i><br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">ActionScript 3 Code:</div>
	<pre class="alt2" style="margin:0px; padding:5px; border: 1px solid #B1B6C2; width:700px; height:228px; overflow:auto"><div dir="ltr" style="text-align:left;"><div class="actionscript3" style="font-family:monospace;"><pre><span style="color: #6699cc; font-weight: bold;">var</span> mc<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=movieclip%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:movieclip.html"><span style="color: #004993;">MovieClip</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a target="_blank" href="http://www.google.com/search?q=movieclip%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:movieclip.html"><span style="color: #004993;">MovieClip</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>mc<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">data</span> = <span style="color: #000000;">&#123;</span><span style="color: #000000;">&#125;</span><span style="color: #000000; font-weight: bold;">;</span>mc<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">data</span><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">x</span> = <span style="color: #000000; font-weight:bold;">10</span><span style="color: #000000; font-weight: bold;">;</span><span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">value</span><span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a><span style="color: #000000; font-weight: bold;">;</span><span style="color: #6699cc; font-weight: bold;">var</span> prop<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = mc<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">data</span><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000000; 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> a<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=uint%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:uint.html"><span style="color: #004993;">uint</span></a> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000; font-weight: bold;">;</span> a <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight:bold;">10000000</span><span style="color: #000000; font-weight: bold;">;</span> a<span style="color: #000000; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span><span style="color: #004993;">value</span> = prop<span style="color: #000000; font-weight: bold;">;</span><span style="color: #000000;">&#125;</span></div></div></pre>
</div><br />
is 10x! zo snel als:<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">ActionScript 3 Code:</div>
	<pre class="alt2" style="margin:0px; padding:5px; border: 1px solid #B1B6C2; width:700px; height:196px; overflow:auto"><div dir="ltr" style="text-align:left;"><div class="actionscript3" style="font-family:monospace;"><pre><span style="color: #6699cc; font-weight: bold;">var</span> mc<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=movieclip%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:movieclip.html"><span style="color: #004993;">MovieClip</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a target="_blank" href="http://www.google.com/search?q=movieclip%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:movieclip.html"><span style="color: #004993;">MovieClip</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>mc<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">data</span> = <span style="color: #000000;">&#123;</span><span style="color: #000000;">&#125;</span><span style="color: #000000; font-weight: bold;">;</span>mc<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">data</span><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">x</span> = <span style="color: #000000; font-weight:bold;">10</span><span style="color: #000000; font-weight: bold;">;</span><span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">value</span><span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a><span style="color: #000000; 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> a<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=uint%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:uint.html"><span style="color: #004993;">uint</span></a> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000; font-weight: bold;">;</span> a <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight:bold;">10000000</span><span style="color: #000000; font-weight: bold;">;</span> a<span style="color: #000000; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span><span style="color: #004993;">value</span> = mc<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">data</span><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000000; font-weight: bold;">;</span><span style="color: #000000;">&#125;</span></div></div></pre>
</div><br />
<b>Gebruik de ternary operator.</b><br />
<br />
De ternary operator is niet zozeer sneller dan een 'normaal' if statement, maar het maakt je code wel een stuk compacter en leesbaarder. Let wel op dat je het condition gedeelte altijd tussen ( ) zet. Doe je dit niet werkt je code prima, geen error aan de lucht. Maar het is 10% langzamer dan wanneer het condintion gedeelte tussen ( ) staat.<br />
<br />
Dus:<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">ActionScript 3 Code:</div>
	<pre class="alt2" style="margin:0px; padding:5px; border: 1px solid #B1B6C2; width:700px; height:84px; overflow:auto"><div dir="ltr" style="text-align:left;"><div class="actionscript3" style="font-family:monospace;"><pre>result = <span style="color: #000000;">&#40;</span>value1==value2<span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">?</span> <span style="color: #004993;">x</span> <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">y</span><span style="color: #000000; font-weight: bold;">;</span><span style="color: #999999; font-style: italic;">//ipv</span>result = value1==value2 <span style="color: #000000; font-weight: bold;">?</span> <span style="color: #004993;">x</span> <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">y</span><span style="color: #000000; font-weight: bold;">;</span></div></div></pre>
</div><br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">ActionScript 3 Code:</div>
	<pre class="alt2" style="margin:0px; padding:5px; border: 1px solid #B1B6C2; width:700px; height:148px; overflow:auto"><div dir="ltr" style="text-align:left;"><div class="actionscript3" style="font-family:monospace;"><pre><span style="color: #6699cc; font-weight: bold;">var</span> v1<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = <span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">10</span><span style="color: #000000; font-weight: bold;">;</span><span style="color: #6699cc; font-weight: bold;">var</span> v2<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a><span style="color: #000000; font-weight: bold;">;</span><span style="color: #999999; font-style: italic;">//dit:</span>v2 = <span style="color: #000000;">&#40;</span>v1 <span style="color: #000000; font-weight: bold;">&lt;</span> 0<span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">?</span> <span style="color: #000000; font-weight: bold;">-</span>v1 <span style="color: #000000; font-weight: bold;">:</span> v1<span style="color: #000000; font-weight: bold;">;</span><span style="color: #999999; font-style: italic;">// is iets langzamer dan:</span><span style="color: #000000;">&#40;</span>v1 <span style="color: #000000; font-weight: bold;">&lt;</span> 0<span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">?</span> v2 = <span style="color: #000000; font-weight: bold;">-</span>v1 <span style="color: #000000; font-weight: bold;">:</span> v2 = v1<span style="color: #000000; font-weight: bold;">;</span></div></div></pre>
</div><br />
In het bovenstaande voorbeeld gebruik ik persoonlijk altijd de langzamere methode.<br />
We praten hier over een paar milliseconden op 10000000 checks. En ik vind de eerste methode een stuk leesbaarder. <br />
<br />
<b>Nog een lijstje met tips:</b><br />
<br />
* Gebruik een zo strikt mogelijk datatype.<br />
* Enterframes zijn sneller dan timers.<br />
* Gebruik zo min mogelijk enterframe handlers en/of timer handlers.<br />
* Constanten zijn sneller dan variablen.<br />
* Zet geen 'zware' code in je constructors. Maak liever een init functie die je aanroept in je constructor.<br />
* Callbacks meegeven is sneller dan events dispatchen.<br />
* Test zelf hoe bepaalde optimalisaties uitpakken in jouw project.<br />
* Draaf niet te ver door met optimaliseren. Een paar milliseconden winst in ruil voor een moeilijk leesbare code zou ik niet aan willen raden.<br />
<br />
<br />
<i>Stellingen in bovenstaand document zijn gebaseerd op testresultaten behaald met de flash 10.1 IDE player van CS5 op Windows Vista 64bit.<br />
Vooral in flash player 9 kunnen de resultaten nog wel eens anders uitpakken. Test daarom altijd zelf en neem niet zomaar aan wat je op internet leest.</i></div>

]]></content:encoded>
			<dc:creator>marcvz</dc:creator>
			<guid isPermaLink="true">http://www.flashfocus.nl/forum/blog.php?b=41</guid>
		</item>
		<item>
			<title>FF-Experiment voorbeeld :  SFX</title>
			<link>http://www.flashfocus.nl/forum/blog.php?b=40</link>
			<pubDate>Tue, 13 Apr 2010 12:56:24 GMT</pubDate>
			<description><![CDATA[Image: http://www.neuroproductions.be/ff/sfxpush.png  
 
Voor het eerste FlashFocus experiment (http://www.flashfocus.nl/forum/showthread.php?p=395084) een voorbeeld met particles en bitmapdata. 
 
http://www.neuroproductions.be/ff/FFparticles.swf 
 
 
Ik ga er wel vanuit dat je al een redelijke basis kennis hebt als je hieraan begint. Ik geef enkel een korte uitleg voor de iets 'moeilijkere' stukken. Maar als je specifieke vragen over dit voorbeeld hebt, mag je die natuurlijk altijd hier...]]></description>
			<content:encoded><![CDATA[<div><img src="http://www.neuroproductions.be/ff/sfxpush.png" border="0" alt="" /><br />
<br />
Voor het eerste <a href="http://www.flashfocus.nl/forum/showthread.php?p=395084" target="_blank">FlashFocus experiment</a> een voorbeeld met particles en bitmapdata.<br />
<br />
<a href="http://www.neuroproductions.be/ff/FFparticles.swf" target="_blank">http://www.neuroproductions.be/ff/FFparticles.swf</a><br />
<br />
<br />
Ik ga er wel vanuit dat je al een redelijke basis kennis hebt als je hieraan begint. Ik geef enkel een korte uitleg voor de iets 'moeilijkere' stukken. Maar als je specifieke vragen over dit voorbeeld hebt, mag je die natuurlijk altijd hier stellen. :)<br />
<br />
<br />
De sourcecode kan je <a href="http://www.flashfocus.nl/forum/attachment.php?attachmentid=9557&amp;d=1270726490" target="_blank">hier</a> downloaden.<br />
<br />
<font size="3">De 2 classe</font><br />
<br />
Main class  ( FFparticles.as)<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">ActionScript 3 Code:</div>
	<pre class="alt2" style="margin:0px; padding:5px; border: 1px solid #B1B6C2; width:700px; height:516px; overflow:auto"><div dir="ltr" style="text-align:left;"><div class="actionscript3" style="font-family:monospace;"><pre><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.events</span><span style="color: #000000; font-weight: bold;">.</span><a target="_blank" href="http://www.google.com/search?q=mouseevent%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:mouseevent.html"><span style="color: #004993;">MouseEvent</span></a><span style="color: #000000; font-weight: bold;">;</span>	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000000; font-weight: bold;">.</span><a target="_blank" href="http://www.google.com/search?q=bitmap%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:bitmap.html"><span style="color: #004993;">Bitmap</span></a><span style="color: #000000; font-weight: bold;">;</span>	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000000; font-weight: bold;">.</span><a target="_blank" href="http://www.google.com/search?q=bitmapdata%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:bitmapdata.html"><span style="color: #004993;">BitmapData</span></a><span style="color: #000000; font-weight: bold;">;</span>	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000000; font-weight: bold;">.</span><a target="_blank" href="http://www.google.com/search?q=bitmapdatachannel%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:bitmapdatachannel.html"><span style="color: #004993;">BitmapDataChannel</span></a><span style="color: #000000; font-weight: bold;">;</span>	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000000; font-weight: bold;">.</span><a target="_blank" href="http://www.google.com/search?q=sprite%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:sprite.html"><span style="color: #004993;">Sprite</span></a><span style="color: #000000; font-weight: bold;">;</span>	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000000; font-weight: bold;">.</span><a target="_blank" href="http://www.google.com/search?q=stagealign%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:stagealign.html"><span style="color: #004993;">StageAlign</span></a><span style="color: #000000; font-weight: bold;">;</span>	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000000; font-weight: bold;">.</span><a target="_blank" href="http://www.google.com/search?q=stagescalemode%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:stagescalemode.html"><span style="color: #004993;">StageScaleMode</span></a><span style="color: #000000; font-weight: bold;">;</span>	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span><span style="color: #000000; font-weight: bold;">.</span><a target="_blank" href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><span style="color: #000000; font-weight: bold;">;</span>	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.filters</span><span style="color: #000000; font-weight: bold;">.</span><a target="_blank" href="http://www.google.com/search?q=blurfilter%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:blurfilter.html"><span style="color: #004993;">BlurFilter</span></a><span style="color: #000000; font-weight: bold;">;</span>	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.geom</span><span style="color: #000000; font-weight: bold;">.</span><a target="_blank" href="http://www.google.com/search?q=colortransform%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:colortransform.html"><span style="color: #004993;">ColorTransform</span></a><span style="color: #000000; font-weight: bold;">;</span>			<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> FFparticles <span style="color: #0033ff; font-weight: bold;">extends</span> <a target="_blank" href="http://www.google.com/search?q=sprite%20inurl:http://livedocs.adobe.com/flex/3/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> bmd <span style="color: #000000; font-weight: bold;">:</span> <a target="_blank" href="http://www.google.com/search?q=bitmapdata%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:bitmapdata.html"><span style="color: #004993;">BitmapData</span></a><span style="color: #000000; font-weight: bold;">;</span>		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> bmdPerlin <span style="color: #000000; font-weight: bold;">:</span> <a target="_blank" href="http://www.google.com/search?q=bitmapdata%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:bitmapdata.html"><span style="color: #004993;">BitmapData</span></a><span style="color: #000000; font-weight: bold;">;</span>		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> sizeH <span style="color: #000000; font-weight: bold;">:</span> <a target="_blank" href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a> = <span style="color: #000000; font-weight:bold;">400</span><span style="color: #000000; font-weight: bold;">;</span>		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> sizeW <span style="color: #000000; font-weight: bold;">:</span> <a target="_blank" href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a> = <span style="color: #000000; font-weight:bold;">600</span><span style="color: #000000; font-weight: bold;">;</span>		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> particles <span style="color: #000000; font-weight: bold;">:</span> Vector<span style="color: #000000; font-weight: bold;">.&lt;</span>Particle<span style="color: #000000; font-weight: bold;">&gt;</span> = <span style="color: #0033ff; font-weight: bold;">new</span> Vector<span style="color: #000000; font-weight: bold;">.&lt;</span>Particle<span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>						<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">colorTransform</span> <span style="color: #000000; font-weight: bold;">:</span> <a target="_blank" href="http://www.google.com/search?q=colortransform%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:colortransform.html"><span style="color: #004993;">ColorTransform</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a target="_blank" href="http://www.google.com/search?q=colortransform%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:colortransform.html"><span style="color: #004993;">ColorTransform</span></a><span style="color: #000000;">&#40;</span>0<span style="color: #000000; font-weight: bold;">.</span>999<span style="color: #000000; font-weight: bold;">,</span> 0<span style="color: #000000; font-weight: bold;">.</span>95<span style="color: #000000; font-weight: bold;">,</span> 0<span style="color: #000000; font-weight: bold;">.</span>6<span style="color: #000000; font-weight: bold;">,</span> 1<span style="color: #000000; font-weight: bold;">,</span> 0<span style="color: #000000; font-weight: bold;">,</span> 0<span style="color: #000000; font-weight: bold;">,</span> 0<span style="color: #000000; font-weight: bold;">,</span> 0<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">filter</span> <span style="color: #000000; font-weight: bold;">:</span> <a target="_blank" href="http://www.google.com/search?q=blurfilter%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:blurfilter.html"><span style="color: #004993;">BlurFilter</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a target="_blank" href="http://www.google.com/search?q=blurfilter%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:blurfilter.html"><span style="color: #004993;">BlurFilter</span></a><span style="color: #000000;">&#40;</span>2<span style="color: #000000; font-weight: bold;">,</span>2<span style="color: #000000; font-weight: bold;">,</span> 1<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>								<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> FFparticles<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>		<span style="color: #000000;">&#123;</span>			<span style="color: #004993;">stage</span><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">scaleMode</span> = <a target="_blank" href="http://www.google.com/search?q=stagescalemode%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:stagescalemode.html"><span style="color: #004993;">StageScaleMode</span></a><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">NO_SCALE</span><span style="color: #000000; font-weight: bold;">;</span>			<span style="color: #004993;">stage</span><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">align</span> = <a target="_blank" href="http://www.google.com/search?q=stagealign%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:stagealign.html"><span style="color: #004993;">StageAlign</span></a><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">TOP_LEFT</span><span style="color: #000000; font-weight: bold;">;</span>						bmd = <span style="color: #0033ff; font-weight: bold;">new</span> <a target="_blank" href="http://www.google.com/search?q=bitmapdata%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:bitmapdata.html"><span style="color: #004993;">BitmapData</span></a><span style="color: #000000;">&#40;</span>sizeW<span style="color: #000000; font-weight: bold;">,</span> sizeH<span style="color: #000000; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000000; font-weight: bold;">,</span> 0<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>			<span style="color: #6699cc; font-weight: bold;">var</span> bm <span style="color: #000000; font-weight: bold;">:</span> <a target="_blank" href="http://www.google.com/search?q=bitmap%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:bitmap.html"><span style="color: #004993;">Bitmap</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a target="_blank" href="http://www.google.com/search?q=bitmap%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:bitmap.html"><span style="color: #004993;">Bitmap</span></a><span style="color: #000000;">&#40;</span>bmd<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>						<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>bm<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>						bmdPerlin = <span style="color: #0033ff; font-weight: bold;">new</span> <a target="_blank" href="http://www.google.com/search?q=bitmapdata%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:bitmapdata.html"><span style="color: #004993;">BitmapData</span></a><span style="color: #000000;">&#40;</span>sizeW<span style="color: #000000; font-weight: bold;">,</span> sizeH<span style="color: #000000; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000000; font-weight: bold;">,</span> 0<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>						<span style="color: #6699cc; font-weight: bold;">var</span> bmPerlin <span style="color: #000000; font-weight: bold;">:</span> <a target="_blank" href="http://www.google.com/search?q=bitmap%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:bitmap.html"><span style="color: #004993;">Bitmap</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a target="_blank" href="http://www.google.com/search?q=bitmap%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:bitmap.html"><span style="color: #004993;">Bitmap</span></a><span style="color: #000000;">&#40;</span>bmdPerlin<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>			bmdPerlin<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">perlinNoise</span><span style="color: #000000;">&#40;</span>200<span style="color: #000000; font-weight: bold;">,</span> 200<span style="color: #000000; font-weight: bold;">,</span> 5<span style="color: #000000; font-weight: bold;">,</span> <a target="_blank" href="http://www.google.com/search?q=math%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:math.html"><span style="color: #004993;">Math</span></a><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">*</span> <a target="_blank" href="http://www.google.com/search?q=uint%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:uint.html"><span style="color: #004993;">uint</span></a><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">MAX_VALUE</span><span style="color: #000000; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000000; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000; font-weight: bold;">,</span> <a target="_blank" href="http://www.google.com/search?q=bitmapdatachannel%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:bitmapdatachannel.html"><span style="color: #004993;">BitmapDataChannel</span></a><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">RED</span> <span style="color: #000000; font-weight: bold;">|</span> <a target="_blank" href="http://www.google.com/search?q=bitmapdatachannel%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:bitmapdatachannel.html"><span style="color: #004993;">BitmapDataChannel</span></a><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">GREEN</span><span style="color: #000000; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>			bmPerlin<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">x</span> = sizeW<span style="color: #000000; font-weight: bold;">;</span>			<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>bmPerlin<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>									buildParticles<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>			<span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a target="_blank" href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">ENTER_FRAME</span><span style="color: #000000; font-weight: bold;">,</span> <span style="color: #004993;">loop</span><span style="color: #000000; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000000; font-weight: bold;">,</span> 0<span style="color: #000000; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>			<span style="color: #004993;">stage</span><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a target="_blank" href="http://www.google.com/search?q=mouseevent%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:mouseevent.html"><span style="color: #004993;">MouseEvent</span></a><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">CLICK</span><span style="color: #000000; font-weight: bold;">,</span> refreshNoise<span style="color: #000000;">&#41;</span><span style="color: #000000; 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> refreshNoise<span style="color: #000000;">&#40;</span>event <span style="color: #000000; font-weight: bold;">:</span> <a target="_blank" href="http://www.google.com/search?q=mouseevent%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:mouseevent.html"><span style="color: #004993;">MouseEvent</span></a><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span>		<span style="color: #000000;">&#123;</span>			bmdPerlin<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">perlinNoise</span><span style="color: #000000;">&#40;</span>200<span style="color: #000000; font-weight: bold;">,</span> 200<span style="color: #000000; font-weight: bold;">,</span> 5<span style="color: #000000; font-weight: bold;">,</span> <a target="_blank" href="http://www.google.com/search?q=math%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:math.html"><span style="color: #004993;">Math</span></a><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">*</span> <a target="_blank" href="http://www.google.com/search?q=uint%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:uint.html"><span style="color: #004993;">uint</span></a><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">MAX_VALUE</span><span style="color: #000000; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000000; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000; font-weight: bold;">,</span> <a target="_blank" href="http://www.google.com/search?q=bitmapdatachannel%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:bitmapdatachannel.html"><span style="color: #004993;">BitmapDataChannel</span></a><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">RED</span> <span style="color: #000000; font-weight: bold;">|</span> <a target="_blank" href="http://www.google.com/search?q=bitmapdatachannel%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:bitmapdatachannel.html"><span style="color: #004993;">BitmapDataChannel</span></a><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">GREEN</span><span style="color: #000000; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000000;">&#41;</span><span style="color: #000000; 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;">loop</span><span style="color: #000000;">&#40;</span>event <span style="color: #000000; font-weight: bold;">:</span> <a target="_blank" href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span>		<span style="color: #000000;">&#123;</span>									bmd<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">lock</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>			bmd<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">colorTransform</span><span style="color: #000000;">&#40;</span>bmd<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">rect</span><span style="color: #000000; font-weight: bold;">,</span> <span style="color: #004993;">colorTransform</span><span style="color: #000000;">&#41;</span>						<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #0033ff; font-weight: bold;">each</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> part <span style="color: #000000; font-weight: bold;">:</span> Particle <span style="color: #0033ff; font-weight: bold;">in</span> particles<span style="color: #000000;">&#41;</span>			<span style="color: #000000;">&#123;</span>								<span style="color: #6699cc; font-weight: bold;">var</span> kleur <span style="color: #000000; font-weight: bold;">:</span> <a target="_blank" href="http://www.google.com/search?q=uint%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:uint.html"><span style="color: #004993;">uint</span></a> = bmdPerlin<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">getPixel</span><span style="color: #000000;">&#40;</span>part<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000000; font-weight: bold;">,</span> part<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>				<span style="color: #6699cc; font-weight: bold;">var</span> rood <span style="color: #000000; font-weight: bold;">:</span> <a target="_blank" href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a> = kleur <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> 16 <span style="color: #000000; font-weight: bold;">&amp;</span> 0xFF<span style="color: #000000; font-weight: bold;">;</span>				<span style="color: #6699cc; font-weight: bold;">var</span> groen <span style="color: #000000; font-weight: bold;">:</span> <a target="_blank" href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a> = kleur <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> 8 <span style="color: #000000; font-weight: bold;">&amp;</span> 0xFF<span style="color: #000000; font-weight: bold;">;</span>				part<span style="color: #000000; font-weight: bold;">.</span>speedx <span style="color: #000000; font-weight: bold;">+</span>= <span style="color: #000000;">&#40;</span>rood <span style="color: #000000; font-weight: bold;">-</span> 128<span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight:bold;">0.002</span><span style="color: #000000; font-weight: bold;">;</span>				part<span style="color: #000000; font-weight: bold;">.</span>speedy <span style="color: #000000; font-weight: bold;">+</span>= <span style="color: #000000;">&#40;</span>groen <span style="color: #000000; font-weight: bold;">-</span> 128<span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight:bold;">0.002</span><span style="color: #000000; font-weight: bold;">;</span>																				part<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">x</span> <span style="color: #000000; font-weight: bold;">+</span>= part<span style="color: #000000; font-weight: bold;">.</span>speedx<span style="color: #000000; font-weight: bold;">;</span>				part<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">y</span> <span style="color: #000000; font-weight: bold;">+</span>= part<span style="color: #000000; font-weight: bold;">.</span>speedy <span style="color: #000000; font-weight: bold;">;</span>								part<span style="color: #000000; font-weight: bold;">.</span>speedx <span style="color: #000000; font-weight: bold;">*</span>= <span style="color: #000000; font-weight:bold;">0.985</span><span style="color: #000000; font-weight: bold;">;</span>				part<span style="color: #000000; font-weight: bold;">.</span>speedy <span style="color: #000000; font-weight: bold;">*</span>= <span style="color: #000000; font-weight:bold;">0.985</span><span style="color: #000000; font-weight: bold;">;</span>												<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>part<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">x</span> <span style="color: #000000; font-weight: bold;">&gt;</span> sizeW<span style="color: #000000;">&#41;</span>				<span style="color: #000000;">&#123;</span>					part<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">x</span> <span style="color: #000000; font-weight: bold;">-</span>= sizeW<span style="color: #000000; font-weight: bold;">;</span>				<span style="color: #000000;">&#125;</span><span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>part<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">x</span> <span style="color: #000000; font-weight: bold;">&lt;</span> 0<span style="color: #000000;">&#41;</span>				<span style="color: #000000;">&#123;</span>					part<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">x</span> <span style="color: #000000; font-weight: bold;">+</span>= sizeW<span style="color: #000000; font-weight: bold;">;</span>				<span style="color: #000000;">&#125;</span>				<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>part<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">y</span> <span style="color: #000000; font-weight: bold;">&gt;</span> sizeH<span style="color: #000000;">&#41;</span>				<span style="color: #000000;">&#123;</span>					part<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">y</span> <span style="color: #000000; font-weight: bold;">-</span>= sizeH<span style="color: #000000; font-weight: bold;">;</span>				<span style="color: #000000;">&#125;</span><span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>part<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">y</span> <span style="color: #000000; font-weight: bold;">&lt;</span> 0<span style="color: #000000;">&#41;</span>				<span style="color: #000000;">&#123;</span>					part<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">y</span> <span style="color: #000000; font-weight: bold;">+</span>= sizeH<span style="color: #000000; font-weight: bold;">;</span>				<span style="color: #000000;">&#125;</span>												bmd<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">setPixel</span><span style="color: #000000;">&#40;</span>part<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000000; font-weight: bold;">,</span> part<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000000; font-weight: bold;">,</span> 0xFFFFFF<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>			<span style="color: #000000;">&#125;</span>			bmd<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">applyFilter</span><span style="color: #000000;">&#40;</span>bmd<span style="color: #000000; font-weight: bold;">,</span> bmd<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">rect</span><span style="color: #000000; font-weight: bold;">,</span> bmd<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">rect</span><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">topLeft</span><span style="color: #000000; font-weight: bold;">,</span> <span style="color: #004993;">filter</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>			bmd<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">unlock</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; 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> buildParticles<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; 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;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> i <span style="color: #000000; font-weight: bold;">:</span> <a target="_blank" href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000; font-weight: bold;">;</span>i <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight:bold;">20000</span><span style="color: #000000; font-weight: bold;">;++</span>i<span style="color: #000000;">&#41;</span>			<span style="color: #000000;">&#123;</span>				<span style="color: #6699cc; font-weight: bold;">var</span> part <span style="color: #000000; font-weight: bold;">:</span> Particle = <span style="color: #0033ff; font-weight: bold;">new</span> Particle<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>				part<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">x</span> = <a target="_blank" href="http://www.google.com/search?q=math%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:math.html"><span style="color: #004993;">Math</span></a><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">*</span> sizeW<span style="color: #000000; font-weight: bold;">;</span>				part<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">y</span> = <a target="_blank" href="http://www.google.com/search?q=math%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:math.html"><span style="color: #004993;">Math</span></a><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">*</span> sizeH<span style="color: #000000; font-weight: bold;">;</span>								particles<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span>part<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>			<span style="color: #000000;">&#125;</span>						particles<span style="color: #000000; font-weight: bold;">.</span>fixed = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000; font-weight: bold;">;</span>		<span style="color: #000000;">&#125;</span>	<span style="color: #000000;">&#125;</span><span style="color: #000000;">&#125;</span></div></div></pre>
</div>particle class  ( Particle.as)<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">ActionScript 3 Code:</div>
	<pre class="alt2" style="margin:0px; padding:5px; border: 1px solid #B1B6C2; width:700px; height:244px; overflow:auto"><div dir="ltr" style="text-align:left;"><div class="actionscript3" style="font-family:monospace;"><pre><span style="color: #9900cc; font-weight: bold;">package</span><span style="color: #000000;">&#123;</span>			<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> Particle	<span style="color: #000000;">&#123;</span>		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">x</span><span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a><span style="color: #000000; font-weight: bold;">;</span>		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">y</span><span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a><span style="color: #000000; font-weight: bold;">;</span>				<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> speedx<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> =<span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000; font-weight: bold;">;</span>		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> speedy<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> =<span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000; font-weight: bold;">;</span>	<span style="color: #000000;">&#125;</span><span style="color: #000000;">&#125;</span></div></div></pre>
</div><font size="3">Een korte uitleg</font><br />
<br />
Als je heel veel particles wil gebruiken, kan je best geen individuele display objecten gebruiken, maar render je ze beter in een bitmap. <br />
Hier doe ik dat door elke frame  de pixels op de positie van de particles wit te kleuren.<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">ActionScript 3 Code:</div>
	<pre class="alt2" style="margin:0px; padding:5px; border: 1px solid #B1B6C2; width:700px; height:100px; overflow:auto"><div dir="ltr" style="text-align:left;"><div class="actionscript3" style="font-family:monospace;"><pre><span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #0033ff; font-weight: bold;">each</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> part <span style="color: #000000; font-weight: bold;">:</span> Particle <span style="color: #0033ff; font-weight: bold;">in</span> particles<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>	bmd<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">setPixel</span><span style="color: #000000;">&#40;</span>part<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000000; font-weight: bold;">,</span> part<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000000; font-weight: bold;">,</span> 0xFFFFFF<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span><span style="color: #000000;">&#125;</span></div></div></pre>
</div>Om de richting te bepalen hoe de particles vliegen gebruiken ik perlin noise<br />
Ik maak eerst een perlinnoise bitmap met enkel een rood en een groen waarde.<br />
we geven de perlin noise ook een random seed, zodat de particles elke keer als we refreshen anders vliegen<br />
<br />
Doormiddel van getPixel kijk ik welke kleurwaarde perlinnoise bitmap heeft op de posite van de particle.<br />
<br />
Die kleur splitsen ik op in rood en groen waarde. De rood waarde bepaald de beweging in de x richting en het groen waarde de beweging in de y richting<br />
<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">ActionScript 3 Code:</div>
	<pre class="alt2" style="margin:0px; padding:5px; border: 1px solid #B1B6C2; width:700px; height:148px; overflow:auto"><div dir="ltr" style="text-align:left;"><div class="actionscript3" style="font-family:monospace;"><pre>bmdPerlin<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">perlinNoise</span><span style="color: #000000;">&#40;</span>200<span style="color: #000000; font-weight: bold;">,</span> 200<span style="color: #000000; font-weight: bold;">,</span> 5<span style="color: #000000; font-weight: bold;">,</span> <a target="_blank" href="http://www.google.com/search?q=math%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:math.html"><span style="color: #004993;">Math</span></a><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">*</span> <a target="_blank" href="http://www.google.com/search?q=uint%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:uint.html"><span style="color: #004993;">uint</span></a><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">MAX_VALUE</span><span style="color: #000000; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000000; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000; font-weight: bold;">,</span> <a target="_blank" href="http://www.google.com/search?q=bitmapdatachannel%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:bitmapdatachannel.html"><span style="color: #004993;">BitmapDataChannel</span></a><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">RED</span> <span style="color: #000000; font-weight: bold;">|</span> <a target="_blank" href="http://www.google.com/search?q=bitmapdatachannel%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:bitmapdatachannel.html"><span style="color: #004993;">BitmapDataChannel</span></a><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">GREEN</span><span style="color: #000000; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span><span style="color: #6699cc; font-weight: bold;">var</span> kleur <span style="color: #000000; font-weight: bold;">:</span> <a target="_blank" href="http://www.google.com/search?q=uint%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:uint.html"><span style="color: #004993;">uint</span></a> = bmdPerlin<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">getPixel</span><span style="color: #000000;">&#40;</span>part<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000000; font-weight: bold;">,</span> part<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span><span style="color: #6699cc; font-weight: bold;">var</span> rood <span style="color: #000000; font-weight: bold;">:</span> <a target="_blank" href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a> = kleur <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> 16 <span style="color: #000000; font-weight: bold;">&amp;</span> 0xFF<span style="color: #000000; font-weight: bold;">;</span><span style="color: #6699cc; font-weight: bold;">var</span> groen <span style="color: #000000; font-weight: bold;">:</span> <a target="_blank" href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a> = kleur <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> 8 <span style="color: #000000; font-weight: bold;">&amp;</span> 0xFF<span style="color: #000000; font-weight: bold;">;</span>part<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">x</span> <span style="color: #000000; font-weight: bold;">+</span>= <span style="color: #000000;">&#40;</span>rood <span style="color: #000000; font-weight: bold;">-</span> 128<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">10</span><span style="color: #000000; font-weight: bold;">;</span>part<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">y</span> <span style="color: #000000; font-weight: bold;">+</span>= <span style="color: #000000;">&#40;</span>groen <span style="color: #000000; font-weight: bold;">-</span> 128<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">/</span>10 <span style="color: #000000; font-weight: bold;">;</span></div></div></pre>
</div>Dit werkt, maar op deze manier komen de particles al snel tot stilstand in hun ideale positie.<br />
Dit kunnen we opllosen door ipv de rood en groen waarde te gebruiken voor de verplaatsing, deze te gebruiken voor de versnelling. We tellen ze dus op bij de snelheid. Om de snelheid te dempen voeg ik nog een soort van wrijving toe (de *0.985 ). Die waarde 0.002 en 0.985 zijn proefondervindelijk gekozen. wijzigingen hierin geven een ander resultaat.<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">ActionScript 3 Code:</div>
	<pre class="alt2" style="margin:0px; padding:5px; border: 1px solid #B1B6C2; width:700px; height:164px; overflow:auto"><div dir="ltr" style="text-align:left;"><div class="actionscript3" style="font-family:monospace;"><pre>part<span style="color: #000000; font-weight: bold;">.</span>speedx <span style="color: #000000; font-weight: bold;">+</span>= <span style="color: #000000;">&#40;</span>rood <span style="color: #000000; font-weight: bold;">-</span> 128<span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight:bold;">0.002</span><span style="color: #000000; font-weight: bold;">;</span>part<span style="color: #000000; font-weight: bold;">.</span>speedy <span style="color: #000000; font-weight: bold;">+</span>= <span style="color: #000000;">&#40;</span>groen <span style="color: #000000; font-weight: bold;">-</span> 128<span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight:bold;">0.002</span><span style="color: #000000; font-weight: bold;">;</span>part<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">x</span> <span style="color: #000000; font-weight: bold;">+</span>= part<span style="color: #000000; font-weight: bold;">.</span>speedx<span style="color: #000000; font-weight: bold;">;</span>part<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">y</span> <span style="color: #000000; font-weight: bold;">+</span>= part<span style="color: #000000; font-weight: bold;">.</span>speedy <span style="color: #000000; font-weight: bold;">;</span>part<span style="color: #000000; font-weight: bold;">.</span>speedx <span style="color: #000000; font-weight: bold;">*</span>= <span style="color: #000000; font-weight:bold;">0.985</span><span style="color: #000000; font-weight: bold;">;</span>part<span style="color: #000000; font-weight: bold;">.</span>speedy <span style="color: #000000; font-weight: bold;">*</span>= <span style="color: #000000; font-weight:bold;">0.985</span><span style="color: #000000; font-weight: bold;">;</span></div></div></pre>
</div>Om de oude particles te laten weg te faden + om een trail effect te krijgen, bluren we de nog eens bitmap elke frame.<br />
<br />
De keur van de trails wijzig ik door elke frame de volledige bitmap te laten colortransformen.<br />
<br />
De colortransform werkt door de rood groen en blauw kleur waarde van elke pixel te vermenigvuldigen <br />
we beginnen met wit 0xFFFFFF= rood 0xFF + groen0xFF  + blauw 0xFF . Door de blauw waarde te vermenigvuldigen met een kleiner getal dan de rood en de groen waarde, daalt deze erg snel, en krijg je iets als 0xFFFF00 =geel, Het zelfde effect heb je met het verschil tussen de rood en groen multiplier , zodat je daarna ongeveer 0xFF0000 = rood krijgt. Op die manier fade de witte pixels van wit naar geel naar rood naar zwart. Door de multipliers te wijzigen kan je andere kleuren bekomen. <br />
<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">ActionScript 3 Code:</div>
	<pre class="alt2" style="margin:0px; padding:5px; border: 1px solid #B1B6C2; width:700px; height:132px; overflow:auto"><div dir="ltr" style="text-align:left;"><div class="actionscript3" style="font-family:monospace;"><pre><span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">colorTransform</span> <span style="color: #000000; font-weight: bold;">:</span> <a target="_blank" href="http://www.google.com/search?q=colortransform%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:colortransform.html"><span style="color: #004993;">ColorTransform</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a target="_blank" href="http://www.google.com/search?q=colortransform%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:colortransform.html"><span style="color: #004993;">ColorTransform</span></a><span style="color: #000000;">&#40;</span>0<span style="color: #000000; font-weight: bold;">.</span>999<span style="color: #000000; font-weight: bold;">,</span> 0<span style="color: #000000; font-weight: bold;">.</span>95<span style="color: #000000; font-weight: bold;">,</span> 0<span style="color: #000000; font-weight: bold;">.</span>6<span style="color: #000000; font-weight: bold;">,</span> 1<span style="color: #000000; font-weight: bold;">,</span> 0<span style="color: #000000; font-weight: bold;">,</span> 0<span style="color: #000000; font-weight: bold;">,</span> 0<span style="color: #000000; font-weight: bold;">,</span> 0<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span><span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">filter</span> <span style="color: #000000; font-weight: bold;">:</span> <a target="_blank" href="http://www.google.com/search?q=blurfilter%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:blurfilter.html"><span style="color: #004993;">BlurFilter</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a target="_blank" href="http://www.google.com/search?q=blurfilter%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:blurfilter.html"><span style="color: #004993;">BlurFilter</span></a><span style="color: #000000;">&#40;</span>2<span style="color: #000000; font-weight: bold;">,</span>2<span style="color: #000000; font-weight: bold;">,</span> 1<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>bmd<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">colorTransform</span><span style="color: #000000;">&#40;</span>bmd<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">rect</span><span style="color: #000000; font-weight: bold;">,</span> <span style="color: #004993;">colorTransform</span><span style="color: #000000;">&#41;</span>bmd<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">applyFilter</span><span style="color: #000000;">&#40;</span>bmd<span style="color: #000000; font-weight: bold;">,</span> bmd<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">rect</span><span style="color: #000000; font-weight: bold;">,</span> bmd<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">rect</span><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">topLeft</span><span style="color: #000000; font-weight: bold;">,</span> <span style="color: #004993;">filter</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span></div></div></pre>
</div>Je kan hier een hoop variaties op maken door het perlin noise te manipuleren (of zelfs een andere bitmap te gebruiken)  Of door de berekening van de snelheid wat te wijzigen en met zijn parameters te spelen. <br />
<br />
Veel plezier met dit experiment! Heb je leuke ideeën opgedaan en/of er je eigen experiment van gemaakt? <br />
<a href="http://www.flashfocus.nl/forum/showthread.php?p=395084" target="_blank">Post jouw inzending hier</a>!</div>

]]></content:encoded>
			<dc:creator>Neuro</dc:creator>
			<guid isPermaLink="true">http://www.flashfocus.nl/forum/blog.php?b=40</guid>
		</item>
		<item>
			<title>FlashDevelop Event Templates</title>
			<link>http://www.flashfocus.nl/forum/blog.php?b=39</link>
			<pubDate>Tue, 06 Apr 2010 07:24:02 GMT</pubDate>
			<description><![CDATA[Dit is geen superuitgebreidde blog, maar meer een handigheid voor FlashDevelop-gebruikers. Ik heb een aantal templates gemaakt die je kunt gebruiken om makkelijk events met parameters (met een mini-wizard) aan te maken:  
 
Image: http://projects.stroep.nl/flashdevelop/event-templates.png  (http://projects.stroep.nl/flashdevelop/) 
http://projects.stroep.nl/flashdevelop/ 
 
*Hoe te installeren* 
 
Ga naar FlashDevelop > Tools > Application files 
  - Ga naar templates/AS3Project 
  - Maak een...]]></description>
			<content:encoded><![CDATA[<div>Dit is geen superuitgebreidde blog, maar meer een handigheid voor FlashDevelop-gebruikers. Ik heb een aantal templates gemaakt die je kunt gebruiken om makkelijk events met parameters (met een mini-wizard) aan te maken: <br />
<br />
<a href="http://projects.stroep.nl/flashdevelop/" target="_blank"><img src="http://projects.stroep.nl/flashdevelop/event-templates.png" border="0" alt="" /></a><br />
<a href="http://projects.stroep.nl/flashdevelop/" target="_blank">http://projects.stroep.nl/flashdevelop/</a><br />
<br />
<b>Hoe te installeren</b><br />
<br />
Ga naar <i>FlashDevelop &gt; Tools &gt; Application files</i><br />
  - Ga naar <i>templates/AS3Project</i><br />
  - Maak een folder, noem deze '<i>Events</i>' <br />
  - Plaats de bestanden uit de zip in die folder<br />
  - Herstart FlashDevelop</div>

]]></content:encoded>
			<dc:creator>mknol</dc:creator>
			<guid isPermaLink="true">http://www.flashfocus.nl/forum/blog.php?b=39</guid>
		</item>
		<item>
			<title>Sorteren op datum, UTC string</title>
			<link>http://www.flashfocus.nl/forum/blog.php?b=37</link>
			<pubDate>Tue, 23 Feb 2010 16:51:31 GMT</pubDate>
			<description><![CDATA[Ik ben bezig een eenvoudige class te maken om tweets in een swf te tonen. 
De bestaande API's vind ik wat overkill voor hetgeen ik zoek. Ik wil gewoon een xml met de laatste 20 tweets van een bepaalde user en verder niets. 
 
Die xml kun je gewoon ophalen bij Twitter: 
http://twitter.com/statuses/user_timeline/marcvanzon.xml 
 
Omdat ik de mogelijkheid wil hebben om tweets van verschillende users in 1 array te hebben staan, moet ik sorteren op het created_at veld. 
 
Twitter geeft hier een...]]></description>
			<content:encoded><![CDATA[<div>Ik ben bezig een eenvoudige class te maken om tweets in een swf te tonen.<br />
De bestaande API's vind ik wat overkill voor hetgeen ik zoek. Ik wil gewoon een xml met de laatste 20 tweets van een bepaalde user en verder niets.<br />
<br />
Die xml kun je gewoon ophalen bij Twitter:<br />
<a href="http://twitter.com/statuses/user_timeline/marcvanzon.xml" target="_blank">http://twitter.com/statuses/user_tim...marcvanzon.xml</a><br />
<br />
Omdat ik de mogelijkheid wil hebben om tweets van verschillende users in 1 array te hebben staan, moet ik sorteren op het created_at veld.<br />
<br />
Twitter geeft hier een zogenaamde UTC string met de datum en tijd mee.<br />
Leuk en aardig, maar hoe ga je dat sorteren?<br />
Mon komt namelijk altijd voor Sat als je dat gewoon met een array.sortOn functie aanpakt.<br />
<br />
Uren gezocht op internet leverde geen eenvoudige oplossing op. Dus ben ik zelf wat gaan proberen.<br />
Uiteindelijk was het veel eenvoudiger dan ik had durven hopen.<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">ActionScript 3 Code:</div>
	<pre class="alt2" style="margin:0px; padding:5px; border: 1px solid #B1B6C2; width:700px; height:436px; overflow:auto"><div dir="ltr" style="text-align:left;"><div class="actionscript3" style="font-family:monospace;"><pre><span style="color: #999999; font-style: italic;">//we maken een array met wat datums erin volgens het UTC format</span><span style="color: #6699cc; font-weight: bold;">var</span> arr<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=array%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:array.html"><span style="color: #004993;">Array</span></a> = <span style="color: #000000;">&#91;</span><span style="color: #009900;">&quot;Tue Feb 23 00:11:49 +0000 2010&quot;</span><span style="color: #000000; font-weight: bold;">,</span> <span style="color: #009900;">&quot;Sat Jan 24 22:14:29 +0000 2009&quot;</span><span style="color: #000000; font-weight: bold;">,</span> <span style="color: #009900;">&quot;Wed Oct 28 19:41:35 +0000 2009&quot;</span><span style="color: #000000; font-weight: bold;">,</span> <span style="color: #009900;">&quot;Sun Feb 21 19:39:10 +0000 2010&quot;</span><span style="color: #000000; font-weight: bold;">,</span> <span style="color: #009900;">&quot;Sun Feb 21 19:39:11 +0000 2010&quot;</span><span style="color: #000000;">&#93;</span><span style="color: #000000; font-weight: bold;">;</span><span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>arr<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span><span style="color: #999999; font-style: italic;">//we maken een lege array. &nbsp;Hierin maken we dalijk objecten met de datum in UTC string en in miliseconden.</span><span style="color: #6699cc; font-weight: bold;">var</span> arr1<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=array%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:array.html"><span style="color: #004993;">Array</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a target="_blank" href="http://www.google.com/search?q=array%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:array.html"><span style="color: #004993;">Array</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span><span style="color: #999999; font-style: italic;">//we lopen door de array met datum</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> a <span style="color: #0033ff; font-weight: bold;">in</span> arr<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>	<span style="color: #999999; font-style: italic;">//hier maken we de objecten met UTC string en de tijd in miliseconden vanaf &nbsp;January 1, 1970, UTC.</span>	<span style="color: #999999; font-style: italic;">//uit de livedocs:</span>	<span style="color: #3f5fbf;">/*	* parse(date:String):Number	* [static] Converts a string representing a date into a number equaling the number of milliseconds elapsed since January 1, 1970, UTC.	*/</span>	arr1<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span> <span style="color: #000000;">&#123;</span> <span style="color: #004993;">date</span><span style="color: #000000; font-weight: bold;">:</span>arr<span style="color: #000000;">&#91;</span>a<span style="color: #000000;">&#93;</span><span style="color: #000000; font-weight: bold;">,</span> <span style="color: #004993;">time</span><span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=date%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:date.html"><span style="color: #004993;">Date</span></a><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">parse</span><span style="color: #000000;">&#40;</span>arr<span style="color: #000000;">&#91;</span>a<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#125;</span> <span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span><span style="color: #000000;">&#125;</span><span style="color: #999999; font-style: italic;">//vervolgens sorteren we de nieuwe array op miliseconden. Het item met de hoogste waarde komt vooraan in de array te staan.</span>arr1<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">sortOn</span><span style="color: #000000;">&#40;</span><span style="color: #009900;">&quot;time&quot;</span><span style="color: #000000; font-weight: bold;">,</span> <a target="_blank" href="http://www.google.com/search?q=array%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:array.html"><span style="color: #004993;">Array</span></a><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">NUMERIC</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span><span style="color: #999999; font-style: italic;">//we draaien de array om, we willen immers niet het oudste maar het recentste item vooraan hebben.</span>arr1<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">reverse</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span><span style="color: #999999; font-style: italic;">//en we loopen nog een keer door de array om te kijken of het gelukt is.</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> a <span style="color: #0033ff; font-weight: bold;">in</span> arr1<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>	<span style="color: #999999; font-style: italic;">//we tracen het veld met de UTC string en concluderen dat het nog werkt ook :D</span>	<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>arr1<span style="color: #000000;">&#91;</span>a<span style="color: #000000;">&#93;</span><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">date</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span><span style="color: #000000;">&#125;</span></div></div></pre>
</div></div>

]]></content:encoded>
			<dc:creator>marcvz</dc:creator>
			<guid isPermaLink="true">http://www.flashfocus.nl/forum/blog.php?b=37</guid>
		</item>
		<item>
			<title>3D Fractals</title>
			<link>http://www.flashfocus.nl/forum/blog.php?b=36</link>
			<pubDate>Mon, 08 Feb 2010 20:29:17 GMT</pubDate>
			<description>Dit weekend heb ik wat zitten experimenteren met 3D fractals. 
 
 Image: http://www.neuroproductions.be/uploads/blog/examples/fractal/fractal1FF.jpg  
 
Maar in plaats van gewoon wat formules te copy-pasten an het internet, heb ik geprobeerd om zelf  
nieuwe volumes te vinden. En dat bleek eigenlijk niet zo moeilijk.  
Ze zijn natuurlijk niet zo spectaculair als de bekende mandelbulb (http://www.skytopia.com/project/fractal/mandelbulb.html)  en Julia fractals. Maar ik ben toch tevreden  
over...</description>
			<content:encoded><![CDATA[<div>Dit weekend heb ik wat zitten experimenteren met 3D fractals.<br />
<br />
 <img src="http://www.neuroproductions.be/uploads/blog/examples/fractal/fractal1FF.jpg" border="0" alt="" /><br />
<br />
Maar in plaats van gewoon wat formules te copy-pasten an het internet, heb ik geprobeerd om zelf <br />
nieuwe volumes te vinden. En dat bleek eigenlijk niet zo moeilijk. <br />
Ze zijn natuurlijk niet zo spectaculair als de bekende <a href="http://www.skytopia.com/project/fractal/mandelbulb.html" target="_blank">mandelbulb</a>  en Julia fractals. Maar ik ben toch tevreden <br />
over het resultaat. :)<br />
<br />
Om de volumes te renderen, heb ik een simpele (en trage :p ) ray-tracer gemaakt die normal-maps genereerd.<br />
 <br />
 <img src="http://www.neuroproductions.be/uploads/blog/examples/fractal/normalMapFractel_2FF.jpg" border="0" alt="" /><br />
 Daarna heb ik en Pixel Bender filter gebruikt om de shading op de renders te zetten.<br />
<br />
Een paar volumes die ik heb 'ontdekt':<br />
(Het bizare is dat het allemaal puur wiskundige vormen zijn)<br />
<br />
<img src="http://www.neuroproductions.be/uploads/blog/examples/fractal/fractal5FF.jpg" border="0" alt="" /><br />
<br />
<img src="http://www.neuroproductions.be/uploads/blog/examples/fractal/fractal4FF.jpg" border="0" alt="" /><br />
<br />
<img src="http://www.neuroproductions.be/uploads/blog/examples/fractal/fractal6FF.jpg" border="0" alt="" /><br />
<br />
<br />
Hierbij de <a href="http://www.neuroproductions.be/wp-content/plugins/download-monitor/download.php?id=24" target="_blank">source code</a> zodat je zelf ook kunt zoeken naar coole 3D vormen. :)</div>

]]></content:encoded>
			<dc:creator>Neuro</dc:creator>
			<guid isPermaLink="true">http://www.flashfocus.nl/forum/blog.php?b=36</guid>
		</item>
		<item>
			<title>Custom Brushes met ActionScript</title>
			<link>http://www.flashfocus.nl/forum/blog.php?b=35</link>
			<pubDate>Sun, 10 Jan 2010 13:43:31 GMT</pubDate>
			<description>Custom brushes in Flash, ik had ze al een paar keer tegen gekomen op het world wide interweb en steeds vroeg ik me af hoe ze dat deden. Dus heb ik dit weekend ook een poging gewaagd. 
 
 
Image: http://www.neuroproductions.be/uploads/ff/brushes/brushesFF.jpg  (http://www.neuroproductions.be/uploads/ff/brushes/BrushTest1.swf) 
 
» Bekijk de swf (http://www.neuroproductions.be/uploads/ff/brushes/BrushTest1.swf) 
 
Het resultaat is nog lang niet perfect, maar goed, voorlopig voldoende...  
...</description>
			<content:encoded><![CDATA[<div>Custom brushes in Flash, ik had ze al een paar keer tegen gekomen op het world wide interweb en steeds vroeg ik me af hoe ze dat deden. Dus heb ik dit weekend ook een poging gewaagd.<br />
<br />
<br />
<a href="http://www.neuroproductions.be/uploads/ff/brushes/BrushTest1.swf" target="_blank"><img src="http://www.neuroproductions.be/uploads/ff/brushes/brushesFF.jpg" border="0" alt="" /></a><br />
<font size="3"><br />
<a href="http://www.neuroproductions.be/uploads/ff/brushes/BrushTest1.swf" target="_blank">» Bekijk de swf</a><br />
</font><br />
Het resultaat is nog lang niet perfect, maar goed, voorlopig voldoende... <br />
<br />
<a href="http://www.neuroproductions.be/wp-content/plugins/download-monitor/download.php?id=22" target="_blank">Source code</a> (het is een puinhoop) :)<br />
<br />
<div align="center"><a href="http://www.neuroproductions.be/uploads/ff/blog/normals/ExSphereNormalMapTestOBJ.swf" target="_blank"><br />
</a></div></div>

]]></content:encoded>
			<dc:creator>Neuro</dc:creator>
			<guid isPermaLink="true">http://www.flashfocus.nl/forum/blog.php?b=35</guid>
		</item>
		<item>
			<title>Een 64K in Flash</title>
			<link>http://www.flashfocus.nl/forum/blog.php?b=34</link>
			<pubDate>Mon, 07 Dec 2009 20:22:21 GMT</pubDate>
			<description>Zo af en toe blader ik wel eens wat rond op scene.org, en hoewel dit eigenlijk weinig met Flash te maken heeft, kwam ik er vandaag toch iets tegen dat in Flash gemaakt is. 
 
Een korte introductie voor degenen die niet precies weten wat een 64K precies is: Een 64K is over het algemeen een programma van 64KB groot, die dankzij zeer goede compressie en programmeerwerk een animatie laat zien die tot wel enkele minuten kan duren (inclusief geluid!). 
 
Dus ik kwam nu een 64K tegen die niet een...</description>
			<content:encoded><![CDATA[<div>Zo af en toe blader ik wel eens wat rond op scene.org, en hoewel dit eigenlijk weinig met Flash te maken heeft, kwam ik er vandaag toch iets tegen dat in Flash gemaakt is.<br />
<br />
Een korte introductie voor degenen die niet precies weten wat een 64K precies is: Een 64K is over het algemeen een programma van 64KB groot, die dankzij zeer goede compressie en programmeerwerk een animatie laat zien die tot wel enkele minuten kan duren (inclusief geluid!).<br />
<br />
Dus ik kwam nu een 64K tegen die niet een win32 programma is, maar een swf. Ik zou zeggen, <a href="http://www.scene.org/file.php?file=%2Fparties%2F2009%2Fassembly09%2Fin64%2Fproof_of_concept_by_evoflash.zip&amp;fileinfo" target="_blank">neem eens een kijkje</a>, en vergeet vooral niet dat al dit moois uit een swf van slechts 64KB komt!</div>

]]></content:encoded>
			<dc:creator>dcm360</dc:creator>
			<guid isPermaLink="true">http://www.flashfocus.nl/forum/blog.php?b=34</guid>
		</item>
		<item>
			<title>Mijn migratie naar AS3: width, height en coördinaten</title>
			<link>http://www.flashfocus.nl/forum/blog.php?b=33</link>
			<pubDate>Sat, 28 Nov 2009 13:21:11 GMT</pubDate>
			<description>In een reeks blogs wil ik mijn migratie van ActionScript 2 naar 3 delen.  
Hier weer eventjes een praktisch voorbeeld van nog een verschil tussen ActionScript 2 en 3. 
 
Voorheen (in AS2) kon je de coördinaten van een MovieClip bepalen door naar de instantienaam te verwijzen en er een _x voor de horizontale en een _y voor de verticale coördinaat ernaast te zetten. 
 
mijnMovieClip_mc._x = 100; 
mijnMovieClip_mc._y = 100;In ActionScript 3 is het echter wat logischer gemaakt, door het *_* teken...</description>
			<content:encoded><![CDATA[<div>In een reeks blogs wil ik mijn migratie van ActionScript 2 naar 3 delen. <br />
Hier weer eventjes een praktisch voorbeeld van nog een verschil tussen ActionScript 2 en 3.<br />
<br />
Voorheen (in AS2) kon je de coördinaten van een MovieClip bepalen door naar de instantienaam te verwijzen en er een _x voor de horizontale en een _y voor de verticale coördinaat ernaast te zetten.<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">ActionScript Code:</div>
	<pre class="alt2" style="margin:0px; padding:5px; border: 1px solid #B1B6C2; width:700px; height:68px; overflow:auto"><div dir="ltr" style="text-align:left;"><div class="actionscript" style="font-family:monospace;"><pre>mijnMovieClip_mc.<span style="color: #004993;">_x</span> = <span style="color: #000000; font-weight:bold;">100</span>;mijnMovieClip_mc.<span style="color: #004993;">_y</span> = <span style="color: #000000; font-weight:bold;">100</span>;</div></div></pre>
</div>In ActionScript 3 is het echter wat logischer gemaakt, door het <b>_</b> teken weg te laten.<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">ActionScript 3 Code:</div>
	<pre class="alt2" style="margin:0px; padding:5px; border: 1px solid #B1B6C2; width:700px; height:68px; overflow:auto"><div dir="ltr" style="text-align:left;"><div class="actionscript3" style="font-family:monospace;"><pre>mijnMovieClip_mc<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">x</span> = <span style="color: #000000; font-weight:bold;">100</span><span style="color: #000000; font-weight: bold;">;</span>mijnMovieClip_mc<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">y</span> = <span style="color: #000000; font-weight:bold;">100</span><span style="color: #000000; font-weight: bold;">;</span></div></div></pre>
</div>Dit maakt het allemaal wat makkelijker. Het stomme was dat als je dan een MovieClip afstemde op de width of height van de Stage dat het er een beetje verwarrend uit zag:<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">ActionScript Code:</div>
	<pre class="alt2" style="margin:0px; padding:5px; border: 1px solid #B1B6C2; width:700px; height:68px; overflow:auto"><div dir="ltr" style="text-align:left;"><div class="actionscript" style="font-family:monospace;"><pre>mijnMovieClip_mc.<span style="color: #004993;">_x</span> = <span style="color: #004993;">Stage</span>.<span style="color: #004993;">width</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span>;mijnMovieClip_mc.<span style="color: #004993;">_y</span> = <span style="color: #004993;">Stage</span>.<span style="color: #004993;">height</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span>;</div></div></pre>
</div>De Stage.height of Stage.width werkte zonder het _ teken, maar bij een MovieClip moest je deze wel gebruiken.<br />
Nu is er voor de Stage.height en Stage.width ook iets veranderd:<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">ActionScript 3 Code:</div>
	<pre class="alt2" style="margin:0px; padding:5px; border: 1px solid #B1B6C2; width:700px; height:148px; overflow:auto"><div dir="ltr" style="text-align:left;"><div class="actionscript3" style="font-family:monospace;"><pre><span style="color: #999999; font-style: italic;">// coördinaten </span>mijnMovieClip_mc<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">x</span> = <span style="color: #004993;">stage</span><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">stageWidth</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000; font-weight: bold;">;</span>mijnMovieClip_mc<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">y</span> = <span style="color: #004993;">stage</span><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">stageHeight</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000; font-weight: bold;">;</span><span style="color: #999999; font-style: italic;">// afmetingen</span>mijnMovieClip_mc<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">width</span> = <span style="color: #004993;">stage</span><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">stageWidth</span><span style="color: #000000; font-weight: bold;">;</span>mijnMovieClip_mc<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">height</span> = <span style="color: #004993;">stage</span><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">stageHeight</span><span style="color: #000000; font-weight: bold;">;</span></div></div></pre>
</div>Allemaal even wennen om het zo te doen, maar de manier van werken maakt het wel een stuk logischer! :D<br />
En voor mijn migratie van AS2 naar AS3: to be continued....</div>

]]></content:encoded>
			<dc:creator>tijmen_4real</dc:creator>
			<guid isPermaLink="true">http://www.flashfocus.nl/forum/blog.php?b=33</guid>
		</item>
		<item>
			<title>Overstap van ActionScript 2 naar 3</title>
			<link>http://www.flashfocus.nl/forum/blog.php?b=32</link>
			<pubDate>Tue, 17 Nov 2009 16:16:58 GMT</pubDate>
			<description>Ik zat dus al een tijdje te twijfelen om over te stappen van ActionScript 2 naar ActionScript 3. 
Nu ga ik dan toch over, en heb ik een duidelijke PDF gelezen van Adobe waarin in hoofdlijnen de verschillen tussen 2 en 3 worden behandeld. 
Om iedereen die ook nog twijfelt ook mee te krijgen schijf ik deze blog waarin ik de, althans voor mij, belangrijkste veranderingen bespreek. 
Eigenlijk is dit niet meer dan een directe vertaling van de Engelstalige PDF uit de bijlage, waar ik in heb geknipt...</description>
			<content:encoded><![CDATA[<div>Ik zat dus al een tijdje te twijfelen om over te stappen van ActionScript 2 naar ActionScript 3.<br />
Nu ga ik dan toch over, en heb ik een duidelijke PDF gelezen van Adobe waarin in hoofdlijnen de verschillen tussen 2 en 3 worden behandeld.<br />
Om iedereen die ook nog twijfelt ook mee te krijgen schijf ik deze blog waarin ik de, althans voor mij, belangrijkste veranderingen bespreek.<br />
Eigenlijk is dit niet meer dan een directe vertaling van de Engelstalige PDF uit de bijlage, waar ik in heb geknipt en geplakt.<br />
<br />
De onderstaande voorbeelden laten eerste de werkwijze in AS2 zien met daaronder de nieuwe werkwijze in AS3.<br />
<br />
<b>Voorbeeld 1: Naar een functie op de _root/main timeline verwijzen</b><br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">ActionScript Code:</div>
	<pre class="alt2" style="margin:0px; padding:5px; border: 1px solid #B1B6C2; width:700px; height:148px; overflow:auto"><div dir="ltr" style="text-align:left;"><div class="actionscript" style="font-family:monospace;"><pre><span style="color: #009900; font-style: italic;">// de functie op de main timeline</span><span style="color: #0033ff; font-weight: bold;">function</span> dumber<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>:<span style="color: #004993;">Void</span> <span style="color: #000000;">&#123;</span>	<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #009900;">&quot;dumber&quot;</span><span style="color: #000000;">&#41;</span>;<span style="color: #000000;">&#125;</span><span style="color: #009900; font-style: italic;">// aanroepen vanuit ergens in je content</span><span style="color: #004993;">_root</span>.<span style="color: #000000;">dumber</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div></div></pre>
</div><div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">ActionScript 3 Code:</div>
	<pre class="alt2" style="margin:0px; padding:5px; border: 1px solid #B1B6C2; width:700px; height:148px; overflow:auto"><div dir="ltr" style="text-align:left;"><div class="actionscript3" style="font-family:monospace;"><pre><span style="color: #999999; font-style: italic;">// de functie op de main timeline</span><span style="color: #339966; font-weight: bold;">function</span> dumber<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span>Void <span style="color: #000000;">&#123;</span>	<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #009900;">&quot;dumber&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span><span style="color: #000000;">&#125;</span><span style="color: #999999; font-style: italic;">// aanroepen vanuit ergens in je content</span><a target="_blank" href="http://www.google.com/search?q=movieclip%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:movieclip.html"><span style="color: #004993;">MovieClip</span></a><span style="color: #000000;">&#40;</span><span style="color: #004993;">root</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">.</span>dumber<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span></div></div></pre>
</div><b>Voorbeeld 2: Met interactiviteit van buttons omgaan<br />
<br />
</b><div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">ActionScript Code:</div>
	<pre class="alt2" style="margin:0px; padding:5px; border: 1px solid #B1B6C2; width:700px; height:196px; overflow:auto"><div dir="ltr" style="text-align:left;"><div class="actionscript" style="font-family:monospace;"><pre><span style="color: #0033ff; font-weight: bold;">function</span> onButtonRelease<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>:<span style="color: #004993;">Void</span> <span style="color: #000000;">&#123;</span>	<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #009900;">&quot;er is op de button geklikt&quot;</span><span style="color: #000000;">&#41;</span>;<span style="color: #000000;">&#125;</span><span style="color: #0033ff; font-weight: bold;">function</span> onButtonRollOver<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>:<span style="color: #004993;">Void</span> <span style="color: #000000;">&#123;</span>	<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #009900;">&quot;de muis ging over de button heen&quot;</span><span style="color: #000000;">&#41;</span>;<span style="color: #000000;">&#125;</span>mijnButton_btn.<span style="color: #004993;">onRelease</span> = onButtonRelease;mijnButton_btn.<span style="color: #004993;">onRollOver</span>= onButtonRollOver;</div></div></pre>
</div><div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">ActionScript 3 Code:</div>
	<pre class="alt2" style="margin:0px; padding:5px; border: 1px solid #B1B6C2; width:700px; height:196px; overflow:auto"><div dir="ltr" style="text-align:left;"><div class="actionscript3" style="font-family:monospace;"><pre><span style="color: #339966; font-weight: bold;">function</span> onButtonClick<span style="color: #000000;">&#40;</span>event<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=mouseevent%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:mouseevent.html"><span style="color: #004993;">MouseEvent</span></a><span style="color: #000000;">&#41;</span><span style="color: #000000; 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: #009900;">&quot;er is op de button geklikt&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span><span style="color: #000000;">&#125;</span><span style="color: #339966; font-weight: bold;">function</span> onMouseOver<span style="color: #000000;">&#40;</span>event<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=mouseevent%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:mouseevent.html"><span style="color: #004993;">MouseEvent</span></a><span style="color: #000000;">&#41;</span><span style="color: #000000; 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: #009900;">&quot;de muis ging over de button heen&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span><span style="color: #000000;">&#125;</span>mijnButton_btn<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a target="_blank" href="http://www.google.com/search?q=mouseevent%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:mouseevent.html"><span style="color: #004993;">MouseEvent</span></a><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">CLICK</span><span style="color: #000000; font-weight: bold;">,</span> onButtonClick<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>mijnButton_btn<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a target="_blank" href="http://www.google.com/search?q=mouseevent%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:mouseevent.html"><span style="color: #004993;">MouseEvent</span></a><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">MOUSE_OVER</span><span style="color: #000000; font-weight: bold;">,</span> onMouseOver<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span></div></div></pre>
</div><b>Voorbeeld 3: Een link openen<br />
<br />
</b><div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">ActionScript Code:</div>
	<pre class="alt2" style="margin:0px; padding:5px; border: 1px solid #B1B6C2; width:700px; height:52px; overflow:auto"><div dir="ltr" style="text-align:left;"><div class="actionscript" style="font-family:monospace;"><pre><span style="color: #004993;">getURL</span><span style="color: #000000;">&#40;</span><span style="color: #009900;">&quot;http://www.google.nl&quot;</span>,<span style="color: #009900;">&quot;_blank&quot;</span><span style="color: #000000;">&#41;</span>;</div></div></pre>
</div><div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">ActionScript 3 Code:</div>
	<pre class="alt2" style="margin:0px; padding:5px; border: 1px solid #B1B6C2; width:700px; height:68px; overflow:auto"><div dir="ltr" style="text-align:left;"><div class="actionscript3" style="font-family:monospace;"><pre><span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">url</span><span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=urlrequest%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:urlrequest.html"><span style="color: #004993;">URLRequest</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a target="_blank" href="http://www.google.com/search?q=urlrequest%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:urlrequest.html"><span style="color: #004993;">URLRequest</span></a><span style="color: #000000;">&#40;</span><span style="color: #009900;">&quot;http://www.google.nl&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span><span style="color: #004993;">navigateToURL</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">url</span><span style="color: #000000; font-weight: bold;">,</span> <span style="color: #009900;">&quot;_blank&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span></div></div></pre>
</div><b>Voorbeeld 4: Een keypress opvangen</b><br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">ActionScript Code:</div>
	<pre class="alt2" style="margin:0px; padding:5px; border: 1px solid #B1B6C2; width:700px; height:148px; overflow:auto"><div dir="ltr" style="text-align:left;"><div class="actionscript" style="font-family:monospace;"><pre><span style="color: #0033ff; font-weight: bold;">function</span> <span style="color: #004993;">onKeyDown</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>:<span style="color: #004993;">Void</span> <span style="color: #000000;">&#123;</span>	<span style="color: #0033ff; font-weight: bold;">var</span> code:<span style="color: #004993;">Number</span> = <span style="color: #004993;">Key</span>.<span style="color: #004993;">getCode</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;	<span style="color: #0033ff; font-weight: bold;">var</span> char:<span style="color: #004993;">String</span> = <span style="color: #004993;">String</span>.<span style="color: #004993;">fromCharCode</span><span style="color: #000000;">&#40;</span>code<span style="color: #000000;">&#41;</span>;	<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #009900;">&quot;Ingedrukte key : code : &quot;</span> + code + <span style="color: #009900;">&quot;char : &quot;</span> + char<span style="color: #000000;">&#41;</span>;<span style="color: #000000;">&#125;</span><span style="color: #004993;">Key</span>.<span style="color: #004993;">addListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">this</span><span style="color: #000000;">&#41;</span>;</div></div></pre>
</div><div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">ActionScript 3 Code:</div>
	<pre class="alt2" style="margin:0px; padding:5px; border: 1px solid #B1B6C2; width:700px; height:148px; overflow:auto"><div dir="ltr" style="text-align:left;"><div class="actionscript3" style="font-family:monospace;"><pre><span style="color: #339966; font-weight: bold;">function</span> onKeyDownHandler<span style="color: #000000;">&#40;</span>event<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=keyboardevent%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:keyboardevent.html"><span style="color: #004993;">KeyboardEvent</span></a><span style="color: #000000;">&#41;</span><span style="color: #000000; 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> <span style="color: #004993;">code</span><span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=uint%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:uint.html"><span style="color: #004993;">uint</span></a> = event<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">keyCode</span><span style="color: #000000; font-weight: bold;">;</span>	<span style="color: #6699cc; font-weight: bold;">var</span> char<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a> = <a target="_blank" href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">fromCharCode</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">code</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>	<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #009900;">&quot;Ingedrukte key : code : &quot;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #004993;">code</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #009900;">&quot;char : &quot;</span> <span style="color: #000000; font-weight: bold;">+</span> char<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span><span style="color: #000000;">&#125;</span><span style="color: #004993;">stage</span><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a target="_blank" href="http://www.google.com/search?q=keyboardevent%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:keyboardevent.html"><span style="color: #004993;">KeyboardEvent</span></a><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">KEY_UP</span><span style="color: #000000; font-weight: bold;">,</span> onKeyDownHandler<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span></div></div></pre>
</div><b>Voorbeeld 5: Een MovieClip dynamisch toevoegen vanuit de Library/Bibliotheek<br />
<br />
</b><div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">ActionScript Code:</div>
	<pre class="alt2" style="margin:0px; padding:5px; border: 1px solid #B1B6C2; width:700px; height:116px; overflow:auto"><div dir="ltr" style="text-align:left;"><div class="actionscript" style="font-family:monospace;"><pre><span style="color: #004993;">attachMovie</span><span style="color: #000000;">&#40;</span><span style="color: #009900;">&quot;mijnMovie&quot;</span>, <span style="color: #009900;">&quot;clip&quot;</span>, 10<span style="color: #000000;">&#41;</span>;clip.<span style="color: #004993;">_x</span> = <span style="color: #000000; font-weight:bold;">100</span>;clip.<span style="color: #004993;">_y</span> = <span style="color: #000000; font-weight:bold;">100</span>;clip.<span style="color: #004993;">_alpha</span> = <span style="color: #000000; font-weight:bold;">50</span>;</div></div></pre>
</div><div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">ActionScript 3 Code:</div>
	<pre class="alt2" style="margin:0px; padding:5px; border: 1px solid #B1B6C2; width:700px; height:164px; overflow:auto"><div dir="ltr" style="text-align:left;"><div class="actionscript3" style="font-family:monospace;"><pre><span style="color: #6699cc; font-weight: bold;">var</span> clip<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=movieclip%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:movieclip.html"><span style="color: #004993;">MovieClip</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> mijnMovie<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>clip<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">x</span> = <span style="color: #000000; font-weight:bold;">100</span><span style="color: #000000; font-weight: bold;">;</span>clip<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">y</span> = <span style="color: #000000; font-weight:bold;">100</span><span style="color: #000000; font-weight: bold;">;</span>clip<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> = <span style="color: #000000; font-weight: bold;">.</span>5<span style="color: #000000; font-weight: bold;">;</span><span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>clip<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span></div></div></pre>
</div>Dit waren 5 voorbeelden van verandering als je overstapt van AS2 naar AS3.<br />
Je vindt nog meer voorbeelden in de bijlage, het originele Migration CookBook van Adobe.<br />
<br />
<font size="1">Er zullen ongetwijfeld een aantal typfouten in bovenstaand artikel staan. Mijn excuses hiervoor ;)....</font></div>


<!-- attachments -->
	<div style="margin-top:10px">

		
		
		
		
			<fieldset class="fieldset">
				<legend>Bijgevoegde bestanden</legend>
				<table cellpadding="0" cellspacing="3" border="0">
				<tr>
	<td><img class="inlineimg" src="http://www.flashfocus.nl/forum/images/attach/pdf.gif" alt="Bestandstype: pdf" width="16" height="16" border="0" style="vertical-align:baseline" /></td>
	<td><a href="http://www.flashfocus.nl/forum/blog_attachment.php?attachmentid=2&amp;d=1258472764">BA843910d01.pdf</a> (599,3 KB, 696x geopend)</td>
</tr>
				</table>
			</fieldset>
		

	</div>
<!-- / attachments -->
]]></content:encoded>
			<dc:creator>tijmen_4real</dc:creator>
			<guid isPermaLink="true">http://www.flashfocus.nl/forum/blog.php?b=32</guid>
		</item>
		<item>
			<title><![CDATA[Chain [updated]]]></title>
			<link>http://www.flashfocus.nl/forum/blog.php?b=31</link>
			<pubDate>Sat, 14 Nov 2009 12:22:28 GMT</pubDate>
			<description><![CDATA[Ik heb een handige util class geschreven die ik graag met jullie wil delen. Het is om functies met verschillende intervallen (in ms) in een sequence aan te roepen. De 'Chain' kan gemakkelijk meerdere keren afgespeeld worden, zelfs in omgekeerde volgorde. :D 
 
Bij deze een klein voorbeeldje, hoe je Chain kan gebruiken: 
 
var myChain:Chain = new Chain();     
myChain.addEventListener( Event.COMPLETE, onComplete); 
myChain.add(one, 2000).add(two, 500).add(three, 1000).play(2); 
 
function...]]></description>
			<content:encoded><![CDATA[<div><div align="left">Ik heb een handige util class geschreven die ik graag met jullie wil delen. Het is om functies met verschillende intervallen (in ms) in een sequence aan te roepen. De 'Chain' kan gemakkelijk meerdere keren afgespeeld worden, zelfs in omgekeerde volgorde. :D<br />
<br />
Bij deze een klein voorbeeldje, hoe je Chain kan gebruiken:<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">ActionScript 3 Code:</div>
	<pre class="alt2" style="margin:0px; padding:5px; border: 1px solid #B1B6C2; width:700px; height:228px; overflow:auto"><div dir="ltr" style="text-align:left;"><div class="actionscript3" style="font-family:monospace;"><pre><span style="color: #6699cc; font-weight: bold;">var</span> myChain<span style="color: #000000; font-weight: bold;">:</span>Chain = <span style="color: #0033ff; font-weight: bold;">new</span> Chain<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span> &nbsp; &nbsp;myChain<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span> <a target="_blank" href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">COMPLETE</span><span style="color: #000000; font-weight: bold;">,</span> onComplete<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span>myChain<span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span>one<span style="color: #000000; font-weight: bold;">,</span> 2000<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span>two<span style="color: #000000; font-weight: bold;">,</span> 500<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span>three<span style="color: #000000; font-weight: bold;">,</span> 1000<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">.</span><span style="color: #004993;">play</span><span style="color: #000000;">&#40;</span>2<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span><span style="color: #339966; font-weight: bold;">function</span> one<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; 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: #009900;">&quot;one&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#125;</span><span style="color: #339966; font-weight: bold;">function</span> two<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; 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: #009900;">&quot;two&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#125;</span><span style="color: #339966; font-weight: bold;">function</span> three<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; 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: #009900;">&quot;three&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#125;</span><span style="color: #339966; font-weight: bold;">function</span> onComplete<span style="color: #000000;">&#40;</span>e<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><span style="color: #000000;">&#41;</span><span style="color: #000000; 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: #009900;">&quot;done.&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#125;</span><span style="color: #3f5fbf;">/* trace output:one two three one two three done.*/</span></div></div></pre>
</div>Wat gebeurt hier? Op de eerste regel maken we de classe Chain aan.Op de volgende regel gebeuren meerdere dingen: We roepen een <i>add</i>-function aan. Dit is een belangrijk onderdeel in de class. Hier geef je aan na hoeveel delay er is voor de volgende functie, en welke functie er nu uitgevoerd moet worden. <i>add(one,</i><i>2000</i><i>);</i> betekent dus dat functie 1 wordt uitgevoerd en dat er daarna 2 seconden gewacht moet worden voor de volgende functie. Zo gaat hij door met de volgende functies.<br />
Aan het einde zie je de <i>play</i>-functie. Wat aangeeft dat er vanaf dat punt de functies uitgevoerd gaan worden, hoeveel keer het herhaald wordt. Daarna wordt het event COMPLETE dispatched.<br />
Je kunt met deze classe dus je eigen patronen,sequenties en/of ritmes maken. <br />
<br />
Ik ben een beetje geïnspireerd door jQuery (wat hier niets mee te maken heeft), om de mogelijkheid te geven om <i>add</i>-functies achter  elkaar te plakken.<br />
<br />
Dat is wat de classe doet. Een koel ding vind ik dat je het ook in omgekeerde volgorde kunt afspelen:<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">ActionScript 3 Code:</div>
	<pre class="alt2" style="margin:0px; padding:5px; border: 1px solid #B1B6C2; width:700px; height:116px; overflow:auto"><div dir="ltr" style="text-align:left;"><div class="actionscript3" style="font-family:monospace;"><pre>myChain<span style="color: #000000; font-weight: bold;">.</span>playReversed<span style="color: #000000;">&#40;</span>2<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">;</span><span style="color: #3f5fbf;">/* trace output:three two one three two one*/</span></div></div></pre>
</div> Natuurlijk kunt je ook tussentijds stoppen/doorgaan met de <i>stop() / doContinue()</i> functies, en je kunt nagaan of hij momenteel afspeelt met de <i>isPlaying</i>-getter<br />
<br />
Dit zijn alle functies:<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">ActionScript 3 Code:</div>
	<pre class="alt2" style="margin:0px; padding:5px; border: 1px solid #B1B6C2; width:700px; height:484px; overflow:auto"><div dir="ltr" style="text-align:left;"><div class="actionscript3" style="font-family:monospace;"><pre><span style="color: #999999; font-style: italic;">/// Constructor</span><span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> Chain<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #999999; font-style: italic;">/// Voeg functies toe met een specifieke interval (in milliseconden).</span><span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span>func<span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=function%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:function.html"><span style="color: #004993;">Function</span></a><span style="color: #000000; font-weight: bold;">,</span> <span style="color: #004993;">delay</span><span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span>Chain<span style="color: #999999; font-style: italic;">/// Speel de &nbsp;sequence af en roep de functies aan.</span><span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">play</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">repeatCount</span><span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a> = 0<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #999999; font-style: italic;">/// Speel de &nbsp;sequence in omgekeerde volgorde af en roep de functies aan.</span><span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> playReversed<span style="color: #000000;">&#40;</span><span style="color: #004993;">repeatCount</span><span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a> = 0<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #999999; font-style: italic;">/// Maakt sequest lijst leeg. Alle data wordt leeggemaakt</span><span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">clear</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span>Chain<span style="color: #999999; font-style: italic;">/// Stop met spelen, gebruik doContinue() om verder te spelen</span><span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">stop</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #999999; font-style: italic;">/// Doorspelen na een stop </span><span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> doContinue<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span>Chain<span style="color: #999999; font-style: italic;">/// Reset indexen om naar begin te springen</span><span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">reset</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">toString</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a><span style="color: #999999; font-style: italic;">/// Retourneerd of je momenteel aan het afspelen bent</span><span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> isPlaying<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><a target="_blank" href="http://www.google.com/search?q=boolean%20inurl:http://livedocs.adobe.com/flex/3/langref/%20inurl:boolean.html"><span style="color: #004993;">Boolean</span></a></div></div></pre>
</div><b>Download:</b> <a href="http://code.google.com/p/stroep/source/browse/#svn/trunk/nl/stroep/chain" target="_blank">Chain</a> (googlecode)<br />
<br />
Ik hoop dat iemand er wat mee kan. Laat maar weten als je nog extra functies verwacht<br />
<br />
<b>updates 15-nov-'09</b><br />
- private functions zijn protected<br />
- add function is nu add(func,delay), dus andersom, en func is verplicht.<br />
- Classe extend EventDispatcher en play/playReversed dispatchen Event.COMPLETE na afspelen van sequence<br />
- code geoptimaliseerd/opgeschoont.<br />
</div></div>

]]></content:encoded>
			<dc:creator>mknol</dc:creator>
			<guid isPermaLink="true">http://www.flashfocus.nl/forum/blog.php?b=31</guid>
		</item>
	</channel>
</rss>

