<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" version="2.0">

<channel>
	<title>La Fabrick</title>
	
	<link>http://www.lafabrick.com/blog/en/</link>
	<description>Rich interfaces lab (Flex, Flash, Air ...)</description>
	<lastBuildDate>Mon, 28 Nov 2011 22:02:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.4</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/lafabrick/en" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="lafabrick/en" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Make me fluid</title>
		<link>http://www.lafabrick.com/blog/en/2011/05/27/2514-make-me-fluid/</link>
		<comments>http://www.lafabrick.com/blog/en/2011/05/27/2514-make-me-fluid/#comments</comments>
		<pubDate>Thu, 26 May 2011 22:15:33 +0000</pubDate>
		<dc:creator>Fabien</dc:creator>
				<category><![CDATA[La Fabrick @en]]></category>
		<category><![CDATA[Mess]]></category>
		<category><![CDATA[Our projects]]></category>
		<category><![CDATA[Pure Style @en]]></category>
		<category><![CDATA[User experience]]></category>
		<category><![CDATA[[Dev] Flash / Flex / AIR... @en]]></category>

		<guid isPermaLink="false">http://www.lafabrick.com/blog/?p=2514</guid>
		<description><![CDATA[Do you remember the old website of Paul Neave? Around 2004 I think. A must of Web 1.0 where the background borders twisted, as the mouse rolled over them. It&#8217;s one of those sites which, at the time, made ​​me say that Flash was cool. Some time ago, following the work of Philippe Elsass (@elsassph) [...]]]></description>
			<content:encoded><![CDATA[<p><img class="aligncenter size-full wp-image-2554" title="FluidGuy" src="http://www.lafabrick.com/blog/wp-content/uploads/2011/05/TheFluidGuy.png" alt="" width="295" height="251" /><br />
Do you remember the <a href="http://web.archive.org/web/20050204015952/http://www.neave.com/games/">old website</a> of <a href="http://twitter.com/#!/neave">Paul Neave</a>? Around 2004 I think. A must of Web 1.0 where the background borders twisted, as the mouse rolled over them. It&#8217;s one of those sites which, at the time, made ​​me say that Flash was cool.</p>
<p>Some time ago, following the work of <a href="http://philippe.elsass.me/">Philippe Elsass</a> (<a href="http://twitter.com/#!/elsassph">@elsassph</a>) about parametric path drawing, I started to dig in this subject. First, in a primitive&#8217;s library for Flex4 : <a href="http://code.google.com/p/uigfx/">UIGFX</a>, and then by making my apps&#8217; skins more&#8230; twisted!<br />
<span id="more-2514"></span></p>
<p><strong>Disclamer : because of the use of many samples, and because this article is a jelly&#8217;s trip, Your computer may change and may become a little grumpy</strong></p>
<p>Those who <a href="http://twitter.com/#!/fabienbizot">follow me on Twitter</a> have perhaps already seen some tests.</p>
<table width="100%">
<tbody>
<tr>
<td width="50%"><a href="http://www.lafabrick.com/labz/skins/jellySound/"><img class="aligncenter size-full wp-image-2558" title="jellySound" src="http://www.lafabrick.com/blog/wp-content/uploads/2011/05/jellySound.png" alt="" width="280" height="200" /></a></td>
<td width="50%"><a href="http://www.lafabrick.com/labz/skins/jellySkin/"><img class="aligncenter size-full wp-image-2557" title="jellySkin" src="http://www.lafabrick.com/blog/wp-content/uploads/2011/05/jellySkin.png" alt="" width="280" height="200" /></a></td>
</tr>
</tbody>
</table>
<p><em>(Click to open)</em><br />
These interactive skinning tests for Flex, come from an extension of library UIGFX (extension that I have not yet released by lack of time&#8230;)</p>
<p>BIGA! <a href="http://en.nicoptere.net/">Nicolas Barradeau</a> (<a href="http://twitter.com/#!/nicoptere">@nicoptere</a>) has written an impressive serie of articles about generative art, which ended in a set of geometric tools: <a href="http://code.google.com/p/biga/">Biga</a>. I could not help myself and resumed my experiments.</p>
<h2>Some points&#8230;</h2>
<p>The idea of the &laquo;&nbsp;fluid&nbsp;&raquo; interaction is based on repulsion algorithm. When the mouse point approaches a zone of interaction of a point vector, you must calculate a &laquo;&nbsp;dispersion&nbsp;&raquo; of the point.</p>
<p>For doing this, I use two distinct factors:</p>
<ul>
<li><strong>viscosity</strong>: a factor which gives, as its name suggests, the viscosity of the point. In the physics of fluid, the viscosity is the ability for a liquid to flow. The lower the coefficient is, the more the fluid will flow fast (eg: water). Conversely, the higher the coefficient is, the more the fluid will be subject to physical constraints (eg: jam).</li>
<li><strong>jelly</strong>: this is my homemade coefficient. An indicator that allows to specify the intensity of a fluid&#8217;s distortion. The lower this factor is, the more the rate of deformation, and therefore the movement of the form, will be important.</li>
</ul>
<p>In AS3, it is expressed this way:</p>
<pre class="brush: js">
public function update(owner:DisplayObject):void
{
offsetx+=(xref - x) / jelly;
offsety+=(yref - y) / jelly;

var dx:Number=0;
var dy:Number=0;
if (owner.stage)
{
dx=x - owner.stage.mouseX;
dy=y - owner.stage.mouseY;
}

if (Math.sqrt((dx * dx) + (dy * dy)) &lt;= approach * 1.1)
{
var divisor:Number=approach / 10;
var a:Number=Math.atan2(dy, dx);

offsetx+=(Math.cos(a) * approach - dx) / divisor;
offsety+=(Math.sin(a) * approach - dy) / divisor;
}

offsetx*=(1 - viscosity);
offsety*=(1 - viscosity);
if (Math.abs(offsetx) &lt; .001)
{
offsetx=0;
}

if (Math.abs(offsety) &lt; .001)
{
offsety=0;
}

x+=offsetx;
y+=offsety;
}
</pre>
<p>Visually:<br />

    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="swfobj_0" width="650" height="300" align="center">
      <param name="movie" value="http://fabien.lafabrick.com/labs/fluid/FluidSpritePointTest.swf" />
      <param name="align" value="center" />
      <!--[if !IE]>-->
      <object type="application/x-shockwave-flash" data="http://fabien.lafabrick.com/labs/fluid/FluidSpritePointTest.swf" width="650" height="300" align="center">
      <!--<![endif]-->
        
      <!--[if !IE]>-->
      </object>
      <!--<![endif]-->
    </object>
</p>
<h2>&#8230;Some lines&#8230;</h2>
<p>2 points define a line. It&#8217;s the rule.<br />

    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="swfobj_1" width="650" height="300" align="center">
      <param name="movie" value="http://fabien.lafabrick.com/labs/fluid/FluidSimpleLineTest.swf" />
      <param name="align" value="center" />
      <!--[if !IE]>-->
      <object type="application/x-shockwave-flash" data="http://fabien.lafabrick.com/labs/fluid/FluidSimpleLineTest.swf" width="650" height="300" align="center">
      <!--<![endif]-->
        
      <!--[if !IE]>-->
      </object>
      <!--<![endif]-->
    </object>
</p>
<h3>Projection</h3>
<p>To get a &laquo;&nbsp;real&nbsp;&raquo; fluid line, you must have an intermediate point on the line.<br />
A simple and effective method is to project the mouse point on the line. Mathematicians have solved the problem a long time ago, and the AS3 implementation of the projection algorithm looks like this:</p>
<pre class="brush: js">
public static function projection(p:Point, a:Point, b:Point):Point
{
var len:Number = length(a, b);
var r:Number = (((a.y - p.y) * (a.y - b.y)) - ((a.x - p.x) * (b.x - a.x))) / (len * len);

var px:Number = a.x + r * (b.x - a.x);
var py:Number = a.y + r * (b.y - a.y);

return new Point(px, py);
}
</pre>
<p>With the geometric tools suggested by @nicoptere, the projection point can be calculated as follows:</p>
<pre class="brush: js">
var mousePoint : Point = new Point(mouseX, mouseY);
var projection : Point = GeomUtils.project(mousePoint, point1, point2);
var constraintProjection : Point = GeomUtils.constrain( projection, point, point2);
</pre>
<p>The projection of the mouse point on our line allows us to obtain an interesting interaction:<br />

    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="swfobj_2" width="650" height="300" align="center">
      <param name="movie" value="http://fabien.lafabrick.com/labs/fluid/FluidLineTest.swf" />
      <param name="align" value="center" />
      <!--[if !IE]>-->
      <object type="application/x-shockwave-flash" data="http://fabien.lafabrick.com/labs/fluid/FluidLineTest.swf" width="650" height="300" align="center">
      <!--<![endif]-->
        
      <!--[if !IE]>-->
      </object>
      <!--<![endif]-->
    </object>
<br />
If origin points are fixed, you get a kind of guitar string. Fun.<br />

    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="swfobj_3" width="650" height="400" align="center">
      <param name="movie" value="http://fabien.lafabrick.com/labs/fluid/FluidRopeTest.swf" />
      <param name="align" value="center" />
      <!--[if !IE]>-->
      <object type="application/x-shockwave-flash" data="http://fabien.lafabrick.com/labs/fluid/FluidRopeTest.swf" width="650" height="400" align="center">
      <!--<![endif]-->
        
      <!--[if !IE]>-->
      </object>
      <!--<![endif]-->
    </object>
</p>
<h2>&#8230;And some paths</h2>
<p>With even more points, we start to have a shape&#8230; like an English cake:<br />

    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="swfobj_4" width="650" height="400" align="center">
      <param name="movie" value="http://fabien.lafabrick.com/labs/fluid/FluidRectTest.swf" />
      <param name="align" value="center" />
      <!--[if !IE]>-->
      <object type="application/x-shockwave-flash" data="http://fabien.lafabrick.com/labs/fluid/FluidRectTest.swf" width="650" height="400" align="center">
      <!--<![endif]-->
        
      <!--[if !IE]>-->
      </object>
      <!--<![endif]-->
    </object>
<br />
Another interesting example that uses the drawing method of Philippe Elsass:<br />
<em>(Click to add a point, drag a point to change its position, Ctrl/Cmd + click to remove a point)</em><br />

    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="swfobj_5" width="650" height="500" align="center">
      <param name="movie" value="http://fabien.lafabrick.com/labs/fluid/FluidMouseShapeTest.swf" />
      <param name="align" value="center" />
      <!--[if !IE]>-->
      <object type="application/x-shockwave-flash" data="http://fabien.lafabrick.com/labs/fluid/FluidMouseShapeTest.swf" width="650" height="500" align="center">
      <!--<![endif]-->
        
      <!--[if !IE]>-->
      </object>
      <!--<![endif]-->
    </object>
</p>
<h2>Even more &laquo;&nbsp;jelly&nbsp;&raquo;</h2>
<p>As I said at the beginning of this article, we work for some time on a library of primitives for Flex4: UIGFX. The idea is to propose a series of useful primitives, that are not offered as standard in the Flex4 SDK (dotted line, arc, pie, &#8230;.).</p>
<p>In this library, we&#8217;ve set up a graphical representation of SVG path, which, unlike the standard Path primitive, enables putting the vectors in the constraints model (top, left, bottom, right).</p>
<p>With a few changes on UIGFX svg parser, we can easily browse an SVG path and extract the vector points of the form. The idea, you can imagine, is to twist the Path <img src='http://www.lafabrick.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />

    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="swfobj_6" width="650" height="500" align="center">
      <param name="movie" value="http://fabien.lafabrick.com/labs/fluid/FluidSvgTest.swf" />
      <param name="align" value="center" />
      <!--[if !IE]>-->
      <object type="application/x-shockwave-flash" data="http://fabien.lafabrick.com/labs/fluid/FluidSvgTest.swf" width="650" height="500" align="center">
      <!--<![endif]-->
        
      <!--[if !IE]>-->
      </object>
      <!--<![endif]-->
    </object>
</p>
<h2>Sources and ressources</h2>
<ul>
<li>You will find all sources <a href="http://fabien.lafabrick.com/labs/fluid/makeMeFluid-src.zip">in this zip</a></li>
<li><a href="http://code.google.com/p/biga/">Biga, geometric tools library</a></li>
<li><a href="http://en.nicoptere.net/?tag=generative-art">The series of articles</a> by <a href="http://twitter.com/#!/nicoptere">Nicolas Barradeau</a> on the geometry</li>
<li><a href="http://philippe.elsass.me/2009/06/as3-parametric-path-drawing/">Parametric path drawing</a> by <a href="http://twitter.com/#!/elsassph">Philippe Elsass</a></li>
<li>And off course <a href="http://neave.com/">the (current) website</a> of <a href="http://twitter.com/#!/neave">Paul Neave</a> <span style="text-decoration: line-through;">(Paul, if you read me, please! Met online, in a corner, the old version of your website!)</span> &#8230; And best of all : <a href="http://web.archive.org/web/20050204015952/http://www.neave.com/games/">the old website</a> <img src='http://www.lafabrick.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
</ul>
<p>Have fluid&#8217;s fun !Autres articles sur le même sujet
<ul>
<li><a href="http://www.lafabrick.com/blog/2007/06/08/142-viscosity-ou-quand-les-ria-font-de-l-art-moderne/" rel="bookmark" title="8 juin 2007">Viscosity, ou quand les RIA font de l&#8217;Art Moderne&#8230;</a></li>
<li><a href="http://www.lafabrick.com/blog/2007/09/12/218-actionscript-php-make-it-fun-with-swx/" rel="bookmark" title="12 septembre 2007">Actionscript + PHP : make it fun with SWX !!!</a></li>
<li><a href="http://www.lafabrick.com/blog/2010/02/09/1964-uigfx-project-flex4-primitives-library-fireworks-extension/" rel="bookmark" title="9 février 2010">uigfx project : Flex4 primitives library / Fireworks extension</a></li>
<li><a href="http://www.lafabrick.com/blog/2011/05/27/2576-make-me-fluid-2/" rel="bookmark" title="27 mai 2011">Make me Fluid</a></li>
</ul>
<p><!-- Similar Posts took 11.942 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.lafabrick.com/blog/en/2011/05/27/2514-make-me-fluid/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>MdaME, my code generation 2011 resolution</title>
		<link>http://www.lafabrick.com/blog/en/2011/01/12/2393-mdame-my-code-generation-2011-resolution/</link>
		<comments>http://www.lafabrick.com/blog/en/2011/01/12/2393-mdame-my-code-generation-2011-resolution/#comments</comments>
		<pubDate>Tue, 11 Jan 2011 22:00:45 +0000</pubDate>
		<dc:creator>Hervé</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.lafabrick.com/blog/?p=2393</guid>
		<description><![CDATA[It&#8217;s been a while since we were busy on something and quiet. Time to solve this! Indeed, to start this new year on the right side, La Fabrick published a small AS3 code generation application based on XSD files. This tool was usefull to us in many projects for our first customers, so why not [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.lafabrick.com/blog/wp-content/uploads/2011/01/MdaMe.png"><img title="MdaMe" src="http://www.lafabrick.com/blog/wp-content/uploads/2011/01/MdaMe.png" alt="" width="499" height="64" /></a></p>
<p>It&#8217;s been a while since we were busy on something and quiet. Time to solve this!</p>
<p>Indeed, to start this new year on the right side, La Fabrick published a small AS3 code generation application based on XSD files.</p>
<p>This tool was usefull to us in many projects for our first customers, so why not sharing it? Maybe you&#8217;ll become MdaME-addict as well?</p>
<p>All information are on: <a href="http://mdame.lafabrick.com/en">http://mdame.lafabrick.com/en</a>Autres articles sur le même sujet
<ul>
<li><a href="http://www.lafabrick.com/blog/2008/02/05/300-souriez-vous-allez-tre-modlis/" rel="bookmark" title="5 février 2008">Souriez vous allez être modélisé <img src='http://www.lafabrick.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </a></li>
<li><a href="http://www.lafabrick.com/blog/2009/01/21/999-what-is-adobe-cocomo/" rel="bookmark" title="21 janvier 2009">Developing with AFCS a.k.a Cocomo &#8211; Introduction</a></li>
<li><a href="http://www.lafabrick.com/blog/2009/06/11/1174-flashbuildereclipse-installation-guide-subclipse-pdt-wtp-and-maven/" rel="bookmark" title="11 juin 2009">FlashBuilder/Eclipse : installation guide &#8211; subclipse, PDT, WTP and Maven</a></li>
<li><a href="http://www.lafabrick.com/blog/2011/01/11/2349-mdame-generateur-code-xsd-as3-flex/" rel="bookmark" title="11 janvier 2011">MdaME, ma résolution 2011 de génération de code AS3</a></li>
</ul>
<p><!-- Similar Posts took 15.762 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.lafabrick.com/blog/en/2011/01/12/2393-mdame-my-code-generation-2011-resolution/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RollingFileTarget in AIR 2.0: let’s roll!</title>
		<link>http://www.lafabrick.com/blog/en/2010/10/21/2283-rollingfiletarget-in-air-2-0-lets-roll/</link>
		<comments>http://www.lafabrick.com/blog/en/2010/10/21/2283-rollingfiletarget-in-air-2-0-lets-roll/#comments</comments>
		<pubDate>Thu, 21 Oct 2010 17:42:50 +0000</pubDate>
		<dc:creator>Hervé</dc:creator>
				<category><![CDATA[[Dev] Flash / Flex / AIR... @en]]></category>
		<category><![CDATA[AIR @en]]></category>
		<category><![CDATA[Flex @en]]></category>
		<category><![CDATA[linkedin]]></category>
		<category><![CDATA[logging]]></category>

		<guid isPermaLink="false">http://www.lafabrick.com/blog/?p=2283</guid>
		<description><![CDATA[For those who know and use the Flex  logging API, you may have noticed the lack of a file &#171;&#160;Target&#160;&#187; (even if the trace results finish somewhere deep in your Flash Player application data folder). For those who wondered about where they could find such a target, you probably found Mike Chambers&#8216;s as3corelib  FileTarget (Yay!). For those [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img class="aligncenter" src="http://help.adobe.com/en_US/flex/using/images/lg_logger_target_dist_popup.png" alt="Flex Logging API" width="506" height="60" /></p>
<p>For those who know and use the Flex  logging API, you may have noticed the lack of a file &laquo;&nbsp;Target&nbsp;&raquo; (even if the <strong>trace</strong> results finish somewhere deep in your Flash Player application data folder).</p>
<p>For those who wondered about where they could find such a target, you probably found <a href="http://twitter.com/#!/mesh">Mike Chambers</a>&#8216;s as3corelib  <a href="http://github.com/mikechambers/as3corelib/blob/master/src/com/adobe/air/logging/FileTarget.as">FileTarget</a> (Yay!).</p>
<p>For those who wondered whenever there would exist an equivalent to <strong>log4j RollingFileAppender</strong> in AIR (and event if you don&#8217;t, I hope some of you will stay and read this until the end <img src='http://www.lafabrick.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> ), well you probably found nothing at all.</p>
<p>So that&#8217;s the point, I couldn&#8217;t resist to do something about that.</p>
<p><span id="more-2283"></span></p>
<h2>A quick overview of Flex logging API</h2>
<p>And why not a plain old <code>trace("simply this")</code> ?<br />
Because the <code>trace()</code> function traces everything, every time, and without indicating complementary information such as criticity or current time&#8230; It is indeed useful for simple debugging, but when it comes to creating robust applications, it just doesn&#8217;t fit.</p>
<h2>How do we create nice and clean traces</h2>
<p>It is simple (cf. Flex documentation) :</p>
<h3>The target</h3>
<pre class="brush: js">
/* Create a target. */
var logTarget:TraceTarget = new TraceTarget();

/* Log only messages for the classes in the mx.rpc.* and
mx.messaging packages. */
logTarget.filters=[&quot;mx.rpc.*&quot;,&quot;mx.messaging.*&quot;];

/* Log all log levels. */
logTarget.level = LogEventLevel.ALL;

/* Add date, time, category, and log level to the output. */
logTarget.includeDate = true;
logTarget.includeTime = true;
logTarget.includeCategory = true;
logTarget.includeLevel = true;

/* Begin logging. */
Log.addTarget(logTarget);
</pre>
<p>Note the usage of the TraceTarget class which will route the traces to the console and eventually to the Flash Player log file.<br />
But it comes with the following enhancements:</p>
<ul>
<li>Log level : every trace with a lower level than the configured one will be ignored</li>
<li>Category filters : thoses filters enable to limit traces only to configured categories</li>
</ul>
<h3>The logger</h3>
<p>We configured a target, now let&#8217;s trace! You need to create a ILogger implementation instance:</p>
<pre class="brush: js">
private static var _logger:ILogger = Log.getLogger(&quot;com.lafabrick.classes.MyClass&quot;);
</pre>
<p>It is a common best practice to create a static logger instance to limit memory usage.<br />
Note the usage of package like category declaration which enables filtering on target side.<br />
You can then use this <code>_logger</code> by calling the following functions:</p>
<pre class="brush: js">
_logger.debug(&quot;Debug trace&quot;);
_logger.info(&quot;Info trace&quot;);
_logger.warn(&quot;Warning trace&quot;);
_logger.error(&quot;Error trace&quot;);
_logger.fatal(&quot;Fatal trace&quot;);
</pre>
<p>These calls will trigger the call to the internalLog method of the configured LoggingTarget instances declared before, depending on the level and category.</p>
<h2>Creating a custom logging target</h2>
<p>You now have to create a custom target by extending the AbstractTarget or LineFormattedTarget class (the latter will take care of formatting the message using the category, date and time which is clearly an good thing).</p>
<p>This is what Mike did with its FileTarget that I will let you check directly on <a href="http://github.com">Github</a>.</p>
<h2>RollingFileTarget</h2>
<p>I used this FileTarget as a base for developping the RollingFileTarget class which intends to create log file backups based on two policies:</p>
<ol>
<li><strong>Date</strong><br />
Goal: one log file per day, month or year</li>
<li><strong>Weight</strong><br />
Goal: the log file size must not exceed a given limit</li>
</ol>
<p><span style="color: #ff0000;">Please note that those two policies should be </span><strong><span style="color: #ff0000;">mutually exclusive</span></strong><span style="color: #ff0000;">: i.e. either </span><strong><span style="color: #ff0000;">choose to roll on log file size OR file date</span></strong><span style="color: #ff0000;"> if you want to keep backups in a natural order. Combination of both policies is possible but will lead to maintain two backup queues which will enventually evolve in different ways in terms of log history.</span></p>
<h3>Usage</h3>
<p>This is a classic target implementation that you can use this way:</p>
<pre class="brush: js">
var fileTarget:RollingFileTarget = new RollingFileTarget(new File(&quot;app-storage:/logs/myapp.log&quot;));
fileTarget.filters = [&quot;*&quot;];
fileTarget.includeDate = true;
fileTarget.level = LogEventLevel.ERROR;
fileTarget.includeTime = true;
fileTarget.includeCategory = true;
fileTarget.includeLevel = true;
fileTarget.rollingInterval = RollingFileTarget.DAY_INTERVAL; // One log file per day
fileTarget.maxLogFileWeight = 0; // No size limit
fileTarget.maxLogBackups = 7; // 7 log files backup maximum (approx. one week here)
Log.addTarget(fileTarget);
</pre>
<p>You may have noticed the following properties:</p>
<ul>
<li><strong>rollingInterval</strong> : the date rolling mode. You can choose amongst <strong>RollingFileTarget.DAY_INTERVAL</strong>, <strong>RollingFileTarget.MONTH_INTERVAL</strong>, <strong>RollingFileTarget.YEAR_INTERVAL</strong>, <strong>RollingFileTarget.NO_INTERVAL</strong><br />
I&#8217;ll let you figure out the meaning of each constant <img src='http://www.lafabrick.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
<li><strong>maxLogFileWeight</strong> : The log file maximum size, in bytes.<br />
To limit the file size to 5Mb you should set the maxLogFileWeight to 5000000. Put zero to deactivate rolling based on file size</li>
<li><strong>maxLogBackups</strong> : the maximum number of backups to keep on disk.<br />
The idea is to keep a limited amount of log files, but enough to be able to go back and debug your application. A 7 days interval is commonly sufficient.</li>
</ul>
<div>This target, when &laquo;&nbsp;rolling&nbsp;&raquo;, will thus create a backup of the current log file by renaming it following these rules:</div>
<div>
<ul>
<li><strong><span style="color: #339966;">YYYY-MM-DD</span>-name.log</strong> for a date base rotation</li>
<li><strong>name.log.<span style="color: #339966;">X</span></strong> for a size based roll</li>
</ul>
</div>
<p>You should know that this pattern is used by the <strong>RollingFileTarget </strong>to guess existing log file backups at startup. This enables a continuous behavior at every application restart  (you will agree that it is rare to let an AIR application run continuously for 2 weeks&#8230;)</p>
<p>I thus didn&#8217;t let the possibility to choose your own pattern to avoid dealing with backup detection problems and keeping the thing simple. It&#8217;s only log files at the end&#8230; <img src='http://www.lafabrick.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h3>Download</h3>
<p>You can gracefully download this class and use it, modify it as you wish and at your own risk, La Fabrick won&#8217;t be held responsible for any direct on indirect damage or data loss resulting of the usage of this class. Please also strictly follow the copyright notice present in the header, thanks!</p>
<p style="text-align: center;"><a href="http://github.com/hlabas/as3corelib/blob/master/src/com/adobe/air/logging/RollingFileTarget.as"><img class="aligncenter" title="Download" src="http://www.lafabrick.com/blog/wp-content/uploads/2010/10/deb.png" alt="Télécharger" width="128" height="128" /></a></p>
<p>Finally, I remind you that this class can only be used within AIR application as it depends on its API.</p>
<p>Have a nice logging experience!Autres articles sur le même sujet
<ul>
<li><a href="http://www.lafabrick.com/blog/2009/01/21/999-what-is-adobe-cocomo/" rel="bookmark" title="21 janvier 2009">Developing with AFCS a.k.a Cocomo &#8211; Introduction</a></li>
<li><a href="http://www.lafabrick.com/blog/2010/08/20/2167-air-2-appeler-un-jar-executable-via-un-nativeprocess/" rel="bookmark" title="20 août 2010">AIR 2 : appeler un JAR exécutable via un NativeProcess</a></li>
<li><a href="http://www.lafabrick.com/blog/2010/07/28/2092-zxpackager-application-pour-l%e2%80%99empaquetage-zxp-d%e2%80%99extensions-cs5/" rel="bookmark" title="28 juillet 2010">ZXPackager : application pour l’empaquetage ZXP d’extensions CS5</a></li>
<li><a href="http://www.lafabrick.com/blog/2010/10/21/2272-rollingfiletarget-pour-air-2-0-lets-roll/" rel="bookmark" title="21 octobre 2010">RollingFileTarget pour AIR 2.0 : let&#8217;s roll !</a></li>
</ul>
<p><!-- Similar Posts took 12.303 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.lafabrick.com/blog/en/2010/10/21/2283-rollingfiletarget-in-air-2-0-lets-roll/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ZXPackager: a packager for ZXP CS5 extensions</title>
		<link>http://www.lafabrick.com/blog/en/2010/07/29/2195-zxpackager-a-packager-for-zxp-cs5-extensions/</link>
		<comments>http://www.lafabrick.com/blog/en/2010/07/29/2195-zxpackager-a-packager-for-zxp-cs5-extensions/#comments</comments>
		<pubDate>Wed, 28 Jul 2010 22:44:41 +0000</pubDate>
		<dc:creator>Fabien</dc:creator>
				<category><![CDATA[Our projects]]></category>
		<category><![CDATA[AIR @en]]></category>
		<category><![CDATA[Applications @en]]></category>
		<category><![CDATA[Flex @en]]></category>
		<category><![CDATA[Lafabrick @en]]></category>
		<category><![CDATA[zxp @en]]></category>

		<guid isPermaLink="false">http://www.lafabrick.com/blog/?p=2195</guid>
		<description><![CDATA[You may have noticed that we added a brand new Applications section to the blog. We&#8217;re currently working on several AIR developer-oriented applications. ZXPackager is the first one. This application provides a simple way to package your CS5 extensions developed with the the new Creative Suite SDK. ZXP extensions Since CS5, Adobe provides a new [...]]]></description>
			<content:encoded><![CDATA[<table width="100%">
<tr>
<td width="125px"><img src="http://www.lafabrick.com/blog/wp-content/uploads/2010/07/logo128.png"  width="128" height="128" class="aligncenter size-full wp-image-2099" /></td>
<td width="100%">You may have noticed that we added a brand new <a href="http://www.lafabrick.com/blog/en/applications-2/">Applications</a> section to the blog. We&#8217;re currently working on several AIR developer-oriented applications. ZXPackager is the first one.</p>
<p>This application provides a simple way to package your CS5 extensions developed with the the new Creative Suite SDK.</td>
</tr>
</table>
<p><span id="more-2195"></span></p>
<h2>ZXP extensions</h2>
<p>Since CS5, Adobe provides a new SDK with a common extension format to the whole software suite.<br />
This SDK, <a href="http://www.adobe.com/devnet/creativesuite/sdk/eula_cs5_toolkit.html">available here</a>, enables you to develop your own panels and CS5 menus. The first available format is MXP, still available, which enables you to export a package for a given CS5 software.<br />
Now, with CS5, you may now take advantage of a common format (ZXP) which is compatible with the whole CS5 suite. </p>
<p>A ZXP file contains an XML manifest, which defines the plugin features (type, software type, &#8230;), and contains the SWF file corresponding to the extension (an extension is actually a kind of AIR application based on CS SDK). A ZXP file must be signed with a digital certificate. You must thus provide this certificate to the application (PKCS12, PKCS11, JKS). You can of course use a self-signed certificate generated using FlashBuilder / FlexBuilder. </p>
<p>More information:</p>
<ul>
<li><a href="http://www.adobe.com/devnet/creativesuite/sdk/index.html">Creative Suite SDK</a></li>
<li><a href="http://blogs.adobe.com/cssdk/">CSSDK Blog</a></li>
</ul>
<p>A ZXP file must usually be compiled using the java <a href="http://www.adobe.com/devnet/creativesuite/sdk/eula_cs5_toolkit.html">UCF</a> packager. This is exactly the idea of ZXPackager: avoiding defining your certificate file and other options on every CS5 package and propose a more user-friendly way to create a ZXP package than the command line way.</p>
<h2>How it works</h2>
<h3>Startup, and preferences</h3>
<p>At initial startup, the application must be aware of your computer&#8217;s configuration.<br />
<center><img src="http://www.lafabrick.com/blog/wp-content/uploads/2010/07/Preferences.png" alt="Preferences" title="Preferences" width="500" height="450" class="aligncenter size-full wp-image-2100" /></center></p>
<ul>
<li>
<h4>Java Home</h4>
<p>You must provide the JDK/JRE home (so that ZXPackager can use it to launch UCF), if it is not the default one. Default paths are defined as follows: </p>
<ul>
<li>On Windows : <strong>&#8216;C:\Program Files\Java\jdk1.6.0&#8242;</strong></li>
<li>On Mac : <strong>&#8216;/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0&#8242;</strong></li>
</ul>
</li>
<li>
<h4>Certificate</h4>
<p>You must provide the path of your certificate (usually a .p12 or .p11 file), as well as its password. Those information are necessary to digitally sign your CS5 extension package.</li>
</ul>
<h3>Extension definition</h3>
<p>A ZXP package needs 2 information: the name and path of the target CS5 extension, as well as the path to the &laquo;&nbsp;bin&nbsp;&raquo; folder of your extension.<br />
<center><img src="http://www.lafabrick.com/blog/wp-content/uploads/2010/07/StartProject.png" alt="start package" title="StartProject" width="500" height="450" class="aligncenter size-full wp-image-2102" /></center></p>
<ul>
<li>
<h4>Target file</h4>
<p>Your must give the generated ZXP file path. The .zxp extension is added automatically.
</li>
<li>
<h4>Extension source</h4>
</li>
<p>The extension sources, as defined in the CS5 SDK guidelines, must follow this organization:<br />
<center><img src="http://www.lafabrick.com/blog/wp-content/uploads/2010/07/binPackageOverview.png" width="537" height="80" class="aligncenter size-full wp-image-2096" /></center><br />
The target folder is created by the Ant task, in your project (cf. the extension test project at the end of this article)<br />
You must target the &laquo;&nbsp;bin&nbsp;&raquo; subfolder (compilation result).
</li>
</ul>
<p>Once packaging has begun, the following message is displayed.<br />
<center><img src="http://www.lafabrick.com/blog/wp-content/uploads/2010/07/waiting-mini.png" width="467" height="48" class="aligncenter size-full wp-image-2103" /></center></p>
<h3>Finalisation</h3>
<p>Once the package has been created, the application enables you to:</p>
<ul>
<li>Create a new package</li>
<li>Open and install the extension using the Extension Manager (you must obviously have the CS5 Extension Manager installed on your computer to make it work)</li>
</ul>
<p><center><img src="http://www.lafabrick.com/blog/wp-content/uploads/2010/07/completed.png" alt="" title="completed" width="500" height="450" class="aligncenter size-full wp-image-2097" /></center></p>
<h2>Download</h2>
<h3>ZXPackager</h3>
<p><center></p>
<table>
<tr>
<td width="128"><a href="http://www.lafabrick.com/applications/zxpackager/ZXPackager-MAC.zip"><img src="http://www.lafabrick.com/blog/wp-content/uploads/2010/07/macPackageExport.png" alt="" title="macPackageExport" width="128" height="128" class="aligncenter size-full wp-image-2137" /></a></td>
<td width="128"><a href="http://www.lafabrick.com/applications/zxpackager/ZXPackager-WIN.zip"><img src="http://www.lafabrick.com/blog/wp-content/uploads/2010/07/winPackageExport.png" alt="" title="winPackageExport" width="128" height="128" class="aligncenter size-full wp-image-2137" /></a></td>
</tr>
</table>
<p></center></p>
<h3>Test extension</h3>
<ul>
<li><a href="http://lafabrick.com/applications/zxpackager/extensionTest.fxp">FXP project</a></li>
<li><a href="http://lafabrick.com/applications/zxpackager/bin.zip">Test project&#8217;s bin folder as ZIP archive</a></li>
</ul>
<p>Autres articles sur le même sujet
<ul>
<li><a href="http://www.lafabrick.com/blog/2009/06/11/1174-flashbuildereclipse-installation-guide-subclipse-pdt-wtp-and-maven/" rel="bookmark" title="11 juin 2009">FlashBuilder/Eclipse : installation guide &#8211; subclipse, PDT, WTP and Maven</a></li>
<li><a href="http://www.lafabrick.com/blog/2010/08/20/2167-air-2-appeler-un-jar-executable-via-un-nativeprocess/" rel="bookmark" title="20 août 2010">AIR 2 : appeler un JAR exécutable via un NativeProcess</a></li>
<li><a href="http://www.lafabrick.com/blog/2010/02/09/1964-uigfx-project-flex4-primitives-library-fireworks-extension/" rel="bookmark" title="9 février 2010">uigfx project : Flex4 primitives library / Fireworks extension</a></li>
<li><a href="http://www.lafabrick.com/blog/2010/07/28/2092-zxpackager-application-pour-l%e2%80%99empaquetage-zxp-d%e2%80%99extensions-cs5/" rel="bookmark" title="28 juillet 2010">ZXPackager : application pour l’empaquetage ZXP d’extensions CS5</a></li>
</ul>
<p><!-- Similar Posts took 21.568 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.lafabrick.com/blog/en/2010/07/29/2195-zxpackager-a-packager-for-zxp-cs5-extensions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DashedLine : the Little Big Primitive</title>
		<link>http://www.lafabrick.com/blog/en/2010/07/23/2011-dashedline-the-little-big-primitive/</link>
		<comments>http://www.lafabrick.com/blog/en/2010/07/23/2011-dashedline-the-little-big-primitive/#comments</comments>
		<pubDate>Fri, 23 Jul 2010 09:07:01 +0000</pubDate>
		<dc:creator>Fabien</dc:creator>
				<category><![CDATA[Our projects]]></category>
		<category><![CDATA[[Dev] Flash / Flex / AIR... @en]]></category>
		<category><![CDATA[flex4 @en]]></category>
		<category><![CDATA[Spark @en]]></category>
		<category><![CDATA[uigfx @en]]></category>

		<guid isPermaLink="false">http://www.lafabrick.com/blog/?p=2011</guid>
		<description><![CDATA[I just added a small but useful primitive in UIGFX library : DashedLine, which, as its name suggests, enables to drawn dashed lines (I&#8217;m really good at finding names ). This primitive is based on Line, and adds a dashes property, which lets you alter the dashes display. dashes is a Number Array. For each [...]]]></description>
			<content:encoded><![CDATA[<p><center><img src="http://www.lafabrick.com/blog/wp-content/uploads/2010/07/dashedLine530.png" alt="" title="dashedLine530" width="532" height="59" class="aligncenter size-full wp-image-1997" /></center><br />
I just added a small but useful primitive in <a href="http://uigfx.googlecode.com">UIGFX library</a> : <a href="http://code.google.com/p/uigfx/source/browse/trunk/uigfx/src/com/lafabrick/uigfx/primitives/DashedLine.as">DashedLine</a>, which, as its name suggests, enables to drawn dashed lines (I&#8217;m really good at finding names <img src='http://www.lafabrick.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> ).<br />
<span id="more-2011"></span><br />
This primitive is based on <b>Line</b>, and adds a dashes property, which lets you alter the dashes display.</p>
<p>dashes is a Number Array. For each pair of two numbers, the first one defines the length of the caret (in pixels) and the second one defines the gap size.</p>
<p>Let&#8217;s look at some code: </p>
<pre class="brush: xml">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;s:Application xmlns:fx=&quot;http://ns.adobe.com/mxml/2009&quot;
    xmlns:s=&quot;library://ns.adobe.com/flex/spark&quot;
    xmlns:mx=&quot;library://ns.adobe.com/flex/mx&quot;
    minWidth=&quot;200&quot; minHeight=&quot;200&quot;
    xmlns:uigfx=&quot;http://uigfx.lafabrick.com&quot;&gt;

    &lt;uigfx:DashedLine
        dashes=&quot;[80, 10, 10, 20, 40, 30]&quot;
        left=&quot;100&quot; verticalCenter=&quot;0&quot; right=&quot;100&quot;&gt;

        &lt;uigfx:stroke&gt;
            &lt;s:SolidColorStroke color=&quot;#FFFFFF&quot; weight=&quot;4&quot; caps=&quot;round&quot; /&gt;
        &lt;/uigfx:stroke&gt;

        &lt;uigfx:filters&gt;
            &lt;s:GlowFilter blurX=&quot;4&quot; blurY=&quot;4&quot; alpha=&quot;.8&quot; color=&quot;#333333&quot; /&gt;
        &lt;/uigfx:filters&gt;

    &lt;/uigfx:DashedLine&gt;

    &lt;uigfx:DashedLine
        dashes=&quot;[80, 10, 10, 20, 40, 30]&quot;
        left=&quot;101&quot; verticalCenter=&quot;0&quot; right=&quot;100&quot;&gt;

        &lt;uigfx:stroke&gt;
            &lt;s:LinearGradientStroke weight=&quot;2&quot; pixelHinting=&quot;true&quot; caps=&quot;square&quot;&gt;
                &lt;s:GradientEntry color=&quot;#009EE0&quot; /&gt;
                &lt;s:GradientEntry color=&quot;#FF9900&quot; /&gt;
                &lt;s:GradientEntry color=&quot;#009EE0&quot; /&gt;
            &lt;/s:LinearGradientStroke&gt;
        &lt;/uigfx:stroke&gt;

    &lt;/uigfx:DashedLine&gt;

&lt;/s:Application&gt;
</pre>
<p>Here is the result:<br />
<center><img src="http://www.lafabrick.com/blog/wp-content/uploads/2010/07/dashedLine650.png" alt="" title="dashedLine630" width="650" height="54" class="aligncenter size-full wp-image-1998" /></center><br />
Beautiful right?</p>
<p>It is obviously available on <a href="http://uigfx.googlecode.com">UIGFX Google code</a>.Autres articles sur le même sujet
<ul>
<li><a href="http://www.lafabrick.com/blog/2009/12/04/1453-flex4-skin-et-primitives/" rel="bookmark" title="4 décembre 2009">Flex4 : skin et primitives</a></li>
<li><a href="http://www.lafabrick.com/blog/2010/02/09/1964-uigfx-project-flex4-primitives-library-fireworks-extension/" rel="bookmark" title="9 février 2010">uigfx project : Flex4 primitives library / Fireworks extension</a></li>
<li><a href="http://www.lafabrick.com/blog/2010/07/23/1989-primitive-dashedline-une-petite-ligne-bien-utile/" rel="bookmark" title="23 juillet 2010">Primitive DashedLine : une petite ligne bien utile</a></li>
<li><a href="http://www.lafabrick.com/blog/2010/05/04/1962-uigfx-practice-a-circularslider-component-2/" rel="bookmark" title="4 mai 2010">UIGFX practice : a CircularSlider component</a></li>
</ul>
<p><!-- Similar Posts took 11.704 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.lafabrick.com/blog/en/2010/07/23/2011-dashedline-the-little-big-primitive/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>La Fabrick goes 3.0</title>
		<link>http://www.lafabrick.com/blog/en/2010/07/18/1969-la-fabrick-goes-3-0/</link>
		<comments>http://www.lafabrick.com/blog/en/2010/07/18/1969-la-fabrick-goes-3-0/#comments</comments>
		<pubDate>Sun, 18 Jul 2010 21:52:00 +0000</pubDate>
		<dc:creator>Hervé</dc:creator>
				<category><![CDATA[La Fabrick @en]]></category>
		<category><![CDATA[Lafabrick @en]]></category>

		<guid isPermaLink="false">http://www.lafabrick.com/blog/?p=1969</guid>
		<description><![CDATA[No web 3.0, just a WordPress upgrade. For those who don&#8217;t speak french, and try to follow us, you&#8217;ll be glad to know that you&#8217;ve got now a dedicated english version of the blog! We hope you&#8217;ll enjoy and understand our &#171;&#160;frenglish&#160;&#187; and keep us posted with your comments. Let&#8217;s rock n&#8217; roll&#8230; Autres articles [...]]]></description>
			<content:encoded><![CDATA[<p>No web 3.0, just a WordPress upgrade. For those who don&#8217;t speak french, and try to follow us, you&#8217;ll be glad to know that you&#8217;ve got now a dedicated english version of the blog! </p>
<p>We hope you&#8217;ll enjoy and understand our &laquo;&nbsp;frenglish&nbsp;&raquo; and keep us posted with your comments.</p>
<p>Let&#8217;s rock n&#8217; roll&#8230;<br />
Autres articles sur le même sujet
<ul>
<li><a href="http://www.lafabrick.com/blog/2006/10/09/4-la-fabrick-ou-quand-fabien-rencontre-erick/" rel="bookmark" title="9 octobre 2006">La Fabrick &#8230; ou quand Fabien rencontre Erick</a></li>
<li><a href="http://www.lafabrick.com/blog/2007/10/01/240-labsadobecom-c-est-nol-avant-l-heure/" rel="bookmark" title="1 octobre 2007">Noël avant l&#8217;heure : la journée de la béta 2 sur Labs.adobe.com</a></li>
<li><a href="http://www.lafabrick.com/blog/2008/07/09/311-lively-la-vie-virtuelle-de-google/" rel="bookmark" title="9 juillet 2008">Lively : la vie virtuelle de Google</a></li>
<li><a href="http://www.lafabrick.com/blog/2010/07/18/1966-la-fabrick-passe-la-troisieme/" rel="bookmark" title="18 juillet 2010">La Fabrick passe la troisième&#8230;</a></li>
</ul>
<p><!-- Similar Posts took 11.851 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.lafabrick.com/blog/en/2010/07/18/1969-la-fabrick-goes-3-0/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Flex 4 layouts – Writing a « pure » Spark ViewStack</title>
		<link>http://www.lafabrick.com/blog/en/2010/07/18/1953-flex-4-layouts-writing-a-pure-spark-viewstack/</link>
		<comments>http://www.lafabrick.com/blog/en/2010/07/18/1953-flex-4-layouts-writing-a-pure-spark-viewstack/#comments</comments>
		<pubDate>Sun, 18 Jul 2010 21:21:18 +0000</pubDate>
		<dc:creator>Hervé</dc:creator>
				<category><![CDATA[[Dev] Flash / Flex / AIR... @en]]></category>
		<category><![CDATA[flex4 @en]]></category>
		<category><![CDATA[layout @en]]></category>
		<category><![CDATA[MVC @en]]></category>
		<category><![CDATA[Spark @en]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.lafabrick.com/blog/?p=1953</guid>
		<description><![CDATA[For those who were lucky enough to switch to Flex 4 and Spark, you may have the same habit as mine which is to avoid the &#60;mx:&#62; in your skins&#8230; Spark, my true and only love&#8230; Nevertheless, some components were not rewritten for Spark. Why? Because Spark architecture uses a very nice feature: layouts. And [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.lafabrick.com/blog/wp-content/uploads/2010/07/layouts-300x155.png" alt="layouts" title="layouts" width="300" height="155" class="aligncenter size-medium wp-image-1930" /><br />
For those who were lucky enough to switch to Flex 4 and Spark, you may have the same habit as mine which is to avoid the <strong>&lt;mx:&gt;</strong> in your skins&#8230; Spark, my true and only love&#8230; Nevertheless, some components were not rewritten for Spark. Why? Because Spark architecture uses a very nice feature: layouts. And layouts are sooooooooo nice!</p>
<p>Let see&#8230;<br />
<span id="more-1953"></span></p>
<h2>Layouts</h2>
<p>Without writing a complete post on spark layouts (which would be possible and interesting for sure), I will remind that Flex 4 distinguishes itself from Flex 3 with Spark by enabling a better separation between business logic and representation. Spark comes with this layout feature to, as its name suggests, organize and lay out children of a container (a <strong>&lt;s:Group&gt;</strong> for example).<br />
Say goodbye then to the <em>VBox</em> or <em>HBox</em> (event if VGroup and HGroup are here to ensure a smooth transition), and say welcome to the <strong>Group</strong> with its layout attribute:</p>
<pre class="brush: xml">
&lt;mx:VBox&gt;
&lt;/mx:VBox&gt;
</pre>
<p>becomes</p>
<pre class="brush: xml">
&lt;s:Group&gt;
	&lt;s:layout&gt;
		&lt;s:VerticalLayout /&gt;
	&lt;/s:layout&gt;
&lt;/s:Group&gt;
</pre>
<p>At first, we could say: that&#8217;s more verbose! Yes but&#8230; Spark layout has this particularity, as a component&#8217;s property, to be updatable at runtime, which is not the cas when you consider a component whose name implies how its children will be displayed and organized. In short, a <em>VBox</em> will always lay out its children vertically (that&#8217;s its name!), while the <em>Group</em> will be able to change its layout very easily, switching from <em>HorizontalLayout</em> to <em>VerticalLayout</em> for example&#8230; We can better understand this even better by imagining to write a custom layout to do crazier and fancier stuff!</p>
<h2>Create a layout</h2>
<p>In order to create a layout, you must extend the LayoutBase class and override at least the updateDisplayList() and most of the time the measure() method also. These methods aim at the same objective as in Flex 3, but adapted to the layout context:</p>
<ul>
<li>updateDisplayList : takes care of laying out the container&#8217;s children and define their size</li>
<li>measure : gives the global size to the container</li>
</ul>
<p>You can access the &laquo;&nbsp;target&nbsp;&raquo; property which corresponds to the container your layout is applied to, and then work with the container&#8217;s chidren by using the getElementAt() or getVirtualElementAt() methods. The second one is for handling &laquo;&nbsp;virtualized&nbsp;&raquo; layouts.</p>
<h3>Small break: layout virtualization</h3>
<p>Flex 4 enables, for performance reasons, to use a layout in &laquo;&nbsp;virtualized&nbsp;&raquo; mode, i.e. only calculating organization of children which must be actually displayed instead of calculating all children layout properties. This mode is very well suited for components with lots of children, but showing only a few at a time. The display will thus be reprocessed whenever the user will scroll (or equivalent).</p>
<h2>Practice: create a ViewStackLayout</h2>
<p>Now we have layouts in mind, it is useless to ask why the ViewStack component hasn&#8217;t been written for Spark: it must be a layout! Event if this <a href="http://opensource.adobe.com/wiki/display/flexsdk/Spark+Virtualization" lang="en">very good article</a> mentions a promising, quote &laquo;&nbsp;(Planned) StackLayout&nbsp;&raquo;, nothing stops us to write one simple, Spark compliant, instead of waiting (we are impatient at La Fabrick).</p>
<p>Here follows a very simple example:</p>
<pre class="brush: js">
	import mx.core.IVisualElement;
	import spark.layouts.supportClasses.LayoutBase;

	public class ViewStackLayout extends LayoutBase {
		public function ViewStackLayout() {
			super();
		}

		protected var _index:uint;

		public function get index():Number {
			return _index;
		}

		public function set index(value:Number):void {
			if (_index != value &amp;amp;&amp;amp; target != null &amp;amp;&amp;amp; value &gt;= 0 &amp;amp;&amp;amp; value &lt; target.numElements) {
				_index = value;
				target.invalidateSize();
				target.invalidateDisplayList();
			}
		}

		override public function updateDisplayList(width:Number, height:Number):void {
			var element:IVisualElement = useVirtualLayout ? target.getVirtualElementAt(index) : target.getElementAt(index);

			if (element) {
				element.setLayoutBoundsSize(element.getPreferredBoundsWidth(), element.getPreferredBoundsHeight());
				target.setActualSize(element.getPreferredBoundsWidth(), element.getPreferredBoundsHeight());
				target.setContentSize(element.getPreferredBoundsWidth(), element.getPreferredBoundsHeight());
			}
		}

		override public function measure():void {
			var count:int = target.numElements;

			for (var i:uint = 0; i &lt; count; i++) {
				var element:IVisualElement = useVirtualLayout ? target.getVirtualElementAt(i) : target.getElementAt(i);

				if (i == index) {
					element.visible = true;
					element.includeInLayout = true;
					target.measuredWidth = element.getPreferredBoundsWidth();
					target.measuredHeight = element.getPreferredBoundsHeight();
				} else {
					element.visible = false;
					element.includeInLayout = false;
				}
			}
		}
	}
</pre>
<p>You may denote the usage of getVirtualElementAt, for future compatibility with virtualization.<br />
You can now use this layout in a DataGroup bound to a Tabbar like this:</p>
<pre class="brush: xml">
	&lt;s:TabBar id=&quot;tabEditors&quot; /&gt;
	&lt;s:DataGroup id=&quot;editors&quot;&gt;
		&lt;s:layout&gt;
			&lt;mylayouts:ViewStackLayout index=&quot;{tabEditors.selectedIndex}&quot; /&gt;
		&lt;/s:layout&gt;
		&lt;!-- Children... --&gt;
	&lt;/s:DataGroup&gt;
</pre>
<p>This way, if you want to change how those elements are displayed in the future, you will only have to change the layout property and use a CoverFlow layout, TimeMachine layout, or whatever you like without changing you component&#8217;s code, but only the skin.</p>
<p>Aren&#8217;t we fine dressed in Spark?Autres articles sur le même sujet
<ul>
<li><a href="http://www.lafabrick.com/blog/2009/01/13/786-reflex-1-une-micro-architecture-pour-flex-simple/" rel="bookmark" title="13 janvier 2009">Reflex #1: une micro-architecture pour Flex&#8230; simple !</a></li>
<li><a href="http://www.lafabrick.com/blog/2009/01/15/819-reflex-2-vous-reprendez-bien-un-peu-de-ioc/" rel="bookmark" title="15 janvier 2009">Reflex #2 : vous reprendrez bien un peu de IOC ?</a></li>
<li><a href="http://www.lafabrick.com/blog/2010/07/14/1920-flex-4-layouts-viewstack-pure-spark/" rel="bookmark" title="14 juillet 2010">Flex 4 et les layouts &#8211; Faire une ViewStack &laquo;&nbsp;pure&nbsp;&raquo; Spark</a></li>
<li><a href="http://www.lafabrick.com/blog/2010/05/04/1962-uigfx-practice-a-circularslider-component-2/" rel="bookmark" title="4 mai 2010">UIGFX practice : a CircularSlider component</a></li>
</ul>
<p><!-- Similar Posts took 12.745 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.lafabrick.com/blog/en/2010/07/18/1953-flex-4-layouts-writing-a-pure-spark-viewstack/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>UIGFX practice : a CircularSlider component</title>
		<link>http://www.lafabrick.com/blog/en/2010/05/04/1849-uigfx-practice-a-circularslider-component/</link>
		<comments>http://www.lafabrick.com/blog/en/2010/05/04/1849-uigfx-practice-a-circularslider-component/#comments</comments>
		<pubDate>Tue, 04 May 2010 21:18:32 +0000</pubDate>
		<dc:creator>Fabien</dc:creator>
				<category><![CDATA[[Dev] Flash / Flex / AIR... @en]]></category>
		<category><![CDATA[component @en]]></category>
		<category><![CDATA[FlashBuilder @en]]></category>
		<category><![CDATA[flex4 @en]]></category>
		<category><![CDATA[primitives @en]]></category>
		<category><![CDATA[Spark @en]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[uigfx @en]]></category>

		<guid isPermaLink="false">http://www.lafabrick.com/blog/?p=1849</guid>
		<description><![CDATA[If you were luck enough to use a multitouch application, did you ever have the idea that it would be interesting to use some circular interface components? As interface space management is easier to achieve on large multitouch tables, I had the idea to develop a CircularSlider component, using my primitive UIGFX library, including the [...]]]></description>
			<content:encoded><![CDATA[<p>If you were luck enough to use a multitouch application, did you ever have the idea that it would be interesting to use some circular interface components?<br />
As interface space management is easier to achieve on large multitouch tables, I had the idea to develop a CircularSlider component, using my primitive <a href="http://code.google.com/p/uigfx/">UIGFX library</a>, including the <a href="http://code.google.com/p/uigfx/source/browse/trunk/uigfx/src/com/lafabrick/uigfx/primitives/Pie.as">Pie primitive</a>.<br />
Let see how it works&#8230;<br />
<span id="more-1849"></span><br />
<H2>The component</H2></p>
<h3>PieButton</h3>
<p>I needed a button with 2 properties <code>startAngle</code> and <code>angle</code>, to be able to transmit these values to the skin: </p>
<pre class="brush: js">
package com.lafabrick.components
{
    import spark.components.Button;

    public class PieButton extends Button
    {
        public function PieButton()
        {
            super();
        }

        private var _angle : Number;
        private var _startAngle : Number;

        public function get angle():Number
        {
            return _angle;
        }
        [Bindable]public function set angle(value:Number):void
        {
            _angle = value;
            invalidateDisplayList();
        }

        public function get startAngle():Number
        {
            return _startAngle;
        }
        [Bindable]public function set startAngle(value:Number):void
        {
            _startAngle = value;
            invalidateDisplayList();
        }

    }
}
</pre>
<h3>CircularSlider</h3>
<p>This component could not extend directly SliderBase or TrackBase because the SkinPart thumb and track, as Button, are extending the TrackBase class.<br />
I thus used the Range class, inserted the Slider architecture, and added specific geometric codes.<br />
<a href="http://fabien.lafabrick.com/labs/components/circularslider/srcview/source/fxComponentKit/src/com/lafabrick/components/CircularSlider.as.html">Check the component&#8217;s source code</a></p>
<h2>Skin implementation</h2>
<p>The design of the Skin is similar to a skin Slider standard, except that it uses a PieButton instead of a Button: </p>
<pre class="brush: xml">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;s:SparkSkin xmlns:fx=&quot;http://ns.adobe.com/mxml/2009&quot;
        xmlns:s=&quot;library://ns.adobe.com/flex/spark&quot;
        xmlns:mx=&quot;library://ns.adobe.com/flex/mx&quot;
        width=&quot;100%&quot; height=&quot;100%&quot;
        xmlns:components=&quot;com.lafabrick.components.*&quot;
        &gt;
    &lt;!-- host component --&gt;
    &lt;fx:Metadata&gt;
        [HostComponent(&quot;com.lafabrick.components.CircularSlider&quot;)]
    &lt;/fx:Metadata&gt;

    &lt;!-- states --&gt;
    &lt;s:states&gt;
        &lt;s:State name=&quot;normal&quot; /&gt;
        &lt;s:State name=&quot;disabled&quot; /&gt;
        &lt;s:State name=&quot;inactive&quot; /&gt;
    &lt;/s:states&gt;

    &lt;!-- SkinParts
    name=track, type=com.lafabrick.uigfx.components.CircularButton
    name=thumb, type=com.lafabrick.uigfx.components.CircularButton
    --&gt;

    &lt;components:PieButton
        id=&quot;track&quot;
        width=&quot;100%&quot; height=&quot;100%&quot;
        top=&quot;0&quot; bottom=&quot;0&quot; left=&quot;0&quot; right=&quot;0&quot;
        skinClass=&quot;skins.CircularTrackButtonSkin&quot;/&gt;

    &lt;components:PieButton
        id=&quot;thumb&quot;
        angle=&quot;20&quot;
        width=&quot;100%&quot; height=&quot;100%&quot;
        top=&quot;0&quot; bottom=&quot;0&quot; left=&quot;0&quot; right=&quot;0&quot;
        skinClass=&quot;skins.CircularThumbButtonSkin&quot;/&gt;

&lt;/s:SparkSkin&gt;
</pre>
<p>Under &laquo;&nbsp;thumb&nbsp;&raquo; and &laquo;&nbsp;track&nbsp;&raquo; Skin, the angular values are a mapped with the PieButton HostComponent. StartAngle and angle properties of the Pie primitive are directly extended from the host component.<br />
Here follows a sample with Track Skin:</p>
<pre class="brush: xml">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;s:SparkSkin xmlns:fx=&quot;http://ns.adobe.com/mxml/2009&quot;
             xmlns:s=&quot;library://ns.adobe.com/flex/spark&quot; 

             minWidth=&quot;21&quot; minHeight=&quot;21&quot;
             alpha.disabled=&quot;0.5&quot;
             xmlns:uigfx=&quot;http://uigfx.lafabrick.com&quot;
             xmlns:primitives=&quot;com.lafabrick.uigfx.primitives.*&quot;&gt;

    &lt;fx:Metadata&gt;
        [HostComponent(&quot;com.lafabrick.components.PieButton&quot;)]
    &lt;/fx:Metadata&gt;

    &lt;s:states&gt;
        &lt;s:State name=&quot;up&quot; /&gt;
        &lt;s:State name=&quot;over&quot; /&gt;
        &lt;s:State name=&quot;down&quot; /&gt;
        &lt;s:State name=&quot;disabled&quot; /&gt;
    &lt;/s:states&gt;

    &lt;primitives:Pie
        top=&quot;0&quot; bottom=&quot;0&quot; left=&quot;0&quot; right=&quot;0&quot;
        gap=&quot;2&quot;
        innerOffset=&quot;-2&quot;
        offset=&quot;-2&quot;

        innerRadius=&quot;0.7&quot;
        angle=&quot;{hostComponent.angle}&quot;
        startAngle=&quot;{hostComponent.startAngle}&quot;
        &gt;

        &lt;primitives:fill&gt;
            &lt;s:RadialGradient&gt;
                &lt;s:GradientEntry color=&quot;#006699&quot; /&gt;
                &lt;s:GradientEntry color=&quot;#009EE0&quot; /&gt;
            &lt;/s:RadialGradient&gt;
        &lt;/primitives:fill&gt;

        &lt;primitives:filters&gt;
            &lt;s:GlowFilter inner=&quot;true&quot; color=&quot;#000000&quot;
                blurX=&quot;10&quot; blurY=&quot;10&quot; alpha=&quot;0.4&quot; /&gt;
        &lt;/primitives:filters&gt;

    &lt;/primitives:Pie&gt;

&lt;/s:SparkSkin&gt;
</pre>
<p><H2>Result</H2><br />
Let see:<br />
<object type="application/x-shockwave-flash" data="http://fabien.lafabrick.com/labs/components/circularslider/circularSlider.swf" width="640" height="500"><param name="movie" value="http://fabien.lafabrick.com/labs/components/circularslider/circularSlider.swf" /><param name="bgcolor" value="#ffffff" /><param name="allowScriptAccess" value="sameDomain" /><param name="allowFullScreen" value="true" /></object><br />
Nice huh?</p>
<p>You can check these for more info: <a href="http://fabien.lafabrick.com/labs/components/circularslider/">Link</a>, and <a href="http://fabien.lafabrick.com/labs/components/circularslider/srcview/index.html">source code</a>.</p>
<p>PS: Thanks to Hervé for review and corrections!Autres articles sur le même sujet
<ul>
<li><a href="http://www.lafabrick.com/blog/2009/11/27/1373-flex4-custom-component-skinnig/" rel="bookmark" title="27 novembre 2009">Flex4 : composant personnalisé et skinning</a></li>
<li><a href="http://www.lafabrick.com/blog/2010/04/06/1754-arduino-2-flash-socket-et-processing/" rel="bookmark" title="6 avril 2010">Arduino #2 : Flash, socket et Processing</a></li>
<li><a href="http://www.lafabrick.com/blog/2010/02/09/1964-uigfx-project-flex4-primitives-library-fireworks-extension/" rel="bookmark" title="9 février 2010">uigfx project : Flex4 primitives library / Fireworks extension</a></li>
<li><a href="http://www.lafabrick.com/blog/2010/05/04/1962-uigfx-practice-a-circularslider-component-2/" rel="bookmark" title="4 mai 2010">UIGFX practice : a CircularSlider component</a></li>
</ul>
<p><!-- Similar Posts took 18.177 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.lafabrick.com/blog/en/2010/05/04/1849-uigfx-practice-a-circularslider-component/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>uigfx project: Flex4 primitives library / Fireworks extension</title>
		<link>http://www.lafabrick.com/blog/en/2010/02/09/2157-uigfx-project-flex4-primitives-library-fireworks-extension-2/</link>
		<comments>http://www.lafabrick.com/blog/en/2010/02/09/2157-uigfx-project-flex4-primitives-library-fireworks-extension-2/#comments</comments>
		<pubDate>Tue, 09 Feb 2010 10:40:22 +0000</pubDate>
		<dc:creator>Fabien</dc:creator>
				<category><![CDATA[Our projects]]></category>
		<category><![CDATA[[Dev] Flash / Flex / AIR... @en]]></category>
		<category><![CDATA[flex4 @en]]></category>
		<category><![CDATA[graphics]]></category>
		<category><![CDATA[library @en]]></category>
		<category><![CDATA[primitives @en]]></category>
		<category><![CDATA[Spark @en]]></category>
		<category><![CDATA[uigfx]]></category>
		<category><![CDATA[zxp @en]]></category>

		<guid isPermaLink="false">http://www.lafabrick.com/blog/?p=2157</guid>
		<description><![CDATA[I just released a new project, called by Erick uigfx, that I have introduced in my previous post (in french). So : it&#8217;s a Flex4 primitives&#8217;s library, which allows you to extend standard graphics primitives. It&#8217;s also one (and more soon) Fireworks extension to accelerate and improve the workflow between designer and developer. The existence [...]]]></description>
			<content:encoded><![CDATA[<p>I just released a<a href="http://code.google.com/p/uigfx/"> new project</a>, called by <a href="http://twitter.com/rick_lafabrick">Erick</a> <b>uigfx</b>, that I have introduced in my previous post (in french).<br />
So : it&#8217;s a Flex4 primitives&#8217;s library, which allows you to extend standard graphics primitives. It&#8217;s also one (and more soon) Fireworks extension to accelerate and improve the workflow between designer and developer.<br />
The existence of this library have just this idea: improve the work processes between teams around a Flex4 project.<br />
<span id="more-2157"></span></p>
<h2>uigfx library</h2>
<h3>ExclusionRect</h3>
<p>Draw a rectangle with rounded corners (&laquo;&nbsp;radius&nbsp;&raquo; property), with a rounded rectangular punch optional.<br />
The roundness of the inner rectangle is defined by &laquo;&nbsp;innerRadius&nbsp;&raquo; property.<br />
Constraints of the inner rectangle are defined with &laquo;&nbsp;innerTop&nbsp;&raquo;, &laquo;&nbsp;innerBottom, &laquo;&nbsp;innerLeft&nbsp;&raquo; and &laquo;&nbsp;innerRight&nbsp;&raquo; properties.<br />
Sample :</p>
<pre class="brush: xml">
&lt;uigfx:ExclusionRect
    radius=&quot;10&quot;
    innerRadius=&quot;30&quot;
    top=&quot;0&quot; left=&quot;0&quot; right=&quot;0&quot; bottom=&quot;0&quot;
    innerTop=&quot;0&quot; innerBottom=&quot;20&quot; innerLeft=&quot;0&quot; innerRight=&quot;20&quot;&gt;

    &lt;uigfx:fill&gt;
        &lt;s:LinearGradient rotation=&quot;90&quot;&gt;
            &lt;s:GradientEntry color=&quot;#212121&quot; ratio=&quot;0&quot; /&gt;
            &lt;s:GradientEntry color=&quot;#313131&quot; ratio=&quot;1&quot;/&gt;
        &lt;/s:LinearGradient&gt;
    &lt;/uigfx:fill&gt;

    &lt;uigfx:filters&gt;
        &lt;s:DropShadowFilter color=&quot;#000000&quot; inner=&quot;true&quot;
            distance=&quot;1&quot; blurX=&quot;4&quot; blurY=&quot;4&quot;
            quality=&quot;3&quot; alpha=&quot;0.8&quot; /&gt;
    &lt;/uigfx:filters&gt;

&lt;/uigfx:ExclusionRect&gt;
</pre>
<p>Result :<br />
<center><img alt="excluded rectangle" src="http://www.lafabrick.com/blog/wp-content/uploads/2009/12/excludedrect.png" title="excludedRect" class="aligncenter" width="239" height="238" /></center></p>
<h3>PointsPath</h3>
<p>This primitive allows you to draw a path, based on a list of points(ConstraintPoint). <br />Additionally, you can set a roundness to your primitive using the &laquo;&nbsp;radius&nbsp;&raquo; property</p>
<p>A PointsPath can be defined as &laquo;&nbsp;not closed&nbsp;&raquo; : in this case you can use the &laquo;&nbsp;closedPath&nbsp;&raquo; property and set it to false :</p>
<pre class="brush: xml">
&lt;uigfx:PointsPath radius=&quot;60&quot; closedPath=&quot;false&quot;&gt;
   ...
&lt;/uigfx:PointsPath&gt;
</pre>
<h4>Using constraint point</h4>
<p>The ConstraintPoint class defines a point with constraints values (left, horizontalCenter, right; and top, verticalCenter, bottom) </p>
<pre class="brush: xml">
&lt;uigfx:ConstraintPoint top=&quot;0&quot; horizontalCenter=&quot;0&quot; /&gt;
</pre>
<p>Every single value can be expressed as a percentage, setting &laquo;&nbsp;valuesInPercent&nbsp;&raquo; property to &laquo;&nbsp;true&nbsp;&raquo; (by default, all values are expressed in pixel) :</p>
<pre class="brush: xml">
&lt;uigfx:ConstraintPoint valuesInPercent=&quot;true&quot; top=&quot;10&quot; horizontalCenter=&quot;-25&quot; /&gt;
</pre>
<h4>Sample</h4>
<p>Draw a five branch star, with a rounded contour (&laquo;&nbsp;radius&nbsp;&raquo; property), and constraints points vector :</p>
<pre class="brush: xml">
&lt;uigfx:PointsPath
    radius=&quot;60&quot; width=&quot;100%&quot; height=&quot;100%&quot;
    horizontalCenter=&quot;0&quot; verticalCenter=&quot;0&quot;&gt;

    &lt;uigfx:points&gt;
        &lt;uigfx:ConstraintPoint top=&quot;0&quot; horizontalCenter=&quot;0&quot; /&gt;
        &lt;uigfx:ConstraintPoint horizontalCenter=&quot;25&quot; verticalCenter=&quot;-25&quot;/&gt;
        &lt;uigfx:ConstraintPoint right=&quot;0&quot; verticalCenter=&quot;-25&quot; /&gt;
        &lt;uigfx:ConstraintPoint horizontalCenter=&quot;40&quot; verticalCenter=&quot;25&quot; /&gt;
        &lt;uigfx:ConstraintPoint right=&quot;40&quot; bottom=&quot;0&quot; /&gt;
        &lt;uigfx:ConstraintPoint horizontalCenter=&quot;0&quot; verticalCenter=&quot;40&quot; /&gt;
        &lt;uigfx:ConstraintPoint left=&quot;40&quot; bottom=&quot;0&quot; /&gt;
        &lt;uigfx:ConstraintPoint horizontalCenter=&quot;-40&quot; verticalCenter=&quot;25&quot; /&gt;
        &lt;uigfx:ConstraintPoint left=&quot;0&quot; verticalCenter=&quot;-25&quot; /&gt;
        &lt;uigfx:ConstraintPoint horizontalCenter=&quot;-25&quot; verticalCenter=&quot;-25&quot; /&gt;
    &lt;/uigfx:points&gt;

    &lt;uigfx:fill&gt;
        &lt;s:SolidColor color=&quot;#353535&quot; /&gt;
    &lt;/uigfx:fill&gt;

    &lt;uigfx:filters&gt;
        &lt;s:DropShadowFilter color=&quot;#000000&quot; inner=&quot;true&quot; distance=&quot;1&quot;
            blurX=&quot;4&quot; blurY=&quot;4&quot;
            quality=&quot;3&quot; alpha=&quot;0.8&quot; /&gt;
    &lt;/uigfx:filters&gt;

&lt;/uigfx:PointsPath&gt;
</pre>
<p>Result :<br />
<center><img src="http://www.lafabrick.com/blog/wp-content/uploads/2010/02/fivestar.png" alt="fivestar" title="fivestar" width="291" height="324" class="aligncenter size-full wp-image-1557" /></center></p>
<h3>ComplexPointsPath</h3>
<p>This primitive allows you to draw a path with one or more contours, defined by ComplexConstraintPoint points. </p>
<h4>Define a complex point</h4>
<p>The ComplexConstraintPoint class defines a vector with a constraint position, and the position of its bezier curves list.<br />
<center><img src="http://www.lafabrick.com/blog/wp-content/uploads/2010/02/vectoranchor.png" alt="vectoranchor" title="vectoranchor" width="291" height="191" class="aligncenter size-full wp-image-1553" /></center><br />
The position of bezier curves is defined by vertical and horizontal offsets as below :<br />
<center><img src="http://www.lafabrick.com/blog/wp-content/uploads/2010/02/vectoranchoroffset.png" alt="vectoranchoroffset" title="vectoranchoroffset" width="229" height="263" class="aligncenter size-full wp-image-1554" /></center><br />
In mxml : </p>
<pre class="brush: xml">
&lt;uigfx:ComplexConstraintPoint
    horizontalCenter=&quot;-48&quot; verticalCenter=&quot;-59&quot;
    nextAnchorOffsetX=&quot;-2&quot; nextAnchorOffsetY=&quot;4&quot;
    prevAnchorOffsetX=&quot;7&quot; prevAnchorOffsetY=&quot;-6&quot; /&gt;
</pre>
<p>Just like the ConstraintPoint, all values can be expressed in percentage :</p>
<pre class="brush: xml">
&lt;uigfx:ComplexConstraintPoint
    valuesInPercent=&quot;true&quot;
    top=&quot;10&quot; horizontalCenter=&quot;-25&quot;
    nextAnchorOffsetX=&quot;-2&quot; nextAnchorOffsetY=&quot;4&quot;
    prevAnchorOffsetX=&quot;7&quot; prevAnchorOffsetY=&quot;-6&quot; /&gt;
</pre>
<h4>Single contour</h4>
<p>Draw a path with a complex contour :</p>
<pre class="brush: xml">
&lt;uigfx:ComplexPointsPath top=&quot;0&quot; bottom=&quot;0&quot; left=&quot;0&quot; right=&quot;0&quot; &gt;
    &lt;uigfx:points&gt;
        &lt;uigfx:ComplexConstraintPoint left=&quot;0&quot; prevAnchorOffsetX=&quot;4.59&quot; top=&quot;36&quot; prevAnchorOffsetY=&quot;5.36&quot; /&gt;
        &lt;uigfx:ComplexConstraintPoint left=&quot;0&quot; bottom=&quot;0&quot; /&gt;
        &lt;uigfx:ComplexConstraintPoint horizontalCenter=&quot;-35&quot; bottom=&quot;0&quot; /&gt;
        &lt;uigfx:ComplexConstraintPoint horizontalCenter=&quot;-23&quot; bottom=&quot;18&quot; /&gt;
        &lt;uigfx:ComplexConstraintPoint horizontalCenter=&quot;3&quot; bottom=&quot;2&quot; /&gt;
        &lt;uigfx:ComplexConstraintPoint horizontalCenter=&quot;2&quot; bottom=&quot;0&quot; /&gt;
        &lt;uigfx:ComplexConstraintPoint right=&quot;0&quot; bottom=&quot;0&quot; /&gt;
        &lt;uigfx:ComplexConstraintPoint right=&quot;0&quot; top=&quot;0&quot; /&gt;
        &lt;uigfx:ComplexConstraintPoint left=&quot;34&quot; nextAnchorOffsetX=&quot;6.07&quot; top=&quot;0&quot; nextAnchorOffsetY=&quot;4.56&quot; /&gt;
        &lt;uigfx:ComplexConstraintPoint left=&quot;44&quot; top=&quot;20&quot; nextAnchorOffsetY=&quot;13.81&quot; prevAnchorOffsetY=&quot;-8.18&quot; /&gt;
        &lt;uigfx:ComplexConstraintPoint left=&quot;19&quot; nextAnchorOffsetX=&quot;-7.6&quot; prevAnchorOffsetX=&quot;13.81&quot; top=&quot;45&quot; /&gt;
    &lt;/uigfx:points&gt;

    &lt;uigfx:stroke&gt;
        &lt;s:SolidColorStroke color=&quot;#ffffff&quot; weight=&quot;1&quot; /&gt;
    &lt;/uigfx:stroke&gt;

    &lt;uigfx:fill&gt;
        &lt;s:LinearGradient rotation=&quot;90&quot;&gt;
            &lt;s:GradientEntry color=&quot;#333333&quot; ratio=&quot;0&quot; alpha=&quot;1&quot;/&gt;
            &lt;s:GradientEntry color=&quot;#212121&quot; ratio=&quot;1&quot; alpha=&quot;1&quot;/&gt;
        &lt;/s:LinearGradient&gt;
    &lt;/uigfx:fill&gt;

    &lt;uigfx:filters&gt;
        &lt;s:GlowFilter color=&quot;#000000&quot; blurX=&quot;12&quot; blurY=&quot;12&quot; alpha=&quot;0.65&quot;/&gt;
    &lt;/uigfx:filters&gt;
&lt;/uigfx:ComplexPointsPath&gt;
</pre>
<p>result :<br />
<center><img src="http://www.lafabrick.com/blog/wp-content/uploads/2010/02/complexpath.png" alt="complexpath" title="complexpath" width="316" height="115" class="aligncenter size-full wp-image-1556" /></center></p>
<h4>Multiples contours</h4>
<p>Draw a path with multiples contours.<br />
Each Contour object defines a part of the path. Basically, it&#8217;s used to process pathfinding, such as union or exclusion.<br />
Each contour is defined on a Contour object, through the &laquo;&nbsp;contours&nbsp;&raquo; collection property. Like PointsPath, a Contour can be defined as unclosed, using &laquo;&nbsp;closedContour&nbsp;&raquo; property :</p>
<pre class="brush: xml">
&lt;uigfx:ComplexPointsPath top=&quot;0&quot; bottom=&quot;0&quot; left=&quot;0&quot; right=&quot;0&quot; &gt;
    &lt;uigfx:contours&gt;
        &lt;uigfx:Contour closedContour=&quot;false&quot;&gt;
            &lt;uigfx:points&gt;
            ...
</pre>
<p>Below a complete sample code : </p>
<pre class="brush: xml">
&lt;uigfx:ComplexPointsPath top=&quot;0&quot; bottom=&quot;0&quot; left=&quot;0&quot; right=&quot;0&quot; &gt;
    &lt;uigfx:contours&gt;
        &lt;uigfx:Contour&gt;
            &lt;uigfx:points&gt;
                &lt;uigfx:ComplexConstraintPoint left=&quot;0&quot; prevAnchorOffsetX=&quot;4.59&quot; top=&quot;36&quot; prevAnchorOffsetY=&quot;5.36&quot; /&gt;
                &lt;uigfx:ComplexConstraintPoint left=&quot;0&quot; bottom=&quot;0&quot; /&gt;
                &lt;uigfx:ComplexConstraintPoint horizontalCenter=&quot;-35&quot; bottom=&quot;0&quot; /&gt;
                &lt;uigfx:ComplexConstraintPoint horizontalCenter=&quot;-23&quot; bottom=&quot;18&quot; /&gt;
                &lt;uigfx:ComplexConstraintPoint horizontalCenter=&quot;3&quot; bottom=&quot;2&quot; /&gt;
                &lt;uigfx:ComplexConstraintPoint horizontalCenter=&quot;2&quot; bottom=&quot;0&quot; /&gt;
                &lt;uigfx:ComplexConstraintPoint right=&quot;0&quot; bottom=&quot;0&quot; /&gt;
                &lt;uigfx:ComplexConstraintPoint right=&quot;0&quot; top=&quot;0&quot; /&gt;
                &lt;uigfx:ComplexConstraintPoint left=&quot;34&quot; nextAnchorOffsetX=&quot;6.07&quot; top=&quot;0&quot; nextAnchorOffsetY=&quot;4.56&quot; /&gt;
                &lt;uigfx:ComplexConstraintPoint left=&quot;44&quot; top=&quot;20&quot; nextAnchorOffsetY=&quot;13.81&quot; prevAnchorOffsetY=&quot;-8.18&quot; /&gt;
                &lt;uigfx:ComplexConstraintPoint left=&quot;19&quot; nextAnchorOffsetX=&quot;-7.6&quot; prevAnchorOffsetX=&quot;13.81&quot; top=&quot;45&quot; /&gt;
            &lt;/uigfx:points&gt;
        &lt;/uigfx:Contour&gt;
        &lt;uigfx:Contour&gt;
            &lt;uigfx:points&gt;
                &lt;uigfx:ComplexConstraintPoint right=&quot;96&quot; top=&quot;18&quot; /&gt;
                &lt;uigfx:ComplexConstraintPoint right=&quot;68&quot; top=&quot;9&quot; /&gt;
                &lt;uigfx:ComplexConstraintPoint right=&quot;59&quot; top=&quot;37&quot; /&gt;
                &lt;uigfx:ComplexConstraintPoint right=&quot;87&quot; top=&quot;46&quot; /&gt;
            &lt;/uigfx:points&gt;
        &lt;/uigfx:Contour&gt;
        &lt;uigfx:Contour&gt;
            &lt;uigfx:points&gt;
                &lt;uigfx:ComplexConstraintPoint right=&quot;49&quot; bottom=&quot;28&quot; nextAnchorOffsetY=&quot;-11.87&quot; prevAnchorOffsetY=&quot;11.87&quot; /&gt;
                &lt;uigfx:ComplexConstraintPoint right=&quot;28&quot; nextAnchorOffsetX=&quot;11.87&quot; prevAnchorOffsetX=&quot;-11.87&quot; bottom=&quot;49&quot; /&gt;
                &lt;uigfx:ComplexConstraintPoint right=&quot;6&quot; bottom=&quot;28&quot; nextAnchorOffsetY=&quot;11.87&quot; prevAnchorOffsetY=&quot;-11.87&quot; /&gt;
                &lt;uigfx:ComplexConstraintPoint right=&quot;28&quot; nextAnchorOffsetX=&quot;-11.87&quot; prevAnchorOffsetX=&quot;11.87&quot; bottom=&quot;6&quot; /&gt;
            &lt;/uigfx:points&gt;
        &lt;/uigfx:Contour&gt;
    &lt;/uigfx:contours&gt;

    &lt;uigfx:stroke&gt;
        &lt;s:SolidColorStroke color=&quot;#ffffff&quot; weight=&quot;2&quot; /&gt;
    &lt;/uigfx:stroke&gt;

    &lt;uigfx:fill&gt;
        &lt;s:LinearGradient rotation=&quot;90&quot;&gt;
            &lt;s:GradientEntry color=&quot;#333333&quot; ratio=&quot;0&quot; alpha=&quot;1&quot;/&gt;
            &lt;s:GradientEntry color=&quot;#212121&quot; ratio=&quot;1&quot; alpha=&quot;1&quot;/&gt;
        &lt;/s:LinearGradient&gt;
    &lt;/uigfx:fill&gt;

    &lt;uigfx:filters&gt;
       &lt;s:GlowFilter color=&quot;#000000&quot; blurX=&quot;12&quot; blurY=&quot;12&quot; alpha=&quot;0.65&quot;/&gt;
    &lt;/uigfx:filters&gt;
&lt;/uigfx:ComplexPointsPath&gt;
</pre>
<p>Result :<br />
<center><img src="http://www.lafabrick.com/blog/wp-content/uploads/2010/02/complexpathmultiples.png" alt="complexpathmultiples" title="complexpathmultiples" width="309" height="222" class="aligncenter size-full wp-image-1555" /></center></p>
<h2>An Extension for Fireworks</h2>
<p>This library would not be complete without an export tools for Fireworks. Have a complex primitive is good, but how to find all the points and bezier curves without a headache? It&#8217;s the goal of this extension!</p>
<p>At this moment the exporter is able to : </p>
<ul>
<li>exports all paths and rectangles</li>
<li>exports strokes</li>
<li>exports fills (solid color and gradient)</li>
<li>exports filters (gaussian blur, glow, drop shadow) </li>
</ul>
<p>But for now, this exporter can&#8217;t :</p>
<ul>
<li>exports text </li>
</ul>
<h3>Installation</h3>
<p>Simply <a href="https://code.google.com/p/uigfx/downloads/list">download the extension</a> (uigfx.mxp), and double click on it to launch the Extension Manager. The installation is automatic. Now, open Fireworks, and open the primitives exporter panel in  &laquo;&nbsp;<b>Window > uigfx</b>&laquo;&nbsp;.</p>
<h3>How to use this extension</h3>
<ul>
<li><b>Make your design</b></li>
<li><b>Generate and place rules</b><br />
You&#8217;ill need 4 vertical rules and 4 horizontal rules to determine all constraints positions of each vector point. You can click on the &laquo;&nbsp;generate rules button&nbsp;&raquo;, to put the rules around your selection (you need to select one or more objects). Move the rules, in order to have all vectors in the good area, like below : <br />
<center><img src="http://www.lafabrick.com/blog/wp-content/uploads/2010/02/constraintsposition.jpg" alt="constraintsposition" title="constraintsposition" width="567" height="401" class="aligncenter size-full wp-image-1558" /></center></li>
<li><b>Export</b><br />
Click on the export button to export all selections. The exporter follows rules placement to determine vectors positions. If there&#8217;s no selection, all layers are exported. Of course, you will have to provide a name for the output file and a directory to save it in.<br />
Finally, an mxml file, containing a Spark Skin with all uigfx primitives, will be created. And voila !</li>
</ul>
<p><b>This project is <a href="http://code.google.com/p/uigfx/">hosted on google code</a>.</b>Autres articles sur le même sujet
<ul>
<li><a href="http://www.lafabrick.com/blog/2009/12/04/1453-flex4-skin-et-primitives/" rel="bookmark" title="4 décembre 2009">Flex4 : skin et primitives</a></li>
<li><a href="http://www.lafabrick.com/blog/2010/02/09/1964-uigfx-project-flex4-primitives-library-fireworks-extension/" rel="bookmark" title="9 février 2010">uigfx project : Flex4 primitives library / Fireworks extension</a></li>
<li><a href="http://www.lafabrick.com/blog/2010/05/04/1962-uigfx-practice-a-circularslider-component-2/" rel="bookmark" title="4 mai 2010">UIGFX practice : a CircularSlider component</a></li>
<li><a href="http://www.lafabrick.com/blog/2011/06/23/2598-fireworks-javascript-spark-skin-pleasure/" rel="bookmark" title="23 juin 2011">Fireworks + Javascript = Spark Skin Pleasure !</a></li>
</ul>
<p><!-- Similar Posts took 12.394 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.lafabrick.com/blog/en/2010/02/09/2157-uigfx-project-flex4-primitives-library-fireworks-extension-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hello AFCS ( bye Cocomo ) ! Simple user authentication with Adobe Flash Collaboration Services</title>
		<link>http://www.lafabrick.com/blog/en/2009/01/31/2175-hello-afcs-bye-cocomo-simple-user-authentication-with-adobe-flash-collaboration-services/</link>
		<comments>http://www.lafabrick.com/blog/en/2009/01/31/2175-hello-afcs-bye-cocomo-simple-user-authentication-with-adobe-flash-collaboration-services/#comments</comments>
		<pubDate>Sat, 31 Jan 2009 21:48:35 +0000</pubDate>
		<dc:creator>Hervé</dc:creator>
				<category><![CDATA[[Dev] Flash / Flex / AIR... @en]]></category>
		<category><![CDATA[cocomo @en]]></category>
		<category><![CDATA[collaboration @en]]></category>
		<category><![CDATA[Interactivity]]></category>
		<category><![CDATA[tips @en]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.lafabrick.com/blog/?p=2175</guid>
		<description><![CDATA[[ 05.03.2009 : Update : Cocomo is now called Adobe Flash Collaboration Services / AFCS and 0.9.1 was released with some bug fixes and a new namespace ] (Translated from French tutorial on FlashXPress ) In this first application example, we will build, or rather &#171;&#160;assemble&#160;&#187;, a videoconferencing application including a chat tool, shared notes [...]]]></description>
			<content:encoded><![CDATA[<p>[ 05.03.2009 : Update : Cocomo is now called Adobe Flash Collaboration Services / AFCS and 0.9.1 was released with some bug fixes and a new namespace ]</p>
<p>(Translated from <a href="http://www.flashxpress.net/ressources-flex/hello-cocomo-premiere-application-multi-utilisateurs/">French tutorial on FlashXPress</a> )</p>
<p>In this first application example, we will build, or rather &laquo;&nbsp;assemble&nbsp;&raquo;, a videoconferencing application including <strong>a chat tool, shared notes and a file sharing manager.</strong> For this we&#8217;ll use some &laquo;&nbsp;<strong>pods</strong>&nbsp;&raquo; , the highest level components of the <del datetime="2009-03-06T16:02:18+00:00">Cocomo</del> AFCS framework.</p>
<p>One of the most important component in a <del datetime="2009-03-06T16:02:18+00:00">Cocomo</del> AFCS application is the <strong>session manager</strong>. It will be<strong> in charge of communicating with <del datetime="2009-03-06T16:02:18+00:00">Cocomo</del> AFCS server, user authentication, connection management, data synchronization</strong>, and even more&#8230;</p>
<p>Two components in the framework can do this job: <strong>ConnectSessionContainer</strong> and <strong>ConnectSession</strong> (both implement com.adobe.rtc.session.<strong>IConnectSession</strong>).</p>
<p><img src="http://lafabrick.com/blog/images/erick//cocomo_connection_tut2_sch1-20090201-155223.jpg" alt="Cocomo connection" /></p>
<p><span id="more-2175"></span></p>
<h3>Hello AFCS ( bye Cocomo )</h3>
<p>For starting :</p>
<p>- create a <strong>new Flex project</strong>,<br />
- <strong>copy <del datetime="2009-03-06T16:02:18+00:00">Cocomo</del> AFCS SWC file (from CocomoSDK_0.9/lib/player 9 or 10/afcs.swc) and paste it in your /libs/ folder</strong></p>
<p>Let&#8217;s start with <strong>ConnectSessionContainer</strong> :<br />
It&#8217;s a <strong>Canvas based component</strong>, which includes all features needed to communicate with <del datetime="2009-03-06T16:02:18+00:00">Cocomo</del> AFCS servers.</p>
<p>This container, and all of its children, will not be visible as long as the room connection is not established. This is the reason why we will integrate our pods (Webcamera, SimpleChat, Notes and FileShare) inside it. As long as our application isn&#8217;t connected to our room, collaborative components will remain hidden.</p>
<p>To start a session, we&#8217;ll need to define two attributes in the ConnectSessionContainer tag :</p>
<p>- roomURL( ex : http://connectnow.acrobat.com/yourAccount/roomName)<br />
- authenticator : your user credentials</p>
<p>User credential&#8217;s transmission is done by using the AdobeHSAuthenticator class. It will encapsulate authentication data (userName and password). Several authentication modes are possible, we&#8217;ll probably focus on them in a future tutorial.</p>
<p>In this first step, we will hard-code our credentials in our application&#8230; Only for the first example.</p>
<pre class="brush: xml">

&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;
&lt;mx:Application layout=&quot;absolute&quot;
 xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;
 xmlns:rtc=&quot;AfcsNameSpace&quot;
 &gt;
&lt;rtc:ConnectSessionContainer id=&quot;sessionManager&quot; width=&quot;500&quot; height=&quot;400&quot;
 roomURL=&quot;http://connectnow.acrobat.com/yourAccount/roomName&quot;
 authenticator=&quot;{identificator}&quot;
 backgroundColor=&quot;#FFFFFF&quot;
/&gt;
&lt;rtc:AdobeHSAuthenticator id=&quot;identificator&quot;
 userName=&quot;votreLogin&quot; password=&quot;VotreMotDePasse&quot;
/&gt;
&lt;/mx:Application&gt;
</pre>
<p>In this step, your application can already connect to the server. By default, connectSessionContainer had a autoLogin property set to true. This means that it will try to communicate with the server as soon as it&#8217;s created. In this example, I set a background color for the container, so we can see when connection is established.</p>
<p>If you publish your project in debug mode, you&#8217;ll be able to see server / client communication logs.</p>
<p><img src="http://lafabrick.free.fr/blogImg/Flex_Builder-20081218-065625.jpg" alt="Logs Connexion Serveurs Cocomo" /></p>
<p>To be notified about the login result, we can watch for AuthenticationEvent.AUTHENTICATION_FAILURE and AuthenticationEvent.AUTHENTICATION_SUCCESS on the AdobeHSAuthenticator.</p>
<p>To know if application is fully connected and synchronized, we must add a listenner to the SessionEvent.SYNCHRONIZATION_CHANGE event of sessionContainer and watch for its isSynchronized property. We will talk about differents aspects of this synchronisation in future tutorials.</p>
<pre class="brush: xml">

&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;
&lt;mx:Application layout=&quot;absolute&quot;
    xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;
    xmlns:rtc=&quot;AfcsNameSpace&quot;
&gt;
     &lt;mx:Script&gt;
         &lt;![CDATA[
             import mx.controls.Alert;
             import com.adobe.rtc.events.SessionEvent;

             // session&#039;s state
             private var isConnected:Boolean = false;

			// when a &quot;server synchronization&quot; event is dispatched
             public function onSynchro( e:SessionEvent ):void
             {
                 if ( sessionManager.isSynchronized &amp;&amp;  ! isConnected )
                 {
                     Alert.show(&quot;Application connectée&quot;);
                     isConnected = true ;
                 }
             }
     ]]&gt;
 &lt;/mx:Script&gt;
&lt;rtc:ConnectSessionContainer id=&quot;sessionManager&quot;
    width=&quot;100%&quot; height=&quot;100%&quot; backgroundColor=&quot;#FFFFFF&quot;
    authenticator=&quot;{identificator}&quot;
    roomURL=&quot;http://connectnow.acrobat.com/regartdemo/meetingzone&quot;
    synchronizationChange=&quot;onSynchro( event )&quot;
/&gt;
&lt;!-- Authentication component --&gt;
 &lt;rtc:AdobeHSAuthenticator id=&quot;identificator&quot;
   userName=&quot;YourUserName&quot; password=&quot;YourPassword&quot;
   authenticationSuccess=&quot;Alert.show(&#039;authentication success&#039;)&quot;
   authenticationFailure=&quot;Alert.show(&#039;authentication failed&#039;)&quot;/&gt;
&lt;/mx:Application&gt;
</pre>
<p>Now that our application can establish a connection to the room, we can start adding pod components.</p>
<h3>Using <del datetime="2009-03-06T16:02:18+00:00">Cocomo</del> AFCS Pods</h3>
<p>Pods are &laquo;&nbsp;ready to go&nbsp;&raquo; components. When you use a ConnectSessionContainer, you just have to add pods as children in it, and allow them to detect and use your <del datetime="2009-03-06T16:02:18+00:00">Cocomo</del> AFCS server connection.</p>
<p>For now, <del datetime="2009-03-06T16:02:18+00:00">Cocomo</del> AFCS contains:<br />
- Simple chat: chat component allowing public and private messages.<br />
- WebCamera: webcam publisher / subscriber<br />
- FileShare component: file sharing components (upload / download)<br />
- Shared Notes components<br />
- Roster and horizontalRoster: user management components<br />
- SharedWhiteBoard</p>
<p>Let&#8217;s insert our pods :</p>
<pre class="brush: xml">

&lt;rtc:ConnectSessionContainer id=&quot;sessionManager&quot; width=&quot;100%&quot; height=&quot;100%&quot; backgroundColor=&quot;#FFFFFF&quot;
   authenticator=&quot;{identificator}&quot;
   roomURL=&quot;http://connectnow.acrobat.com/votreCompte/nomSalon&quot;
   synchronizationChange=&quot;onSynchro( event )&quot;
   &gt;

   &lt;!-- PODS --&gt;
   &lt;mx:VBox width=&quot;50%&quot; height=&quot;100%&quot; horizontalAlign=&quot;center&quot;&gt;

      &lt;rtc:WebCamera id=&quot;webcam&quot; width=&quot;300&quot; /&gt;

      &lt;rtc:SimpleChat id=&quot;chat&quot; width=&quot;100%&quot; height=&quot;100%&quot; /&gt;

   &lt;/mx:VBox&gt;

   &lt;mx:VBox width=&quot;50%&quot; height=&quot;100%&quot;  right=&quot;0&quot;&gt;

     &lt;rtc:FileShare id=&quot;fileManager&quot; width=&quot;100%&quot; height=&quot;50%&quot; /&gt;

      &lt;rtc:Note id=&quot;notes&quot; width=&quot;100%&quot; height=&quot;50%&quot; /&gt;
   &lt;/mx:VBox&gt;
&lt;/rtc:ConnectSessionContainer&gt;
</pre>
<p><img src="http://lafabrick.free.fr/blogImg/hello_cocomo-20081218-081901.jpg" alt="Hello Cocomo" /></p>
<p>Pods embed robust role management features, as we&#8217;ll see later.</p>
<p>Anyway, you&#8217;ve just built your first <del datetime="2009-03-06T16:02:18+00:00">Cocomo</del> AFCS application, or should I say your first &laquo;&nbsp;real time communication&nbsp;&raquo; application&#8230; I can&#8217;t think how we use to do that before!!??&#8230;</p>
<h3>User authentication et connection management</h3>
<p>Hmmm&#8230;there&#8217;s still something missing&#8230; For a single user app, it&#8217;s almost ok&#8230; but it&#8217;s not the scenario here&#8230; What are we going to do if, someday, we find friends and want to collaborate with them??? Does anybody need to connect with my &laquo;&nbsp;owner&nbsp;&raquo; account? Can we let any AS3 decompiler reveal our credential data? I don&#8217;t think so!! Fortunatly <del datetime="2009-03-06T16:02:18+00:00">Cocomo</del> AFCS allows us to easily manage these aspects.</p>
<p><del datetime="2009-03-06T16:02:18+00:00">Cocomo</del> AFCS room allows several authentication methods, specially :<br />
- as owner, based on your <del datetime="2009-03-06T16:02:18+00:00">Cocomo</del> AFCS Developer account credentials<br />
- as guest, only needing a user name.</p>
<pre class="brush: xml">

&lt;mx:Panel id=&quot;logPanel&quot; &gt;
   &lt;mx:Form&gt;

      &lt;mx:FormItem label=&quot;Login&quot;&gt;
         &lt;mx:TextInput id=&quot;chp_login&quot; /&gt;
      &lt;/mx:FormItem&gt;

      &lt;mx:FormItem label=&quot;your role :&quot; direction=&quot;horizontal&quot; &gt;

         &lt;mx:RadioButtonGroup id=&quot;userRole&quot; /&gt;

         &lt;mx:RadioButton id=&quot;isGuest&quot; groupName=&quot;userRole&quot;
            label=&quot;Guest&quot; value=&quot;{UserRoles.VIEWER}&quot;  selected=&quot;true&quot;
         /&gt;
         &lt;mx:RadioButton id=&quot;isOwner&quot; groupName=&quot;userRole&quot;
            label=&quot;Host&quot; value=&quot;{UserRoles.OWNER}&quot;
         /&gt;
      &lt;/mx:FormItem&gt;

      &lt;mx:FormItem label=&quot;Password&quot;  enabled=&quot;{ userRole.selectedValue == UserRoles.OWNER }&quot;&gt;
         &lt;mx:TextInput id=&quot;field_password&quot; displayAsPassword=&quot;true&quot;  /&gt;
      &lt;/mx:FormItem&gt;

      &lt;mx:FormItem &gt;
         &lt;mx:Button label=&quot;Enter&quot;
            click=&quot;login(chp_login.text , userRole.selectedValue == UserRoles.OWNER ? field_password.text : null  )&quot;
          /&gt;
      &lt;/mx:FormItem&gt;

   &lt;/mx:Form&gt;
&lt;/mx:Panel&gt;
</pre>
<p>Users role definition is based on integer values, which are defined as constants in UserRoles class.</p>
<p>The principal roles are : owner (host / developer account), publisher (guest who can publish on one or several components) and viewer (passive guest who is only allowed to publish on chat channel). By default, guests can use a room only if the owner is connected. You can configure initial room settings (auto-promote guest as publisher, data persistence, free room access&#8230;). You can also manage user roles and permissions with the <del datetime="2009-03-06T16:02:18+00:00">CocomoDevConsole</del> AFCSDevConsole app, or directly by using the API. But that&#8217;s another story&#8230;</p>
<p>For now we will insert an authentication form. We thus need to deactivate the ConnectSessionContainer&#8217;s autoLogin property.</p>
<p>Then, we need to add a login() method, in charge of filling the AdobeHSAuthenticator with data. It will also initialize the sessionContainer room connection:</p>
<pre class="brush: js">

private function login ( login:String, password:String ):void
{
   identificator.userName = login;
	//if password is set : log as host
	//else log as guest
   identificator.password = password ;

	// run sessionManager connection
   sessionManager.login();
}
</pre>
<p>We can also add a logout button.</p>
<pre class="brush: js">

// disconnection
// in actual 0.9 beta, mostly pods, can&#039;t be re-connected after a disconnection

private function logout():void
{
    sessionManager.logout();

	// close() is supposed to disconnect et remove all childNodes, but seems not work yet
    //sessionManager.close();
}
</pre>
<pre class="brush: xml">

&lt;mx:VBox width=&quot;50%&quot; height=&quot;100%&quot; horizontalAlign=&quot;center&quot; right=&quot;0&quot;&gt;
    &lt;mx:Button label=&quot;Logout&quot; click=&quot;logout()&quot; /&gt;

    &lt;rtc:FileShare id=&quot;fileManager&quot; width=&quot;100%&quot; height=&quot;50%&quot; /&gt;

    &lt;rtc:Note id=&quot;notes&quot; width=&quot;100%&quot; height=&quot;50%&quot; /&gt;
&lt;/mx:VBox&gt;
</pre>
<p>Once the application is connected, we shall remove the form and the sessionContainer will be removed as well when the connection is stopped or lost</p>
<pre class="brush: js">

// for each synchronization event
// : connection, disconnection , state&#039;s change, ...
private function onSynchro( e:SessionEvent ):void
{

	// once application is successfully connected / synchronized
    if ( sessionManager.isSynchronized &amp;&amp; ! isConnected )
    {
        Alert.show(&quot;Application connectée&quot;);

        isConnected = true ;

        removeChild( logPanel );

    } else if ( ! sessionManager.isSynchronized &amp;&amp; isConnected ){
    // if disconnected
    isConnected = false ;

   /* remove the connectSessionContainer
   *  » in this version disconnected pods can&#039;t re-connect
   *
   *  » For re-connect, you can :
   *     - reload html page
   *     - dynamically re-create connectSession and pods
   */
   removeChild( sessionManager );

   // display logout message
   Alert.show( &#039;vous avez quitté la réunion, recharger la page pour entrer à nouveau&#039;);
   }
}
</pre>
<p>In this beta version, I encountered problems when trying to repeat multiple login/logout. After a few tests, the best way I found wass to force a page refresh.</p>
<p><a href="http://www.e-actif.com/lab/hello_cocomo">Get sources</a></p>
<p>This first <del datetime="2009-03-06T16:02:18+00:00">Cocomo</del> AFCS example is finished, and obviously it&#8217;s possible to do a lot more. In future tutorials, we&#8217;ll take a deeper look on <del datetime="2009-03-06T16:02:18+00:00">Cocomo</del> AFCS architecture. We&#8217;ll also use the <del datetime="2009-03-06T16:02:18+00:00">CocomoDevConsole</del> AFCSDevConsole and LocalConnectionServer, two AIR utilities included in the SDK.</p>
<p>Have a good collaboration !!! <img src='http://www.lafabrick.com/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> Autres articles sur le même sujet
<ul>
<li><a href="http://www.lafabrick.com/blog/2008/12/23/591-cocomo-wiibot/" rel="bookmark" title="23 décembre 2008">Introducing r.CØ &#8230; First &laquo;&nbsp;Cocomo ready&nbsp;&raquo; Air Wiibot&#8230;</a></li>
<li><a href="http://www.lafabrick.com/blog/2009/01/21/999-what-is-adobe-cocomo/" rel="bookmark" title="21 janvier 2009">Developing with AFCS a.k.a Cocomo &#8211; Introduction</a></li>
<li><a href="http://www.lafabrick.com/blog/2009/01/31/1040-hello-cocomo-first-app/" rel="bookmark" title="31 janvier 2009">Hello AFCS ( bye Cocomo ) : première application multi-utilisateurs</a></li>
<li><a href="http://www.lafabrick.com/blog/2009/01/15/819-reflex-2-vous-reprendez-bien-un-peu-de-ioc/" rel="bookmark" title="15 janvier 2009">Reflex #2 : vous reprendrez bien un peu de IOC ?</a></li>
</ul>
<p><!-- Similar Posts took 26.197 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.lafabrick.com/blog/en/2009/01/31/2175-hello-afcs-bye-cocomo-simple-user-authentication-with-adobe-flash-collaboration-services/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

