<?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>Francois Faubert &#187; Flash</title>
	<atom:link href="http://www.francoisfaubert.com/category/flash/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.francoisfaubert.com</link>
	<description></description>
	<lastBuildDate>Tue, 08 Sep 2009 19:00:31 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Multi-Treading Oriented ActionScript</title>
		<link>http://www.francoisfaubert.com/2006/11/16/multi-treading-oriented-actionscript/</link>
		<comments>http://www.francoisfaubert.com/2006/11/16/multi-treading-oriented-actionscript/#comments</comments>
		<pubDate>Fri, 17 Nov 2006 02:55:45 +0000</pubDate>
		<dc:creator>francoisfaubert</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[setInterval]]></category>
		<category><![CDATA[Theading]]></category>

		<guid isPermaLink="false">http://fake.themusictank.com/2006/11/16/multi-treading-oriented-actionscript/</guid>
		<description><![CDATA[I am currently working on a Flash animation that must deal with simultaneous management of dynamically created, autonomous MovieClips and the management of data obtained from various XML feeds from the Internet. It&#8217;s basically a RSS Aggregator in which RSS items are represented by a graphical symbol. All must be generated using ActionScript, meaning the [...]]]></description>
			<content:encoded><![CDATA[<p>I am currently working on a Flash animation that must deal with simultaneous management of dynamically created, autonomous MovieClips and the management of data obtained from various XML feeds from the Internet. It&#8217;s basically a RSS Aggregator in which RSS items are represented by a graphical symbol. All must be generated using ActionScript, meaning the actual .swf file only consists of a call to the constructor of my main .as class.</p>
<p>Having learned how to program mainly with Java and VB.Net, the approach I wanted to take was to have two threads running in my flash movie : one that fetches and treats the XML data, the second that handles events, collisions and the movement of the MovieClips. However, to put it bluntly, there is no such thing as multi-treading in Flash 9.</p>
<p>The approach I chose to solve this problem was to generate calls to key function of my main class using the <a href="http://www.adobe.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary646.html"><code>setInterval</code></a> function. Of course, on a much larger scale, one would probably notice a lag when using an interval technique compared to real simultaneous treading. However, with the usual Flash applications this kind of performance goes rather unnoticed.</p>
<p>Here&#8217;s an example similar to what I am doing:</p>
<pre><code>class Feed {
    public function Feed():Void {
        setInterval(this.refreshFeedData, 500);
        setInterval(this.moveFeedMovieClips, 500);
    }
    public function refreshFeedData():Void {
        // load the xml
    }
    public function moveFeedMovieClips():Void {
        // run through my MovieClip objects
    }
}</code></pre>
<p>By keeping a frequent and similar intervals (in this example 0.5 seconds), you can somewhat mimic the threading effect. Note that you can lose the reference to the class using &#8220;<code>this</code>.&#8221; in the function being called by <a href="http://www.adobe.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary646.html"><code>setInterval</code></a> . You can go around it by supplying a reference to the current class in the call :</p>
<pre><code>setInterval(this.moveFeedMovieClips, 500, this);</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.francoisfaubert.com/2006/11/16/multi-treading-oriented-actionscript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>1 step forward, 2 steps back</title>
		<link>http://www.francoisfaubert.com/2006/08/01/1-step-forward-2-steps-back/</link>
		<comments>http://www.francoisfaubert.com/2006/08/01/1-step-forward-2-steps-back/#comments</comments>
		<pubDate>Tue, 01 Aug 2006 18:33:25 +0000</pubDate>
		<dc:creator>francoisfaubert</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Local file]]></category>
		<category><![CDATA[Tile Game]]></category>

		<guid isPermaLink="false">http://www.themusictank.com/fake/2006/08/01/1-step-forward-2-steps-back/</guid>
		<description><![CDATA[Once more I trip on the flowers of the carpet. To easy my game making, it was necessary to build a Flash application that would make the process of drawing my maps a visual process. That idea worked pretty well, especially because Flash supplies competent User Interface objects I wouldn&#8217;t have to make myself.
A problem [...]]]></description>
			<content:encoded><![CDATA[<p>Once more I trip on the flowers of the carpet. To easy my game making, it was necessary to build a Flash application that would make the process of drawing my maps a visual process. That idea worked pretty well, especially because Flash supplies competent User Interface objects I wouldn&#8217;t have to make myself.</p>
<p>A problem came up however. I needed to loop through a specified local folder recursively in order to load the *.gifs, *.pngs and whatnot in the local file structure. Flash 8 has added file management support with the <a href="http://livedocs.macromedia.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&amp;file=00002204.html#234413">FileReference</a> class. It&#8217;s neat browse() function mimics HTML&#8217;s file input to pop the file browsing dialog. There were two problems with this class:</p>
<ul>
<li>I couldn&#8217;t select a directory;</li>
<li>I couldn&#8217;t select multiple files.</li>
</ul>
<p>Screwed aren&#8217;t we? I&#8217;ve also learned you could browse through local files using an ActiveX valid only for IE which is completely useless. All other solutions involve fetching the files using server-side scripting like PHP or ASP which no one have installed on their desktop anyway (if you do have one of these installed, then you are official a nerd).</p>
<p>So, desperate but not without motivation, I&#8217;ve downloaded Mac&#8217;s software development package in hopes of building it on that platform. We&#8217;ll see how it goes.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.francoisfaubert.com/2006/08/01/1-step-forward-2-steps-back/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rise Of The Espers: The Making of</title>
		<link>http://www.francoisfaubert.com/2006/06/14/rise-of-the-espers-the-making-of/</link>
		<comments>http://www.francoisfaubert.com/2006/06/14/rise-of-the-espers-the-making-of/#comments</comments>
		<pubDate>Thu, 15 Jun 2006 01:40:34 +0000</pubDate>
		<dc:creator>francoisfaubert</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Game Making]]></category>
		<category><![CDATA[Tiles]]></category>

		<guid isPermaLink="false">http://www.themusictank.com/fake/2006/06/14/rise-of-the-espers-the-making-of/</guid>
		<description><![CDATA[Introduction
For about 2 years now, I wanted to make a full blown flash game. I’ve done a few unfinished sketches, have tried to build an adventure game engine, then I tried doing an RPG engine, then followed a simulation game, and then I tried making an RPG again. Hell, I even tried to make a [...]]]></description>
			<content:encoded><![CDATA[<h3>Introduction</h3>
<p>For about 2 years now, I wanted to make a full blown flash game. I’ve done a few unfinished sketches, have tried to build an adventure game engine, then I tried doing an RPG engine, then followed a simulation game, and then I tried making an RPG again. Hell, I even tried to make a hockey game.</p>
<p>Do I even need to say making a <em>real</em> flash game it’s hard as hell?</p>
<p>That&#8217;s without mentioning the common cliché of Real Life catching up and forcing me to put my projects on the ice for a while. Also, just like any project you do without thinking thoroughly before beginning, after a while you start noticing how the programming sucks, how the same thing could be done in a much simpler way and all that depressing crap.</p>
<p>Well! Now I feel like going at it again. Though I don’t know how much time it’ll take me, I have decided on continuing Rise of the Espers (read: start it over again). This RPG is meant to be similar than those of the SNES and should be a mix between Final Fantasy 3 and Secret Of Mana. We&#8217;ll see how <em>that</em> will go!</p>
<p>Of course, you can’t quite tackle a task like that without help. Even if I’ll probably end up making everything myself, I will need the help of those with more “mathematical” minds that mine. It was by asking Evilmax help on how I could generate an isometric map dynamically that he came up with the idea of having me publish the game’s progress. Without further ado, here’s the first post in a long series in the Rise Of The Espers: The Making of.</p>
<h3>“Let there be light”</h3>
<p><a class="imagelink" title="Flash Project File" href="http://www.francoisfaubert.com/wordpress/wp-content/uploads/2006/06/project.png"><img id="image22" src="http://www.francoisfaubert.com/wordpress/wp-content/uploads/2006/06/project.thumbnail.png" alt="Flash Project File" align="left" /></a>Here is a screenshot of the game&#8217;s architecture at the moment. The Game.as file is where I will be handling the game&#8217;s interface (new game menu, options menu, save, etc). The Map.as class will generate the map using data from an XML file and by creating a Tile.as object per each texture tile.</p>
<p>Utils.as is a file I&#8217;ve been using for a while in many of my projects. I store usefull static functions in there like the event handlers.</p>
<p><a class="imagelink" title="XML file of the map called 0001.xml" href="http://www.francoisfaubert.com/wordpress/wp-content/uploads/2006/06/xml.png"></a><a class="imagelink" title="XML file of the map called 0001.xml" href="http://www.francoisfaubert.com/wordpress/wp-content/uploads/2006/06/xml.png"><img id="image23" src="http://www.francoisfaubert.com/wordpress/wp-content/uploads/2006/06/xml.thumbnail.png" alt="XML file of the map called 0001.xml" align="right" /></a>game.fla is an empty file with only a call to the Game.as&#8217; constructor in the actions layer of the first frame.</p>
<p>The map itself is created from an xml file that contains arrays of numbers which are each associated with a image in the game.fla texture pack. For performance issues, the texture images are likely to be pixel images and not drawn in Flash.</p>
<p><a class="imagelink" title="library of the game.fla file" href="http://www.francoisfaubert.com/wordpress/wp-content/uploads/2006/06/library.png"><img id="image24" src="http://www.francoisfaubert.com/wordpress/wp-content/uploads/2006/06/library.thumbnail.png" alt="library of the game.fla file" align="left" /></a>The game.fla file does more than it is supposed to be doing at the moment. As the project grows in maturity, game.fla will handle game menus, pauses, server connections and whatnot. To continue loading the maps, I will create another placeholder movie where only Map instances are created. This map movie loader will be loaded from game.fla using the loadMovie() command.</p>
<p>Extensive use of the Progress bar control warns of data transfers delays but is also used with each heavy loops, like the one that creates the tiles. While you don&#8217;t even see them when I start the game from my desktop, they will be much appreciated on the web. I also use the alert component to raise error messages.</p>
<p><a class="imagelink" title="the beginning of a game" href="http://www.francoisfaubert.com/wordpress/wp-content/uploads/2006/06/result.png"><img id="image25" src="http://www.francoisfaubert.com/wordpress/wp-content/uploads/2006/06/result.thumbnail.png" alt="the beginning of a game" align="right" /></a>And that&#8217;s where I stand at the moment, the movie loads a simple map of two textures dynamically. The next step will be to draw the main textures and build a quick interface in flash through which I will be able to save my arrays automatically, and not have to learn all the texture codes by heart.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.francoisfaubert.com/2006/06/14/rise-of-the-espers-the-making-of/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Eureka Follow up</title>
		<link>http://www.francoisfaubert.com/2006/02/07/eureka-follow-up/</link>
		<comments>http://www.francoisfaubert.com/2006/02/07/eureka-follow-up/#comments</comments>
		<pubDate>Tue, 07 Feb 2006 16:38:19 +0000</pubDate>
		<dc:creator>francoisfaubert</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Actionscript 2]]></category>
		<category><![CDATA[Event Delegation]]></category>
		<category><![CDATA[OOP]]></category>

		<guid isPermaLink="false">http://themusictank.com/fake/?p=12</guid>
		<description><![CDATA[The use of a static method to delegate events in Flash is one of the easiest ways of associating functions to an event.]]></description>
			<content:encoded><![CDATA[<p>As I mentioned in my last post, the Delegate class is quite useful even if I couldn&#8217;t pass parameters as easily as I would have wanted. While looking around today, I stumbled on <a href="http://www.person13.com/articles/proxy/Proxy.htm">this method</a> which also makes things much easier. I don&#8217;t like how it&#8217;s written because of the in-line functions, but it really does solve the problem. Here&#8217;s the code, which I took the liberty to customize a little bit:</p>
<pre><code>class Utils {
// Desc		:	Usually, when you attach a function to an event, you can't pass
//			parameters, using this function instead of the Delegate class
//			will allow you to do the same thing but with unlimitted parameters
// 			Window: General Information.
// 			http://www.person13.com/articles/proxy/Proxy.htm
public static function delegateEvent(oTarget:Object, fFunction:Function):Function {
    // Create an array of the extra parameters passed to the method. Loop
    // through every element of the arguments array starting with index 2,
    // and add the element to the aParameters array.
    var aParameters:Array = new Array();
    for(var i:Number = 2; i &lt; arguments.length; i++) {
        aParameters[i - 2] = arguments[i];
    }
    // Create a new function that will be the proxy function.
    var fProxy:Function = function():Void {
        var aActualParameters:Array = arguments.concat(aParameters);
        fFunction.apply(oTarget, aActualParameters);
    };
    return fProxy;
}</code></pre>
<p>And you can call it like this:</p>
<pre><code>private function someFunction():Void {
    this._xml.onLoad = Utils.delegateEvent(this, xml_onLoad, "GeneralInformation");
}

private function xml_onLoad(success:Boolean, nextStep:String):Void {
    if(success)
    // Get the contents of xml
    switch (nextStep) {
        case "GeneralInformation" :
            this.open_GeneralInformation(); break;
    //etc...
    }
}</code></pre>
<p>This was a huge time savor and suits how I like to write code.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.francoisfaubert.com/2006/02/07/eureka-follow-up/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Eureka!</title>
		<link>http://www.francoisfaubert.com/2006/02/01/eureka/</link>
		<comments>http://www.francoisfaubert.com/2006/02/01/eureka/#comments</comments>
		<pubDate>Wed, 01 Feb 2006 19:13:52 +0000</pubDate>
		<dc:creator>francoisfaubert</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Actionscript 2]]></category>
		<category><![CDATA[Event Delegation]]></category>
		<category><![CDATA[OOP]]></category>

		<guid isPermaLink="false">http://themusictank.com/fake/?p=11</guid>
		<description><![CDATA[I’ve been having a lot of trouble having Event (clicks, loads, etc&#8230;) in Flash for as long as I’ve been doing Object-Oriented ActionScript. I barely managed to call inline functions and having to use the absolute path to the property. Example:
class Foo {
	public var _someProperty:String
	public function Foo() {
		// Lets skip how I actually make the [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve been having a lot of trouble having Event (clicks, loads, etc&#8230;) in Flash for as long as I’ve been doing Object-Oriented ActionScript. I barely managed to call inline functions and having to use the absolute path to the property. Example:</p>
<pre><code>class Foo {
	public var _someProperty:String
	public function Foo() {
		// Lets skip how I actually make the button,
		// but I usually use .attach() and I make
		// exportable the object in the Library. I
		// think I should use createClassComponent however.
		var but:MovieClip = new MovieClip();
		but.onPress = function () {
		_root.MyFooObject._someProperty = “Clicked”;
		}
	}
}</code></pre>
<p>To access my attribute, I must leave my class and follow the absolute, practically hard-coded, path to my value. It&#8217;s really not a good thing to do. Instead, I found you can use the Delegate class to forward events to a function inside the parent class. Like this:</p>
<pre><code>class Foo {
	private var _someProperty:String
	public function Foo() {
		// Lets skip how I actually make the button here too.
		var but:MovieClip = new movieclip();
		but.onPress = mx.utils.Delegate.create(this, button_onClick);
	}
	private function button_onClick():Void {
		this._someProperty = “Clicked”;
	}
}</code></pre>
<p>Where &#8220;this&#8221; means the class you are in (could be another one), and &#8220;button_onClick&#8221; is the name of the function you will be calling after the event is triggered.</p>
<p>There you go! It’s a lot more powerful, much more logical from a semantic point of view and it makes the code a lot clearer. Notice how I can protect my call properties now using the private attribute.</p>
<p>Speaking of being semantic, you always should call you call properties with &#8220;getters and setters&#8221; instead of calling it directly like I did in my example. It should look like this instead:</p>
<pre><code>private var _someProperty:String
public function get someProperty():String { return this._someProperty;}
public function set someProperty(val:String):Void {
    // validation if needed; this._someProperty = val;
}</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.francoisfaubert.com/2006/02/01/eureka/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>mx.transitions.Tween</title>
		<link>http://www.francoisfaubert.com/2005/12/08/mxtransitionstween/</link>
		<comments>http://www.francoisfaubert.com/2005/12/08/mxtransitionstween/#comments</comments>
		<pubDate>Fri, 09 Dec 2005 03:52:05 +0000</pubDate>
		<dc:creator>francoisfaubert</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Actionscript 2]]></category>
		<category><![CDATA[Animation]]></category>
		<category><![CDATA[Tweening]]></category>

		<guid isPermaLink="false">http://themusictank.com/fake/?p=9</guid>
		<description><![CDATA[One of my current assignments at work is to make something similar to Google Maps for my employer’s Oil website. I must build a map browser that is completely dynamic that will need to generate 3 dynamic layers for 3 different types of maps of Oil Wells.
I decided on making this using Flash, just like [...]]]></description>
			<content:encoded><![CDATA[<p>One of my current assignments at work is to make something similar to Google Maps for my employer’s Oil website. I must build a map browser that is completely dynamic that will need to generate 3 dynamic layers for 3 different types of maps of Oil Wells.</p>
<p>I decided on making this using Flash, just like Yahoo Maps have. From the start, the most important feature was how I had to permit a click event somewhere on the map and to center the map on these X and Y coordinates. At first, I approached the project by planning on incrementing a value to the <code>_x</code> and <code>_y</code> properties of the map MovieClip for some period of time to mimic movement until the map was re-centered, but I’ve had no success doing so.</p>
<p>That’s when I had a revelation. Once you start trying to build Object-Oriented applications in Flash, you tend to forget all the design tools built-in Flash. Why didn’t I call the Tween function from within ActionScript? And so I did.</p>
<p>Here’s the relatively simple function call to move a MovieClip object using the Tween class:</p>
<pre><code>new mx.transitions.Tween(MovieClip, "_x", easeType, begin, end, speed of execution, time unit boolean);</code></pre>
<p>You pass on a MovieClip, the property you wish to edit (in Flash, the properties all start with “_”), the effect you wish to use for the transition, the starting value (for the <code>_x</code> property, <code>MovieClip ._x</code> for instance), the end value (passing <code>MovieClip ._x  + 50</code> would create a motion tween that would move the MovieClip 50 pixels to the right from its original location), and the speed of execution which is either counted in seconds or in frames depending on the last Boolean parameter (<code>true</code> meaning seconds).</p>
<p>It’s really flexible and powerful. Passing in a different easing type will allow you to apply built-in elastic or bouncing effects to a MovieClip. Now all of the bouncing menus we see all over the Internet seem much simpler.</p>
<p>You can also pause, rewind and do other operations on the Tween process because it generates events as the animation plays.</p>
<p>It opens a lot of doors to OOP in Flash. You no longer need to bother with sketchy animations when forcing movement on your MovieClips from within a Class.</p>
<p>If you code in Flash and have never come across this function, I strongly suggest you <a href="http://www.designcontest.net/tutorials/tween_easing/index.html ">read more on this undocumented function</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.francoisfaubert.com/2005/12/08/mxtransitionstween/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Love/hate relationship with Flash&#8217;s components</title>
		<link>http://www.francoisfaubert.com/2005/11/12/lovehate-relationship-with-flash%e2%80%99s-components/</link>
		<comments>http://www.francoisfaubert.com/2005/11/12/lovehate-relationship-with-flash%e2%80%99s-components/#comments</comments>
		<pubDate>Sat, 12 Nov 2005 15:11:20 +0000</pubDate>
		<dc:creator>francoisfaubert</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Actionscript 2]]></category>
		<category><![CDATA[OOP]]></category>

		<guid isPermaLink="false">http://themusictank.com/fake/?p=5</guid>
		<description><![CDATA[Macromedia have brought a lot more depth into Flash by adding pre-compiled components (or movie clips) to the software&#8217;s library. Mostly available only in the professional edition, these components make building application faster and easier.
One of the components I&#8217;ve played with it the Window object. It&#8217;s simple to understand and it&#8217;s possible to create a [...]]]></description>
			<content:encoded><![CDATA[<p>Macromedia have brought a lot more depth into Flash by adding pre-compiled components (or movie clips) to the software&#8217;s library. Mostly available only in the professional edition, these components make building application faster and easier.</p>
<p>One of the components I&#8217;ve played with it the Window object. It&#8217;s simple to understand and it&#8217;s possible to create a Window on the fly using ActionScript only. Let me put some emphasis on that. Within a few lines, I was able to program my way into a graphic application. We can all agree that&#8217;s the goal behind the general direction Macromedia is taking and to a certain extent they are succeeding in doing so.</p>
<p>However, other components are much harder to instantiate or create/call straight from ActionScript. The documentation on Live Docs is also somewhat deficient. I&#8217;ve tried a gazillion times to have the XML connector work when created dynamically but couldn&#8217;t make it work yet. The media playback was a bit easier to build with dynamic values, but as I write this, the Mp3 player on The Music Tank still has trouble opening .mp3 files consistently.</p>
<p>What I hate about components is how I never know if it&#8217;s my fault if it&#8217;s not working. If it is (which is probably the case) there are two questions I can rarely find answers for:</p>
<ul>
<li>Am I supplying invalid values which failed validation once the control is speaking with my website? And</li>
<li> Is the control not working because I instantiated its properties with wrong values?</li>
</ul>
<p>I hope Flex will make it easier for graphic artists who are able to do real Object-Oriented programming. Right now, I feel pretty dumb having to use illogical code just to make up for Flash&#8217;s &#8220;almost-there&#8221; programming language.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.francoisfaubert.com/2005/11/12/lovehate-relationship-with-flash%e2%80%99s-components/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
