<?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>The Pixel Code &#187; Flash</title>
	<atom:link href="http://www.thepixelcode.com/category/development/flash/feed" rel="self" type="application/rss+xml" />
	<link>http://www.thepixelcode.com</link>
	<description>Design / Develop / Inspiration by Mohammed Khan</description>
	<lastBuildDate>Mon, 19 Jul 2010 03:45:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Working with Command Pattern &#8211; Interface</title>
		<link>http://www.thepixelcode.com/development/flash/working-with-command-pattern</link>
		<comments>http://www.thepixelcode.com/development/flash/working-with-command-pattern#comments</comments>
		<pubDate>Sat, 08 Aug 2009 12:46:47 +0000</pubDate>
		<dc:creator>Mohammed Khan</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[command]]></category>
		<category><![CDATA[pattern]]></category>

		<guid isPermaLink="false">http://www.thepixelcode.com/?p=294</guid>
		<description><![CDATA[Applications that require undo/redo functionality, can be constructed using the Command Pattern. Other uses of command pattern can be to construct reusable components, process queued requests, and develop wizard or transactional applications. As the name goes, Command pattern encapsulates functionality into a class and consist of five elements: 1. Interface 2. Concrete Command 3. Receiver [...]]]></description>
			<content:encoded><![CDATA[<p>Applications that require undo/redo functionality, can be constructed using the Command Pattern. Other uses of command pattern can be to construct reusable components, process queued requests, and develop wizard or transactional applications. As the name goes, Command pattern encapsulates functionality into a class and consist of five elements:</p>
<p>1. Interface<br />
2. Concrete Command<br />
3. Receiver<br />
4. Client<br />
5. Invoker</p>
<div id="attachment_332" class="wp-caption alignnone" style="width: 460px"><a href="http://www.thepixelcode.com/wp-content/uploads/2009/08/Command-Pattern-Structure2.jpg"><img src="http://www.thepixelcode.com/wp-content/uploads/2009/08/Command-Pattern-Structure2.jpg" alt="Command Pattern Structure" title="Command Pattern Structure" width="450" height="235" class="size-full wp-image-332" /></a><p class="wp-caption-text">Command Pattern Structure</p></div>
<p>In this post I will touch upon <strong>Interface</strong> element of the command pattern. The command interface defines the <em>execute()</em> method, which is responsible for executing the requested operation. Also multiple command types can be implemented using the same interface. The command interface provides a programmatic approach to manage the objects which have disparate modes of operation.</p>
<pre class="java">
//General interface implementation
package com.thepixelcode.sampleCPExample.commands {

  public interface ICommand {
     function execute():void;
  }

}
</pre>
<p>The above snippet can be further extended to support the redo/undo functionality, and in order to implement, we would need to create two command interfaces, one for redo and another for undo which shall extend the <strong>ICommand</strong>.</p>
<pre class="java">
//Interface for undo
package com.thepixelcode.sampleCPExample.commands {

  public interface IUndoCommand extends ICommand {
     function undo():void;
  }
}

//Interface for redo
package com.thepixelcode.sampleCPExample.commands {

  public interface IRedoCommand extends ICommand {
     function redo():void;
  }
}
</pre>
<p>I didn&#8217;t want to write a long post over the weekend, also neither i wanted to loose on my writing spirit. Shall continue on other elements and a demo app in next post. Till then have a great weekend.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thepixelcode.com/development/flash/working-with-command-pattern/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Embedding Fonts for Flex in SWC</title>
		<link>http://www.thepixelcode.com/development/flex/embedding-fonts-for-flex-in-swc</link>
		<comments>http://www.thepixelcode.com/development/flex/embedding-fonts-for-flex-in-swc#comments</comments>
		<pubDate>Thu, 02 Jul 2009 21:59:49 +0000</pubDate>
		<dc:creator>Mohammed Khan</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[SWC]]></category>

		<guid isPermaLink="false">http://www.thepixelcode.com/?p=105</guid>
		<description><![CDATA[Its common that when a Flex developer needs to embed certain assets like images, fonts or skin graphics, SWF is the first thing that one would assemble using Adobe Flash CS3, but I was just wondering instead of loading the assets library at runtime, why not compile it within the main flex project. As we [...]]]></description>
			<content:encoded><![CDATA[<p>Its common that when a Flex developer needs to embed certain assets like images, fonts or skin graphics, SWF is the first thing that one would assemble using Adobe Flash CS3, but I was just wondering instead of loading the assets library at runtime, why not compile it within the  main flex project. As we usually do with other library files which needs to be included, I would then need to build a SWC using the Adobe Flash CS3 which shall contain the assets.</p>
<p>To try out, lets look at embedding few fonts which I wish to use in Flex project for styling the label text. Open Flash CS3, and follow the steps to create an SWC in which fonts are embedded.</p>
<ol>
<li>Embed a font by going to the library, and in the top right corner drop down, select “New Font…”. In the dialogue box, select the font that you want to embed, and give it a library name.</li>
<li>Then, in the library, right click the font, and select “Linkage…”.</li>
<li>Select “Export for ActionScript”, and give the font a class name, I gave here as <code>com.thepixelcode.fonts.EmbedSensation.</code></li>
<li>While exporting make sure that the option Export SWC is selected, you can name at this point the SWC as FontsLibrary.swc.</li>
</ol>
<p>Fire up your Flex Builder 3 and follow this steps :</p>
<ol>
<li>Create a Flex project called SampleFontTest and click Next.</li>
<li>Let the output folder be bin-debug and click Next.</li>
<li>In the Main Application Field, I usually prefer to name it as index.mxml, this is because when hosting on servers, its easy to deploy through scripts (don&#8217;t need t change name or do a mapping).</li>
<li>Now in the Navigator you should find your flex project, and in the libs folder add the FontsLibrary.swc.</li>
<li>Look at the code below for  index.mxml where during the project initialization the fonts are registered and can be used as fontNames for labels or text.</li>
</ol>
<pre class="java">
import com.thepixelcode.fonts.*;

//Registering fonts embedded in FontsLibrary.swc during initialization

public function init():void {

Font.registerFont(com.thepixelcode.fonts.EmbedGoudyTwenty);
Font.registerFont(com.thepixelcode.fonts.EmbedKomika);
Font.registerFont(com.thepixelcode.fonts.EmbedMothproof);
Font.registerFont(com.thepixelcode.fonts.EmbedSensation);

}</pre>
<p>You can find the source code below to try and test, there are other ways to register the font, but would simply increase code or add would need to add CSS definitions for styles. </p>
<p><a href='http://www.thepixelcode.com/wp-content/uploads/2009/07/SampleTestFont.zip'>SampleTestFont Source Zip</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.thepixelcode.com/development/flex/embedding-fonts-for-flex-in-swc/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Comparing RTMP and RTMFP protocols</title>
		<link>http://www.thepixelcode.com/development/flash/comparing-rtmp-and-rtmfp-protocols</link>
		<comments>http://www.thepixelcode.com/development/flash/comparing-rtmp-and-rtmfp-protocols#comments</comments>
		<pubDate>Sat, 27 Jun 2009 08:56:21 +0000</pubDate>
		<dc:creator>Mohammed Khan</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[RTMFP]]></category>
		<category><![CDATA[RTMP]]></category>
		<category><![CDATA[Adobe Flash Media Server]]></category>
		<category><![CDATA[Adobe Stratus]]></category>
		<category><![CDATA[Cocomo]]></category>
		<category><![CDATA[FMS]]></category>

		<guid isPermaLink="false">http://www.thepixelcode.com/?p=53</guid>
		<description><![CDATA[Its interesting to see how Adobe has been evolving the protocols required for collaborative apps. In recent years Real Time Messaging Protocol (RTMP) has dominated live content delivery product markets. Flash Media Server and other open source media servers relied on RTMP for streaming audio and video content, and also to create collaborative apps. But [...]]]></description>
			<content:encoded><![CDATA[<p>Its interesting to see how Adobe has been evolving the protocols required for collaborative apps. In recent years <strong>Real Time Messaging Protocol (RTMP)</strong> has dominated live content delivery product markets. Flash Media Server and other open source media servers relied on RTMP for streaming audio and video content, and also to create collaborative apps. But there was a constraint while using RTMP protocol for collaborative apps, all clients involved in the conversation had to fetch feeds from the streaming server, they couldn&#8217;t directly connect to each other to interact. The answer to this concern again came out from Adobe, they released the <strong>Real Time Media Flow Protocol (RTMFP) </strong>specification for Peer to Peer communication (P2P). </p>
<p>As I was discussing with my team at office today about collaborative apps, and when I asked &#8220;Does someone know here about RTMFP ?&#8221;, SOMEONE popped up &#8220;Its an upcoming extension to the RTMP protocol&#8221;. I had to hold on and say &#8220;Vinay I don&#8217;t think its an extension to RTMP but instead its a communication standard for a whole different breed of apps&#8221;. So after getting back to home, I thought it would be interesting if I could put up a blog post that differentiates out RTMP and RTMFP. So here is what I feel are the differences :</p>
<p><strong>1.</strong> Looking at the specifications of RTMP and RTMFP (as they are open source now), the first observation is in the underlying transport layer protocols that RTMP and RTMFP use. RTMP uses the <strong>Transmission Control Protocol (TCP)</strong>, where as the RTMFP uses the <strong>User Datagram Protocol (UDP)</strong>. With the above highlight, it would be necessary to look at TCP and UDP to understand the what RTMP and RTMFP offers. </p>
<p>As we know TCP is the most commonly used protocol on the Internet. The reason for this is because TCP offers error correction. When the TCP protocol is used there is a &#8220;guaranteed delivery.&#8221; This is due largely in part to a method called &#8220;flow control.&#8221; Flow control determines when data needs to be re-sent, and stops the flow of data until previous packets are successfully transferred. This works because if a packet of data is sent, a collision may occur. When this happens, the client re-requests the packet from the server until the whole packet is complete and is identical to its original. </p>
<p>On other side UDP (User Datagram Protocol) is another commonly used protocol on the Internet. However, UDP is never used to send important data such as webpages, database information, etc; UDP is commonly used for streaming audio and video. Streaming media such as Windows Media audio files (.WMA) , Real Player (.RM), and others use UDP because it offers speed! The reason UDP is faster than TCP is because there is no form of flow control or error correction. The data sent over the Internet is affected by collisions, and errors will be present. Remember that UDP is only concerned with speed. This is the main reason why streaming media is not high quality.</p>
<p>Well if UDP is not suitable for streaming media, then why is chosen for RTMFP ? To answer this lets look at a scenario, if I am gonna use the TCP protocol for streaming audio and during transmission a 300ms audio was lost, then as per the mechanism, the media server will reinitiate the streaming from start. This would get painful if each time some data is lost. This is reason why UDP is used, even if I loose the 300ms audio, the gap is not that large that I have to start over again, so the drop packets are compromised and I get the whole data packet.</p>
<p><strong>2.</strong> Communication model when using RTMP and RTMFP is different, when using RTMP, clients when needed to interact with each other has to route messages through the Flash Media Server, which means that a direct connection between the user&#8217;s flash players cannot be made. But with RTMFP the scenario is different, because the protocol has been designed to build collaborative apps, Adobe made it possible for individual Flash Player clients to connect with each other and pass messages while maintaining the session with the media server or the Adobe Stratus service. Below figures, illustrate the two different communication models.</p>
<div id="attachment_52" class="wp-caption alignnone" style="width: 310px"><a href="http://www.thepixelcode.com/wp-content/uploads/2009/06/RTMFP-Communicatio-Model.png"><img src="http://www.thepixelcode.com/wp-content/uploads/2009/06/RTMFP-Communicatio-Model-300x222.png" alt="RTMFP Communication Model" title="RTMFP-Communicatio-Model.png" width="300" height="222" class="size-medium wp-image-52" /></a><p class="wp-caption-text">RTMFP Communication Model</p></div>
<div id="attachment_51" class="wp-caption alignnone" style="width: 310px"><a href="http://www.thepixelcode.com/wp-content/uploads/2009/06/RTMP-Communication-Model.png"><img src="http://www.thepixelcode.com/wp-content/uploads/2009/06/RTMP-Communication-Model-300x222.png" alt="RTMP Communication Model" title="RTMP-Communication-Model.png" width="300" height="222" class="size-medium wp-image-51" /></a><p class="wp-caption-text">RTMP Communication Model</p></div>
<p><strong>3.</strong> Bandwidth consumption is much better when using RTMFP as it avoids much of the client-server communication for inter-client communications as it prevails in the RTMP implementation. </p>
<p><strong>4.</strong> Security and firewall restrictions are always part of the application design considerations, RTMFP fails to impress at this point, because most of the firewalls implemented in corporates are not UDP port friendly. So when RTMFP and RTMP are to be considered, the implementation considerations are always different for both the protocols.</p>
<p><strong>5.</strong> RTMFP cannot be used for broadcasting high quality live video or swarming, it can only connect and stream live audio and webcam, whereas the RTMP can be used to stream high quality video, audio and webcam (from different sources).</p>
<p>In coming time the RTMFP protocol, I feel would evolve the way P2P or C2C applications are built using a common communication framework. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.thepixelcode.com/development/flash/comparing-rtmp-and-rtmfp-protocols/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
