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

<channel>
	<title>armisael.silix.org &#187; opensource</title>
	<atom:link href="http://armisael.silix.org/tag/opensource/feed/" rel="self" type="application/rss+xml" />
	<link>http://armisael.silix.org</link>
	<description>Armisael's scientific world</description>
	<lastBuildDate>Sat, 28 Jan 2012 13:35:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>AS3: write a simple undefined loader</title>
		<link>http://armisael.silix.org/2009/03/as3-write-a-simple-undefined-loader/</link>
		<comments>http://armisael.silix.org/2009/03/as3-write-a-simple-undefined-loader/#comments</comments>
		<pubDate>Thu, 05 Mar 2009 20:11:24 +0000</pubDate>
		<dc:creator>Armisael</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[actionscript 3]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[loader]]></category>
		<category><![CDATA[opensource]]></category>

		<guid isPermaLink="false">http://armisael.silix.org/?p=27</guid>
		<description><![CDATA[I love to write my own visual classes in actionscript3. Some days ago I was searching for an undefined loader, like a rotating animated gif. But I thought that it would be great to have something wrote in as3 to do that, so I code it. I wrote a simple as3 class that shows some &#8230; </p><p><a class="more-link block-button" href="http://armisael.silix.org/2009/03/as3-write-a-simple-undefined-loader/">Continue reading &#187;</a>]]></description>
			<content:encoded><![CDATA[<p>I love to write my own visual classes in actionscript3. Some days ago I was searching for an undefined loader, like a rotating animated gif. But I thought that it would be great to have something wrote in as3 to do that, so I code it.</p>
<p>I wrote a simple as3 class that shows some circles that moves from a point to the external of the loader, creating a simple bubble effect.</p>
<p>Here you can see it in action: <a href="http://armisael.silix.org/wp-content/uploads/2009/03/undefinedloaderexample1.swf" target="_blank">UndefinedLoader.swf</a></p>
<p>What do we need? Well, I usually use Caurina.Tweener for the animations, you can download it on <a href="http://code.google.com/p/tweener/">google code</a>. Download the as3 version and copy it in your source directory.</p>
<p>After that create a new class extending Sprite and create a simple costructor like this:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package myControls
<span style="color: #66cc66;">&#123;</span>
    <span style="color: #0066CC;">import</span> caurina.<span style="color: #006600;">transitions</span>.<span style="color: #006600;">Tweener</span>;
    <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #66cc66;">*</span>;
&nbsp;
    <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> UndefinedLoader <span style="color: #0066CC;">extends</span> Sprite
    <span style="color: #66cc66;">&#123;</span>
        <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> w:<span style="color: #0066CC;">Number</span>;
        <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> h:<span style="color: #0066CC;">Number</span>;
        <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> colors:<span style="color: #0066CC;">Array</span> = <span style="color: #66cc66;">&#91;</span>0xFFFFFF<span style="color: #66cc66;">&#93;</span>;
&nbsp;
        <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> UndefinedLoader<span style="color: #66cc66;">&#40;</span>w:<span style="color: #0066CC;">Number</span>, h:<span style="color: #0066CC;">Number</span>, colors:<span style="color: #0066CC;">Array</span> = <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#123;</span>
            <span style="color: #0066CC;">this</span>.<span style="color: #006600;">w</span> = w;
            <span style="color: #0066CC;">this</span>.<span style="color: #006600;">h</span> = h;
            <span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">false</span>;
            <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>colors <span style="color: #66cc66;">!</span>= <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span>
                <span style="color: #0066CC;">this</span>.<span style="color: #006600;">colors</span> = colors;
        <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>We set the width and height attributes, and if the user want to change the color of the loader we set it.<br />
We will use the &#8216;visible&#8217; attribute to indicate if the loader is running or not. So we have to write a get function for that:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">        <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> loading<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>: <span style="color: #0066CC;">Boolean</span> <span style="color: #66cc66;">&#123;</span>
           <span style="color: #b1b100;">return</span> <span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">visible</span>;
        <span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>After that, we need some constants in the class, indicating the minimum and the maximum radius of the circles, the time for the animation, how many circles we want and the type of transition (see the Tweener documentation for the possible values)</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">        <span style="color: #0066CC;">private</span> const NCIRCLES: <span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">25</span>;
        <span style="color: #0066CC;">private</span> const MIN_DURATION: <span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">1</span>;
        <span style="color: #0066CC;">private</span> const MAX_DURATION: <span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">2.5</span>;
        <span style="color: #0066CC;">private</span> const MIN_RADIUS:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">2</span>;
        <span style="color: #0066CC;">private</span> const MAX_RADIUS:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">5</span>;
        <span style="color: #0066CC;">private</span> const TRANSITION: <span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;linear&quot;</span>;</pre></div></div>

<p>Ok, now we need the start and the stop functions. When we start the loader, we want to create the circles, storing them into a private array. After that we will call the animation function on each of them. Stopping the loader will only hide it. The animation will automatically stop by itself (see later).</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">        <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">start</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>: <span style="color: #0066CC;">void</span>
        <span style="color: #66cc66;">&#123;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">visible</span><span style="color: #66cc66;">&#41;</span>
                <span style="color: #b1b100;">return</span>; <span style="color: #808080; font-style: italic;">// animazione gia` partita!</span>
&nbsp;
            <span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">true</span>;
&nbsp;
            <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>circles.<span style="color: #0066CC;">length</span> == <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>
                <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span>; i <span style="color: #66cc66;">&amp;</span>lt; NCIRCLES; i++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                    circles<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span> = <span style="color: #000000; font-weight: bold;">new</span> Sprite<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
                    addChild<span style="color: #66cc66;">&#40;</span>circles<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;
                <span style="color: #66cc66;">&#125;</span>
&nbsp;
            <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span>i = <span style="color: #cc66cc;">0</span>; i <span style="color: #66cc66;">&amp;</span>lt; circles.<span style="color: #0066CC;">length</span>; i++<span style="color: #66cc66;">&#41;</span>
                tween<span style="color: #66cc66;">&#40;</span>circles<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
        <span style="color: #66cc66;">&#125;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">        <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">stop</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>: <span style="color: #0066CC;">void</span>
        <span style="color: #66cc66;">&#123;</span>
            <span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">false</span>;
        <span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>Now let we write the tween function: first of all we need to check if the loader is still shown. If it&#8217;s not, we will return, doing nothing. Otherwise, we generate randomly the color of the circle, the duration of the animation, the radius and the angle to move on. After that, reset the circles attribute, redraw it, and start the animation. When it will be completed, it will be recalled the tween function, checking if the loader is still working or not.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">        <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> tween<span style="color: #66cc66;">&#40;</span>c:Sprite<span style="color: #66cc66;">&#41;</span>: <span style="color: #0066CC;">void</span>
        <span style="color: #66cc66;">&#123;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">!</span><span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">visible</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                <span style="color: #b1b100;">return</span>; <span style="color: #808080; font-style: italic;">// fermiamo l'animazione.</span>
            <span style="color: #66cc66;">&#125;</span>
&nbsp;
            <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">color</span>:<span style="color: #0066CC;">int</span> = <span style="color: #66cc66;">&#40;</span>colors.<span style="color: #0066CC;">length</span> == <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> ? colors<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span> : <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">random</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">*</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">abs</span><span style="color: #66cc66;">&#40;</span>colors<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>-colors<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
            <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">time</span>:<span style="color: #0066CC;">Number</span> = <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">random</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">*</span><span style="color: #66cc66;">&#40;</span>MAX_DURATION - MIN_DURATION<span style="color: #66cc66;">&#41;</span>;
            <span style="color: #000000; font-weight: bold;">var</span> radius:<span style="color: #0066CC;">Number</span> = <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">random</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">*</span><span style="color: #66cc66;">&#40;</span>MAX_RADIUS - MIN_RADIUS<span style="color: #66cc66;">&#41;</span>;
            <span style="color: #000000; font-weight: bold;">var</span> beta:<span style="color: #0066CC;">Number</span> = <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">random</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">*</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">*</span><span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">PI</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
            c.<span style="color: #006600;">alpha</span> = <span style="color: #cc66cc;">1</span>;
            c.<span style="color: #006600;">x</span> = <span style="color: #cc66cc;">0</span>;
            c.<span style="color: #006600;">y</span> = <span style="color: #cc66cc;">0</span>;
            c.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">clear</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
            c.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">lineStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span>, <span style="color: #0066CC;">color</span>, <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;
            c.<span style="color: #006600;">graphics</span>.<span style="color: #006600;">drawCircle</span><span style="color: #66cc66;">&#40;</span>w<span style="color: #66cc66;">/</span><span style="color: #cc66cc;">2</span>, h<span style="color: #66cc66;">/</span><span style="color: #cc66cc;">2</span>, radius<span style="color: #66cc66;">&#41;</span>;
&nbsp;
            Tweener.<span style="color: #006600;">addTween</span><span style="color: #66cc66;">&#40;</span>c, <span style="color: #66cc66;">&#123;</span>x:w<span style="color: #66cc66;">/</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">*</span><span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">cos</span><span style="color: #66cc66;">&#40;</span>beta<span style="color: #66cc66;">&#41;</span>, y:h<span style="color: #66cc66;">/</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">*</span><span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">sin</span><span style="color: #66cc66;">&#40;</span>beta<span style="color: #66cc66;">&#41;</span>,
                                 alpha:<span style="color: #cc66cc;">0</span>, <span style="color: #0066CC;">time</span>:<span style="color: #0066CC;">time</span>, transition:TRANSITION,
                                 onComplete: tween, onCompleteParams:<span style="color: #66cc66;">&#91;</span>c<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#41;</span>;
        <span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>You can download the source code here: <a href="http://armisael.silix.org/wp-content/uploads/2009/03/undefinedloader.as">undefinedloader.as</a></p>
]]></content:encoded>
			<wfw:commentRss>http://armisael.silix.org/2009/03/as3-write-a-simple-undefined-loader/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My Projects</title>
		<link>http://armisael.silix.org/my-projects/</link>
		<comments>http://armisael.silix.org/my-projects/#comments</comments>
		<pubDate>Fri, 26 Sep 2008 16:59:53 +0000</pubDate>
		<dc:creator>Armisael</dc:creator>
				<category><![CDATA[Senza categoria]]></category>
		<category><![CDATA[fbk]]></category>
		<category><![CDATA[gaja]]></category>
		<category><![CDATA[mindgapper]]></category>
		<category><![CDATA[moograph]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[sourceforge]]></category>
		<category><![CDATA[webvalley]]></category>

		<guid isPermaLink="false">http://armisael.silix.org/?page_id=3</guid>
		<description><![CDATA[Here there are some projects I&#8217;m working / I&#8217;ve been working on: Gaja: Just another Judge for algorithms&#8230; Gaja is a web application written in Java (jsp and servlets) that lets students to submit their algorithms (C/C++, Java and Pascal). The goal is to solve some tipical informatic problems, like sorting, searching, data manipulation, &#8230; &#8230; </p><p><a class="more-link block-button" href="http://armisael.silix.org/my-projects/">Continue reading &#187;</a>]]></description>
			<content:encoded><![CDATA[<p>Here there are some projects I&#8217;m working / I&#8217;ve been working on:</p>
<h2>Gaja: Just another Judge for algorithms&#8230;</h2>
<p>Gaja is a web application written in Java (jsp and servlets) that lets students to submit their algorithms (C/C++, Java and Pascal). The goal is to solve some tipical informatic problems, like sorting, searching, data manipulation, &#8230;<br />
This OpenSource Software is written for the OII italian students, and it was commissioned by the &#8220;Liceo Galileo Galilei&#8221; of Trento and the University of Trento.<br />
<a href="http://sourceforge.net/projects/gaja/">Gaja on SourceForge</a><br />
<a href="http://gaja.science.unitn.it">Gaja on university server</a><br />
<a href="http://lsgalilei.tn.it/">Liceo Galilei WebSite</a><br />
<a href="http://science.unitn.it"> University of Trento</a></p>
<h2>MooGraph (was MindGapper): a GapMinder clone</h2>
<p>MooGraph is an OpenSource clone of GapMinder, the Google&#8217;s software for multidimensional data-view. Written in Flex 3 and ActionScript 3, MooGraph is a scatterplot that lets you to see interesting data associated with countries. Three different indicators can be shown by it (x and y axis and bubble dimensions). It also support countries aggregation.<br />
Written with the italian students of WebValley 2008, organized by the Bruno Kessler Foundation.<br />
<a href="http://sourceforge.net/projects/mindgapper/">MooGraph on SourceForge</a><br />
<a href="http://www.fbk.eu/">Bruno Kessler Foundation</a></p>
]]></content:encoded>
			<wfw:commentRss>http://armisael.silix.org/my-projects/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

