<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-2861696249025058484</id><updated>2024-08-30T12:05:35.693+02:00</updated><title type='text'>GAV Development</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://gavflash.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2861696249025058484/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://gavflash.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Jonas</name><uri>http://www.blogger.com/profile/02575874994580939202</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidaaLR_KOW5RM7YZLX35PXqLj795OUwKm9Y3ctVT_F7MQX7y0QalfX-s5qfKn8opMknjItndWe5EN1tbbii7P54ZwMEn2cPSOIpu-qFxr1mWIigiAZJzkHfoFF598untU/s220/jonas-bw-skagg.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>6</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2861696249025058484.post-574349756718010280</id><published>2012-03-02T15:33:00.001+01:00</published><updated>2012-03-02T15:33:27.031+01:00</updated><title type='text'></title><content type='html'>&lt;iframe src=&quot;http://www.ncomva.se/html5/vislet&quot; width=&quot;100%&quot; height=&quot;600&quot;&gt;
    &lt;/iframe&gt;</content><link rel='replies' type='application/atom+xml' href='http://gavflash.blogspot.com/feeds/574349756718010280/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gavflash.blogspot.com/2012/03/blog-post_02.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2861696249025058484/posts/default/574349756718010280'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2861696249025058484/posts/default/574349756718010280'/><link rel='alternate' type='text/html' href='http://gavflash.blogspot.com/2012/03/blog-post_02.html' title=''/><author><name>Tobias</name><uri>http://www.blogger.com/profile/11793823707385627353</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2861696249025058484.post-9186407406093008301</id><published>2010-02-23T09:56:00.003+01:00</published><updated>2010-03-26T12:30:15.321+01:00</updated><title type='text'>Micro Threads in ActionScript3 with open source Thrash</title><content type='html'>&lt;p&gt;One of the major drawbacks of Flash Player is its lack of multithreading. In today’s market, when every new laptop comes with at least two processor cores and the cores aren’t getting faster this is a serious caveat. However, there is one other situation which also would benefit from threads. If you are doing any heavy data processing in your Flash/Flex app you know this; namely that the Flex GUI blocks while executing ActionScript.&lt;/p&gt;&lt;p&gt;While trying to make &lt;a href=&quot;http://stats.oecd.org/OECDregionalstatistics/&quot;&gt;eXplorer&lt;/a&gt; perform better by using &lt;span style=&quot;font-family: monospace;&quot;&gt;callLater()&lt;/span&gt; to delay some execution to the next frame and let the GUI update, I realized that I could abstract a pattern from this.  But little did I know that &lt;i&gt;pseudo threading&lt;/i&gt; in Flash has been covered in &lt;a href=&quot;http://senocular.com/flash/tutorials/asyncoperations/&quot;&gt;several&lt;/a&gt; &lt;a href=&quot;http://www.joristimmerman.be/wordpress/2009/01/11/pseudo-threading-in-actionscrip-as3/&quot;&gt;places&lt;/a&gt; &lt;a href=&quot;http://blogs.adobe.com/aharui/2008/01/threads_in_actionscript_3.html&quot;&gt;before&lt;/a&gt;, so I wrote a couple of classes to simplify the creation of what I called Micro Threads (however, I realize that Pseudo Threads might be a better name).&lt;/p&gt;&lt;p&gt;A MicroThread simply implements the interface IMicroThread:&lt;br /&gt;&lt;pre class=&quot;prettyprint&quot;&gt;&lt;br /&gt;package org.ncva.thrash&lt;br /&gt;{&lt;br /&gt;    public interface IMicroThread&lt;br /&gt;    {&lt;br /&gt;        function worker(): Boolean;&lt;br /&gt;        function get name(): String;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;/p&gt;&lt;p&gt;The idea is that the method “worker” is executed as many times as possible during one frame after which the thread is paused to allow rendering and other AS3 execution only to be resumed again the next frame. The thread will indicate that it is finished by returning true after a call to “worker”.&lt;/p&gt;&lt;p&gt;My pseudo threads in contrast to those mentioned above make use of a &lt;i&gt;scheduler&lt;/i&gt; that is responsible of calculating how many times a task can execute per frame. I’m also planning to add &lt;i&gt;priority&lt;/i&gt; to the threads so that more important operations are given more processor time than others. Right now each task is executed at least once per frame, which can be too much if you have several heavy threads running at once. The threads should instead take turns and execute only when there is frame time available.&lt;/p&gt;&lt;h3&gt;Task&lt;/h3&gt;&lt;p&gt;I created a class named Task which implements the IMicroThread interface and takes as parameter a function to be used as “worker”. You can use task like this:&lt;pre class=&quot;prettyprint&quot;&gt;var x: uint = 0;&lt;br /&gt;            &lt;br /&gt;MicroThreadScheduler.scheduler.addThread(new Task(function (): Boolean {&lt;br /&gt;    x++;&lt;br /&gt;    var done: Boolean = x &gt;= 10;&lt;br /&gt;    return done;&lt;br /&gt;}));&lt;/pre&gt;&lt;/p&gt;&lt;p&gt;Since &lt;span style=&quot;font-family: monospace;&quot;&gt;x&lt;/span&gt; is in scope for the thread and the function passed to the Task is a closure, the same &lt;span style=&quot;font-family: monospace;&quot;&gt;x&lt;/span&gt; will be available each time the thread is awakened, and whenever this code is reached and you create a new thread, you also create a new &lt;span style=&quot;font-family: monospace;&quot;&gt;x&lt;/span&gt;, so there won’t be a conflict in the access of the variable &lt;span style=&quot;font-family: monospace;&quot;&gt;x&lt;/span&gt;. &lt;/p&gt;&lt;h3&gt;AsyncLoop&lt;/h3&gt;&lt;p&gt;To further simplify the porting of existing code you can use the class AsyncLoop which contains some methods imitating the behavior of our beloved loop-constructs:&lt;pre class=&quot;prettyprint&quot;&gt;//  doWhile imitates &quot;do ... while (condition)&quot;&lt;br /&gt;    var x: uint = 0;&lt;br /&gt;    var control: uint = 0;&lt;br /&gt;    &lt;br /&gt;    do {&lt;br /&gt;        control++;&lt;br /&gt;    } while (control &amp;lt; 10);&lt;br /&gt;    &lt;br /&gt;    AsyncLoop.doWhile(function (): Boolean {&lt;br /&gt;        x++;&lt;br /&gt;        return x &amp;lt; 10;&lt;br /&gt;    });&lt;br /&gt;&lt;br /&gt;    assertEquals(control, x);&lt;br /&gt;&lt;br /&gt;//  forRange imitates the common &quot;for (var i=0; i&amp;lt;L; i++)&quot; construct&lt;br /&gt;    var A: Array = [1,2,3,4,5,6,7,8,9,10]; &lt;br /&gt;    var control: uint = 0;&lt;br /&gt;    var sum: uint = 0;&lt;br /&gt;    &lt;br /&gt;    for (var i:uint=0; i&amp;lt;A.length; i++)&lt;br /&gt;        control += A[i];&lt;br /&gt;    &lt;br /&gt;    AsyncLoop.forRange(0, A.length, function (i: uint): void {&lt;br /&gt;        sum += A[i];&lt;br /&gt;    });&lt;br /&gt;&lt;br /&gt;    assertEquals(control, sum);&lt;br /&gt;&lt;br /&gt;//  forEach imitates &quot;for each&quot;:&lt;br /&gt;    var A: Array = [1,2,3,4,5,6,7,8,9,10]; &lt;br /&gt;    var control: uint = 0;&lt;br /&gt;    var sum: uint = 0;&lt;br /&gt;    &lt;br /&gt;    for each (var x: uint in A)&lt;br /&gt;        control += x;&lt;br /&gt;    &lt;br /&gt;    AsyncLoop.forEach(A, function (a: uint): void {&lt;br /&gt;        sum += a;&lt;br /&gt;    });&lt;br /&gt;    assertEquals(control, sum);&lt;br /&gt;&lt;br /&gt;//  forEach works with Object too:&lt;br /&gt;    var O: Object = getMyObjectFromSomeWhere();&lt;br /&gt;    &lt;br /&gt;    for each (var a: Object in O) &lt;br /&gt;        doSomeThing(a);&lt;br /&gt;    &lt;br /&gt;    AsyncLoop.forEach(O, function (a:Object): void {&lt;br /&gt;        doSomeThing(a);&lt;br /&gt;    });&lt;/pre&gt;&lt;/p&gt;&lt;p&gt;The first iteration of the loop will be scheduled the next frame and following iterations will be scheduled as many times as possible the coming frames.&lt;/p&gt;&lt;p&gt;Thrash &lt;strike&gt;0.1&lt;/strike&gt; 0.2 is available here: [&lt;a href=&quot;http://vitagate.itn.liu.se/GAV/opensource/thrash-0.2.zip&quot;&gt;source&lt;/a&gt;, &lt;a href=&quot;http://vitagate.itn.liu.se/GAV/opensource/thrash-0.2.swc.zip&quot;&gt;binary&lt;/a&gt;] and can be used under the terms of GNU LGPL.&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://gavflash.blogspot.com/feeds/9186407406093008301/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gavflash.blogspot.com/2010/02/micro-threads-in-actionscript3-with.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2861696249025058484/posts/default/9186407406093008301'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2861696249025058484/posts/default/9186407406093008301'/><link rel='alternate' type='text/html' href='http://gavflash.blogspot.com/2010/02/micro-threads-in-actionscript3-with.html' title='Micro Threads in ActionScript3 with open source Thrash'/><author><name>Markus</name><uri>http://www.blogger.com/profile/07735639843378697321</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2861696249025058484.post-5118709692010557575</id><published>2010-02-23T09:12:00.005+01:00</published><updated>2010-02-23T09:47:30.022+01:00</updated><title type='text'>FlashPlayer 10 playerglobals and Flex Builder 3 projects</title><content type='html'>&lt;p&gt;Recently I wanted to use the Flash Player 10 only type &lt;span style=&quot;font-family: monospace;&quot;&gt;Vector.&amp;lt;T&amp;gt;&lt;/span&gt;, so I added the &lt;span style=&quot;font-family: monospace;&quot;&gt;playerglobals.swc&lt;/span&gt; from FlashPlayer 10 to my AS Library project&#39;s libs path like I feel I have done a zillion times before. However, this time Flex Builder gave me errors for each type I used from the player:&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdH2Ki00WhEJjSCZht6ov1DV4A03stmjUkgzXaSnJUSu0iGOA7irNgFyURW-fIZrsum_gMPzcaBhIK6Obv16YNaQGQri90GhPx7AneVTcqu8juCGb8GnBngCtRfH5JaHT2WSaKuRcaBqY/s1600-h/playerglobals_errors.jpg&quot;&gt;&lt;img style=&quot;display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 274px; height: 320px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdH2Ki00WhEJjSCZht6ov1DV4A03stmjUkgzXaSnJUSu0iGOA7irNgFyURW-fIZrsum_gMPzcaBhIK6Obv16YNaQGQri90GhPx7AneVTcqu8juCGb8GnBngCtRfH5JaHT2WSaKuRcaBqY/s320/playerglobals_errors.jpg&quot; alt=&quot;__AS3__.vec:Vector is undefined etc.&quot; border=&quot;0&quot; alt=&quot;&quot;id=&quot;BLOGGER_PHOTO_ID_5441351749637704946&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;The error I made was that I did not change the &lt;i&gt;Link Type&lt;/i&gt; to &quot;External&quot;. So just click the small arrow and double-click &quot;Link Type&quot; and change the value to &quot;External&quot;:&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjvBv-WPEioY1bggZSbbwEM8-uUb6LaluBKCRLScPABpiPOleRafOAVKivT9v5xArb6LcO_uX7Up9RtfjhSBVDM7_r_0fa5MS_mI_1OnYdRowZ0Cj2otAEKjnvZMxKCdrUaw-7cdIg7B_4/s1600-h/linktype.jpg&quot;&gt;&lt;img style=&quot;display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 296px; height: 88px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjvBv-WPEioY1bggZSbbwEM8-uUb6LaluBKCRLScPABpiPOleRafOAVKivT9v5xArb6LcO_uX7Up9RtfjhSBVDM7_r_0fa5MS_mI_1OnYdRowZ0Cj2otAEKjnvZMxKCdrUaw-7cdIg7B_4/s320/linktype.jpg&quot; border=&quot;0&quot; alt=&quot;&quot;id=&quot;BLOGGER_PHOTO_ID_5441356050517875122&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Moreover, if you get an error about &quot;inconsistant linkage&quot;:&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxPm0catVi7iwIsKfH_-JZHkf-3GItjKrIm_0Ag9qf_PznmtRrEGOaTKCjSqmv76Mcq6MKC67H8R8W5G9vBCmyz1aVS1MfsoVDFyKTNZiDCTtVglzIkqDQVkhve176jQUT8OmvF_wEmas/s1600-h/inconsistant_linkage.jpg&quot;&gt;&lt;img style=&quot;display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 243px; height: 81px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxPm0catVi7iwIsKfH_-JZHkf-3GItjKrIm_0Ag9qf_PznmtRrEGOaTKCjSqmv76Mcq6MKC67H8R8W5G9vBCmyz1aVS1MfsoVDFyKTNZiDCTtVglzIkqDQVkhve176jQUT8OmvF_wEmas/s320/inconsistant_linkage.jpg&quot; border=&quot;0&quot; alt=&quot;Inconsistant linkage&quot; id=&quot;BLOGGER_PHOTO_ID_5441351751212851762&quot; /&gt;&lt;/a&gt;&lt;br /&gt;Then you have probably forgot to remove the &lt;span style=&quot;font-family: monospace;&quot;&gt;playerglobals.swc&lt;/span&gt; from the Flex framework link:&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEtz3053cEx-7gE4vPhyphenhyphenM0IULxUR6FjzdbA5q8ClMtAiHVbr5WYhYkBWe-Oqfw8rlzjuwsNbLep0mphR4psq0ltX4t8YtJubdblg1_ZGZdG4DQ17oDtkLBJChNJscnabeEOvusU_BUtps/s1600-h/framework+link.jpg&quot;&gt;&lt;img style=&quot;display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 244px; height: 127px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEtz3053cEx-7gE4vPhyphenhyphenM0IULxUR6FjzdbA5q8ClMtAiHVbr5WYhYkBWe-Oqfw8rlzjuwsNbLep0mphR4psq0ltX4t8YtJubdblg1_ZGZdG4DQ17oDtkLBJChNJscnabeEOvusU_BUtps/s320/framework+link.jpg&quot; border=&quot;0&quot; alt=&quot;&quot;id=&quot;BLOGGER_PHOTO_ID_5441357079748561010&quot; /&gt;&lt;/a&gt;&lt;br /&gt;Just select the &lt;span style=&quot;font-family: monospace;&quot;&gt;playerglobals.swc&lt;/span&gt; item under Flex and hit &lt;i&gt;Remove&lt;/i&gt;.&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://gavflash.blogspot.com/feeds/5118709692010557575/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gavflash.blogspot.com/2010/02/flashplayer-10-playerglobals-and-flex.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2861696249025058484/posts/default/5118709692010557575'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2861696249025058484/posts/default/5118709692010557575'/><link rel='alternate' type='text/html' href='http://gavflash.blogspot.com/2010/02/flashplayer-10-playerglobals-and-flex.html' title='FlashPlayer 10 playerglobals and Flex Builder 3 projects'/><author><name>Markus</name><uri>http://www.blogger.com/profile/07735639843378697321</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdH2Ki00WhEJjSCZht6ov1DV4A03stmjUkgzXaSnJUSu0iGOA7irNgFyURW-fIZrsum_gMPzcaBhIK6Obv16YNaQGQri90GhPx7AneVTcqu8juCGb8GnBngCtRfH5JaHT2WSaKuRcaBqY/s72-c/playerglobals_errors.jpg" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2861696249025058484.post-8690687666873594777</id><published>2010-01-26T11:32:00.002+01:00</published><updated>2010-01-26T11:43:11.427+01:00</updated><title type='text'>Glyph performance testing and glyph model</title><content type='html'>Hi,&lt;br /&gt;&lt;br /&gt;I put my slides (Glyph.pptx) and data file (GlyphTest.xls) of performance testing for the meeting on Jan 26, 2010 on my web folder http://webstaff.itn.liu.se/~hova/&lt;br /&gt;&lt;br /&gt;/Quan</content><link rel='replies' type='application/atom+xml' href='http://gavflash.blogspot.com/feeds/8690687666873594777/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gavflash.blogspot.com/2010/01/glyph-performance-testing-and-glyph.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2861696249025058484/posts/default/8690687666873594777'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2861696249025058484/posts/default/8690687666873594777'/><link rel='alternate' type='text/html' href='http://gavflash.blogspot.com/2010/01/glyph-performance-testing-and-glyph.html' title='Glyph performance testing and glyph model'/><author><name>Quan Ho</name><uri>http://www.blogger.com/profile/14768894742243601306</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2861696249025058484.post-2774659328189298267</id><published>2009-11-20T11:39:00.013+01:00</published><updated>2009-11-20T12:45:51.198+01:00</updated><title type='text'>Unit testing with Flex Unit 4</title><content type='html'>&lt;h3&gt;Why?&lt;/h3&gt;&lt;p&gt;Unit testing should be done for several purposes:&lt;ul&gt;&lt;li&gt;If you write your tests before the actual class code, you design the public interface of the class to be conveniently callable&lt;/li&gt;&lt;li&gt;The class you create is by definition testable&lt;/li&gt;&lt;li&gt;Unit tests shortens the code-debug-fix-cycle because you won’t have to load your application and click around to test stuff&lt;/li&gt;&lt;li&gt;When you refactor the code you will know directly if something breaks, but only if you run all the tests in the suite.&lt;/li&gt;&lt;/ul&gt;&lt;/p&gt;&lt;h3&gt;How?&lt;/h3&gt;&lt;p&gt;Flex Unit is an open source project lead by Adobe. It will be integrated with Flash Builder 4, but as it is an ActionScript3 project it can be used with Flex Builder. It has a graphical test runner based on Flex. You can create either a separate application for the test runner or you could integrate it into your application. The FlexUnit project consists of a couple of swc-files which you put in your test project.&lt;/p&gt;&lt;p&gt;You write tests in ActionScript for all your code by extending the class TestCase. Below is an example of a test for one of the methods in the GAV Flash class ArrayHelper:&lt;/p&gt;&lt;pre class=&quot;prettyprint&quot;&gt;&lt;br /&gt;package gavtests.utils&lt;br /&gt;{&lt;br /&gt;    import flexunit.framework.TestCase;&lt;br /&gt;    import gav.utils.ArrayHelper;&lt;br /&gt;&lt;br /&gt;    public class ArrayHelperTest extends TestCase&lt;br /&gt;    {&lt;br /&gt;        public function testCreateArray(): void&lt;br /&gt;        {&lt;br /&gt;            function filler(i:uint, arr:Array): * {&lt;br /&gt;                return i*i;&lt;br /&gt;            }&lt;br /&gt;            assertObjectEquals([0,1,4,9,16,25], &lt;br /&gt;                ArrayHelper.createArray(6, filler));&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;} &lt;br /&gt;&lt;/pre&gt;&lt;p&gt;The TestCase class provides several methods named assertXXX which are used to do the actual testing. In this case two objects are compared using the assertObjectEquals, one is the return value from createArray and the other is what we would expect it to be. Whenever an assertion fails, the test is stopped.The ArrayHelperTest class is added to a test suite, which is added to the test runner. Below is a simple testing application which features a graphical test runner and runs the test class above:&lt;/p&gt;&lt;pre class=&quot;prettyprint&quot;&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;&lt;br /&gt;&amp;lt;mx:Application &lt;br /&gt;    xmlns:mx=&amp;quot;http://www.adobe.com/2006/mxml&amp;quot;     &lt;br /&gt;    creationComplete=&amp;quot;onCreationComplete()&amp;quot; &lt;br /&gt;    layout=&amp;quot;absolute&amp;quot;&lt;br /&gt;    xmlns:flexui=&amp;quot;flexunit.flexui.*&amp;quot;&amp;gt;&lt;br /&gt;    &amp;lt;mx:Script&amp;gt;&lt;br /&gt;    &amp;lt;![CDATA[&lt;br /&gt;        import mx.binding.utils.BindingUtils;&lt;br /&gt;        import flexunit.framework.TestSuite;&lt;br /&gt;        import gavtests.utils.ArrayHelperTest;&lt;br /&gt;        &lt;br /&gt;        private function onCreationComplete(): void&lt;br /&gt;        {&lt;br /&gt;            testRunner.test = createTestSuite();&lt;br /&gt;            testRunner.startTest();&lt;br /&gt;        }&lt;br /&gt;        &lt;br /&gt;        private function createTestSuite(): TestSuite&lt;br /&gt;        {&lt;br /&gt;            var testSuite:TestSuite = new TestSuite();&lt;br /&gt;            // Add your test cases here:&lt;br /&gt;            testSuite.addTestSuite(ArrayHelperTest);&lt;br /&gt;            return testSuite;&lt;br /&gt;        }&lt;br /&gt;    ]]&amp;gt;&lt;br /&gt;    &amp;lt;/mx:Script&amp;gt;&lt;br /&gt;    &amp;lt;flexui:TestRunnerBase id=&amp;quot;testRunner&amp;quot; width=&amp;quot;100%&amp;quot; height=&amp;quot;100%&amp;quot;/&amp;gt;&lt;br /&gt;&amp;lt;/mx:Application&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;h3&gt;What should be tested?&lt;/h3&gt;&lt;p&gt;Test as much as possible. But here are some examples:&lt;ul&gt;&lt;li&gt;All public functions - this should actually exercise all private functions as well. What you should aim for is to cover every single path through your code.&lt;/li&gt;&lt;li&gt;Invalid arguments – define how your square root function should behave if you hand it a negative number and assert that it behaves that way&lt;/li&gt;&lt;li&gt;Boundary conditions – how should your array manipulating algorithm behave when you pass it an empty array?&lt;/li&gt;&lt;li&gt;Properties  –  You might find it unnecessary to test that a property actually has the value you assign to it, but if you at some point mess up a property setter it might take a long while for you to debug that. If you have a test case for it you will find out directly. What if you assign null? I’ve seen code that keeps the old value in this case, which is probably incorrect.&lt;/li&gt;&lt;li&gt;That event listeners are removed from the old property value if you assign a new one&lt;/li&gt;&lt;li&gt;Bugs. Whenever you find a bug reproducible by code, add a test case for it and fix it. That way the bug won’t reappear.&lt;/li&gt;&lt;/ul&gt;&lt;/p&gt;&lt;h3&gt;GAV Flash tests&lt;/h3&gt;&lt;p&gt;I’ve created a new project on SVN called GavFlashTests where I will try to add tests whenever I write new code for GAV Flash. We probably will never cover all of the current code with unit tests, but then again we probably won&#39;t use the current code forever.&lt;/p&gt;&lt;h3&gt;Resources&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;http://opensource.adobe.com/wiki/display/flexunit/Developer+Documentation&quot;&gt;Developer Documentation&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://blogs.digitalprimates.net/codeSlinger/index.cfm/2009/5/3/FlexUnit-4-in-360-seconds&quot;&gt;FlexUnit 4 in 360 seconds&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://gavflash.blogspot.com/feeds/2774659328189298267/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gavflash.blogspot.com/2009/11/unit-testing-with-flex-unit-4.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2861696249025058484/posts/default/2774659328189298267'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2861696249025058484/posts/default/2774659328189298267'/><link rel='alternate' type='text/html' href='http://gavflash.blogspot.com/2009/11/unit-testing-with-flex-unit-4.html' title='Unit testing with Flex Unit 4'/><author><name>Markus</name><uri>http://www.blogger.com/profile/07735639843378697321</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2861696249025058484.post-7257014613595146409</id><published>2009-11-06T15:52:00.000+01:00</published><updated>2009-11-06T15:56:49.861+01:00</updated><title type='text'>GAV Code Meeting #1</title><content type='html'>Today the GAV development team had our first of many bi-weekly code meetings.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;There was much rejoicing! and cake.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Issues discussed:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;- Microthreads, new tool developed by Markus&lt;/div&gt;&lt;div&gt;- Optimizing Performance&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt; &lt;/span&gt;- Invalidation&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt; &lt;/span&gt;- Strict Array typing&lt;/div&gt;&lt;div&gt;- New flash drawing API, applied to map shapes&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gavflash.blogspot.com/feeds/7257014613595146409/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gavflash.blogspot.com/2009/11/gav-code-meeting-1.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2861696249025058484/posts/default/7257014613595146409'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2861696249025058484/posts/default/7257014613595146409'/><link rel='alternate' type='text/html' href='http://gavflash.blogspot.com/2009/11/gav-code-meeting-1.html' title='GAV Code Meeting #1'/><author><name>Tobias</name><uri>http://www.blogger.com/profile/11793823707385627353</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>