<?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>Alekkus » Empowering social media with Flash &#187; Tutorials</title>
	<atom:link href="http://alekkus.com/blog/category/tutorials/feed/" rel="self" type="application/rss+xml" />
	<link>http://alekkus.com/blog</link>
	<description>flex consultant + social media specialist</description>
	<lastBuildDate>Wed, 17 Mar 2010 07:54:54 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Flex tutorial: Enabling track pad (mouse wheel) scrolling on Mac OS X for Flex 4</title>
		<link>http://alekkus.com/blog/2010/03/flex-tutorial-enabling-track-pad-mouse-wheel-scrolling-on-mac-os-x-for-flex-4/</link>
		<comments>http://alekkus.com/blog/2010/03/flex-tutorial-enabling-track-pad-mouse-wheel-scrolling-on-mac-os-x-for-flex-4/#comments</comments>
		<pubDate>Wed, 17 Mar 2010 07:54:54 +0000</pubDate>
		<dc:creator>Alekkus</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Flex 4 (Gumbo)]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[scroll]]></category>

		<guid isPermaLink="false">http://alekkus.com/blog/?p=300</guid>
		<description><![CDATA[It&#8217;s been quite a while since I last worked on Flex after I became a Web Evangelist at Microsoft where I&#8217;m spending most of my time working on Silverlight (a very awesome technology too). Recently, I was working on a pet project using Flex 4 (to keep up with my Flex skill), and sadly despite [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been quite a while since I last worked on Flex after I became a <a href="http://sg.linkedin.com/in/alekkus">Web Evangelist</a> at Microsoft where I&#8217;m spending most of my time working on <a href="http://silverlight.net/">Silverlight</a> (a very awesome technology too). Recently, I was working on a pet project using Flex 4 (to keep up with my Flex skill), and sadly despite all the new features, mouse wheel/track pad scrolling on the Mac OS is still not supported out-of-the-box. All the <a href="http://www.impossibilities.com/v4/2009/03/06/flash-mousewheel-implementations-for-mac-os-x/">previous implementations</a> by the Flash community doesn&#8217;t work on Flex 4 if you using the viewport approach introduced in the new version. So I decided to modify the codes in my <a href="http://alekkus.com/blog/2009/02/flex-tutorial-enabling-track-pad-or-mouse-wheel-scrolling-on-mac-os-x/">previous post</a>, and here you go&#8230; : )</p>
<p><strong>Demo/Source codes:</strong><br />
<a href="http://alekkus.com/flex4/osx_mouse_wheel.html">Trackpad/Mousewheel Scrolling on Mac for Flex 4</a> (view source is enabled&#8230;.because sharing is caring)</p>
<p>I also took an extra to tweak the scrolling speed for various browser&#8230; let me know if it&#8217;s not working well in a particular browser.</p>
]]></content:encoded>
			<wfw:commentRss>http://alekkus.com/blog/2010/03/flex-tutorial-enabling-track-pad-mouse-wheel-scrolling-on-mac-os-x-for-flex-4/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Flex tutorial: Convert unicode (UTF16) to text, and vice verse</title>
		<link>http://alekkus.com/blog/2009/02/flex-tutorial-convert-unicodes-to-text-and-vice-verse/</link>
		<comments>http://alekkus.com/blog/2009/02/flex-tutorial-convert-unicodes-to-text-and-vice-verse/#comments</comments>
		<pubDate>Fri, 27 Feb 2009 06:30:52 +0000</pubDate>
		<dc:creator>Alekkus</dc:creator>
				<category><![CDATA[Flex 3 (Moxie)]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[unicode]]></category>

		<guid isPermaLink="false">http://alekkus.com/blog/?p=206</guid>
		<description><![CDATA[In contrary to most mashup api services that uses UTF8, Twitter returns non-Latin characters encoded in UTF16. After googling, seems like many people have issues with converting UTF16 encoded characters to proper text and vice verse. There might be other better ways, but here&#8217;s what I have done. Feel free to comment.
A UTF converter that [...]]]></description>
			<content:encoded><![CDATA[<p>In contrary to most mashup api services that uses UTF8, Twitter returns non-Latin characters encoded in UTF16. After googling, seems like many people have issues with converting UTF16 encoded characters to proper text and vice verse. There might be other better ways, but here&#8217;s what I have done. Feel free to comment.</p>
<p>A UTF converter that I always used is <a href="http://macchiato.com/unicode/convert.html">this</a>.</p>
<p><strong>Demo:</strong><br />
<a href="http://alekkus.com/flex3/unicode_converter.html">Unicode Converter </a> (view source enabled)</p>
<p><strong>Source Codes</strong><br />
Right-click on application to view source.</p>
]]></content:encoded>
			<wfw:commentRss>http://alekkus.com/blog/2009/02/flex-tutorial-convert-unicodes-to-text-and-vice-verse/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Flex tutorial: Popup warning before browser closes</title>
		<link>http://alekkus.com/blog/2009/02/flex-tutorial-popup-warning-before-browser-closes/</link>
		<comments>http://alekkus.com/blog/2009/02/flex-tutorial-popup-warning-before-browser-closes/#comments</comments>
		<pubDate>Mon, 16 Feb 2009 07:10:40 +0000</pubDate>
		<dc:creator>Alekkus</dc:creator>
				<category><![CDATA[Flex 3 (Moxie)]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://alekkus.com/blog/?p=166</guid>
		<description><![CDATA[As the title implies, this post will show you how to ask for user confirmation before the browser window closes or navigated away from the current url.
We will make use of the onbeforeunload event in javascript. So first of all, you will need to insert the following into index.template.html.


&#60;script language=&#34;JavaScript&#34; type=&#34;text/javascript&#34;&#62;
window.onbeforeunload = function()
{
	var swfApp = [...]]]></description>
			<content:encoded><![CDATA[<p>As the title implies, this post will show you how to ask for user confirmation before the browser window closes or navigated away from the current url.</p>
<p>We will make use of the <em>onbeforeunload</em> event in javascript. So first of all, you will need to insert the following into <em>index.template.html</em>.</p>
<pre name="code" class="html">

&lt;script language=&quot;JavaScript&quot; type=&quot;text/javascript&quot;&gt;
window.onbeforeunload = function()
{
	var swfApp = ${application};

	return swfApp.onCloseApplication();
}
&lt;/script&gt;
</pre>
<p>The all you need is to add a callback function <em>onCloseApplication</em> in your main application (see codes below).</p>
<p><strong>Demo:</strong><br />
<a href="http://alekkus.com/flex3/exit_warning.html">Application Exit Warning</a> (view source enabled)</p>
<p><strong>Source Codes: main application</strong></p>
<pre name="code" class="as3">

&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;mx:Application
	xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;
	layout=&quot;absolute&quot;
	backgroundColor=&quot;#F8F8F8&quot;
	creationComplete=&quot;onCreationComplete()&quot;&gt;

&lt;mx:Script&gt;
&lt;![CDATA[
	private function onCreationComplete() : void
	{
		if ( ExternalInterface.available )
		{
			ExternalInterface.addCallback( &quot;onCloseApplication&quot;,
				function():String
				{
					if ( chkDisplayMessage.selected )
					{
						return txtMsg.text;
					}
					return null;
				} );
		}
	}
]]&gt;
&lt;/mx:Script&gt;

	&lt;mx:CheckBox
		id=&quot;chkDisplayMessage&quot;
		x=&quot;37&quot; y=&quot;29&quot;
		label=&quot;Display message upon application exit&quot;/&gt;

	&lt;mx:Label x=&quot;37&quot; y=&quot;59&quot; text=&quot;Message:&quot;/&gt;

	&lt;mx:TextInput
		id=&quot;txtMsg&quot;
		x=&quot;104&quot; y=&quot;57&quot;
		text=&quot;Please don&#039;t close me.&quot;/&gt;

	&lt;mx:Label x=&quot;37&quot; y=&quot;107&quot; color=&quot;#666666&quot; text=&quot;*Check on the above checkbox, then close/navigate away from the current url.&quot;/&gt;
&lt;/mx:Application&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://alekkus.com/blog/2009/02/flex-tutorial-popup-warning-before-browser-closes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex tutorial: Setting tile image as background</title>
		<link>http://alekkus.com/blog/2009/02/flex-tutorial-setting-tile-image-as-background/</link>
		<comments>http://alekkus.com/blog/2009/02/flex-tutorial-setting-tile-image-as-background/#comments</comments>
		<pubDate>Sun, 08 Feb 2009 17:16:33 +0000</pubDate>
		<dc:creator>Alekkus</dc:creator>
				<category><![CDATA[Flex 3 (Moxie)]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[background]]></category>
		<category><![CDATA[canvas]]></category>
		<category><![CDATA[tile]]></category>

		<guid isPermaLink="false">http://alekkus.com/blog/?p=137</guid>
		<description><![CDATA[This tutorial shows you how to fill a Canvas background with repeated images. We will make use of the BitmapData.draw() function to achieve this. Note that if the image to be repeated is from another domain (i.e. a cross domain image), you have to ensure that the domain has a cross domain policy file, and [...]]]></description>
			<content:encoded><![CDATA[<p>This tutorial shows you how to fill a Canvas background with repeated images. We will make use of the BitmapData.draw() function to achieve this. Note that if the image to be repeated is from another domain (i.e. a cross domain image), you have to ensure that the domain has a cross domain policy file, and you have to set checkPolicyFile=true in order to get it working. Otherwise, you will get a security sandbox error. More explanation <a href="http://www.abdulqabiz.com/blog/archives/flash_and_actionscript/enabling_bitmapdatad.php">here</a>. </p>
<p><strong>Demo:</strong><br />
<a href="http://alekkus.com/flex3/tile_image_background.html">Tile Image Background</a> (view source enabled)</p>
<p><strong>Source Codes: main application</strong></p>
<pre name="code" class="as3">

&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;mx:Application
	xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;
	xmlns:alekkus=&quot;com.alekkus.*&quot;
	layout=&quot;absolute&quot;
	backgroundColor=&quot;#F8F8F8&quot;&gt;

&lt;mx:Script&gt;
  &lt;![CDATA[
  	import mx.controls.Image;

	private function onClick() : void
	{
		// 1. for crossdomain images, we need to create a LoaderContext object and set its checkPolicyFile to true.
		var loaderContext : LoaderContext = new LoaderContext ();
		loaderContext.checkPolicyFile = true;

		// 2. assign that loaderContext object to an Image object
		var image : Image =  new Image();
		image.loaderContext =  loaderContext;

		// 3. set source and load
		image.source = &quot;http://alekkus.com/flex3/extra/images/duck.jpg&quot;
		image.addEventListener( Event.COMPLETE, onImageLoaded  );
		image.load();
	}

	private function onImageLoaded( event : Event ) : void
	{
		var image : Image = Image( event.currentTarget );

		// 1. set as tile image background
		cvsMain.setTileImage( image );
	}

  ]]&gt;
&lt;/mx:Script&gt;

	&lt;alekkus:TileImageCanvas id=&quot;cvsMain&quot; width=&quot;100%&quot; height=&quot;100%&quot; /&gt;
	&lt;mx:Button x=&quot;10&quot; y=&quot;10&quot; label=&quot;Set background as tile image&quot; click=&quot;onClick()&quot; /&gt;

&lt;/mx:Application&gt;
</pre>
<p><strong>Source Codes: TileImageCanvas class</strong></p>
<pre name="code" class="as3">

&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;mx:Canvas
	xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;&gt;

&lt;mx:Script&gt;
&lt;![CDATA[
	import mx.controls.Image;

	private var _image : Image = null;

	public function setTileImage( image : Image ) : void
	{
		this._image = image;
		this.invalidateDisplayList();
	}

    override protected function updateDisplayList( unscaledWidth : Number, unscaledHeight : Number ) : void
    {
        super.updateDisplayList(unscaledWidth, unscaledHeight );

        if ( _image != null )
        {
	        var bitmap : Bitmap = Bitmap( _image.content );
	        var bitmapData : BitmapData = new BitmapData( bitmap.width, bitmap.height );
	        bitmapData.draw( bitmap );      

	        graphics.clear();
	        graphics.beginBitmapFill( bitmapData );
	        graphics.drawRect(0, 0, unscaledWidth, unscaledHeight);
	        graphics.endFill();
	    }
    }
]]&gt;
&lt;/mx:Script&gt;
&lt;/mx:Canvas&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://alekkus.com/blog/2009/02/flex-tutorial-setting-tile-image-as-background/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Flex tutorial: Enabling track pad or mouse wheel scrolling on Mac OS X</title>
		<link>http://alekkus.com/blog/2009/02/flex-tutorial-enabling-track-pad-or-mouse-wheel-scrolling-on-mac-os-x/</link>
		<comments>http://alekkus.com/blog/2009/02/flex-tutorial-enabling-track-pad-or-mouse-wheel-scrolling-on-mac-os-x/#comments</comments>
		<pubDate>Thu, 05 Feb 2009 07:03:31 +0000</pubDate>
		<dc:creator>Alekkus</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Flex 3 (Moxie)]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[scroll]]></category>

		<guid isPermaLink="false">http://alekkus.com/blog/?p=104</guid>
		<description><![CDATA[A couple of months back when Steve Jobs announced the new unibody MacBook Pro, I couldn&#8217;t resist and decided to switched to Mac. As I was settling in to the new OS, I was surprised when I learned that Flex applications do not support track pad (or mouse wheel) scrolling on the Mac OS X. [...]]]></description>
			<content:encoded><![CDATA[<p>A couple of months back when Steve Jobs announced the new <a href="http://www.apple.com/macbookpro/">unibody MacBook Pro</a>, I couldn&#8217;t resist and decided to switched to Mac. As I was settling in to the new OS, I was surprised when I learned that Flex applications do not support track pad (or mouse wheel) scrolling on the Mac OS X. This <a href="http://bugs.adobe.com/jira/browse/SDK-14771">issue</a> has been filed in the Adobe bug system, but they have yet to resolved it.</p>
<p>Good news is, <a href="http://blog.pixelbreaker.com/flash/swfmacmousewheel/">Gabriel Bucknall</a> has came out with an elegant solution. It&#8217;s built upon SWFObject, basically a small Javascript file used to embed Flash content (read my post on using SWFObject to embed Flash content <a href="http://alekkus.com/blog/2009/02/flex-tutorial-embedding-flash-content-with-swfobject-2/">here</a>).</p>
<p>Here&#8217;s what you need to get it working using Flex Builder:</p>
<ul>
<li>Embed your Flash content using the SWFObject method. (see <a href="http://alekkus.com/blog/2009/02/flex-tutorial-embedding-flash-content-with-swfobject-2/">previous post</a>)
<li>Include &#8220;swfmacmousewheel2.js&#8221; file into the &#8220;html-template&#8221; folder </li>
<li>Replace the codes within &#8220;index.template.html&#8221; file with the codes below</li>
<li>Lastly, in your application add the line &#8220;MacMouseWheel.setup( this.stage );&#8221; within the application&#8217;s addedToStage event listener
</ul>
<p><strong>Note:</strong> If are trying this out on your local machine, you may get a security sandbox violation error #2060. You need to deploy it on a local/remote web server to get it working. I can&#8217;t find a way to get around this. Tried including crossdomain policy file, changing the params value when embedding, and tweaking the compiler options but to no luck. Let me know if anyone found a solution to this.</p>
<p><strong>Demo:</strong><br />
<a href="http://alekkus.com/flex3/mac_scrolling.html">Trackpad/Mousewheel Scrolling on Mac</a> (view source enabled)</p>
<p><strong>Source Codes: index.template.html</strong></p>
<pre name="code" class="html">

&lt;!-- saved from url=(0014)about:internet --&gt;
&lt;html lang=&quot;en&quot;&gt;

&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;history/history.css&quot; /&gt;
&lt;title&gt;${title}&lt;/title&gt;
&lt;script src=&quot;AC_OETags.js&quot; language=&quot;javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;history/history.js&quot; language=&quot;javascript&quot;&gt;&lt;/script&gt;

&lt;style&gt;
body { margin: 0px; overflow:hidden }
&lt;/style&gt;

&lt;/head&gt;

&lt;body scroll=&quot;no&quot;&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;swfobject.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;swfmacmousewheel2.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;

	var flashVars = {};

	var params = { play: &quot;true&quot;,
				   loop: &quot;false&quot;,
				   quality: &quot;high&quot;,
				   wmode: &quot;window&quot;,
				   allowscriptaccess: &quot;sameDomain&quot; };

	var attributes = { id: &quot;${application}&quot; };

	swfobject.embedSWF( &quot;${swf}.swf&quot;,
						&quot;divContent&quot;,
						&quot;100%&quot;, &quot;100%&quot;,
						&quot;9.0.0&quot;,
						&quot;expressInstall.swf&quot;,
						flashVars,
						params,
						attributes );

	swfmacmousewheel.registerObject( attributes.id );

&lt;/script&gt;

&lt;div id=&quot;divContent&quot;&gt;
	&lt;h1&gt;Alternative content&lt;/h1&gt;
	&lt;p&gt;&lt;a href=&quot;http://www.adobe.com/go/getflashplayer&quot;&gt;&lt;img src=&quot;http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif&quot; alt=&quot;Get Adobe Flash player&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p><strong>Source Codes: main application</strong></p>
<pre name="code" class="as3">

&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;mx:Application
	xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;
	layout=&quot;absolute&quot;
	backgroundColor=&quot;#F8F8F8&quot;
	addedToStage=&quot;onAddedToStage()&quot;&gt;

&lt;mx:Script&gt;
&lt;![CDATA[
	import com.pixelbreaker.ui.osx.MacMouseWheel;

	private function onAddedToStage() : void
    {
        if ( this.stage != null )
        {
        	MacMouseWheel.setup( this.stage );
        }
    }
]]&gt;
&lt;/mx:Script&gt;

	&lt;mx:Canvas x=&quot;28&quot; y=&quot;26&quot; width=&quot;239&quot; height=&quot;332&quot; backgroundColor=&quot;#C6DFF6&quot;&gt;
		&lt;mx:Text
			x=&quot;10&quot; y=&quot;10&quot;
			width=&quot;201&quot;
			text=&quot;The quick brown fox jumps over the lazy dog quick brown fox jumps over the lazy dog..... and then, the quick brown fox jumps over the lazy dog....and then, the quick brown fox jumps over the lazy dog....and then, the quick brown fox jumps over the lazy dog....and then, the quick brown fox jumps over the lazy dog....and then, the quick brown fox jumps over the lazy dog....and then, the quick brown fox jumps over the lazy dog....and then, the quick brown fox jumps over the lazy dog....and then, the quick brown fox jumps over the lazy dog....and then, the quick brown fox jumps over the lazy dog&quot;
			fontSize=&quot;18&quot;/&gt;
	&lt;/mx:Canvas&gt;
	&lt;mx:Label x=&quot;28&quot; y=&quot;366&quot; text=&quot;Place your cursor within the canvas and scroll using the mouse wheel or trackpad.&quot; fontSize=&quot;12&quot;/&gt;
&lt;/mx:Application&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://alekkus.com/blog/2009/02/flex-tutorial-enabling-track-pad-or-mouse-wheel-scrolling-on-mac-os-x/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Flex tutorial: Embedding Flash content with SWFObject 2</title>
		<link>http://alekkus.com/blog/2009/02/flex-tutorial-embedding-flash-content-with-swfobject-2/</link>
		<comments>http://alekkus.com/blog/2009/02/flex-tutorial-embedding-flash-content-with-swfobject-2/#comments</comments>
		<pubDate>Wed, 04 Feb 2009 13:16:34 +0000</pubDate>
		<dc:creator>Alekkus</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex 3 (Moxie)]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[SWFObject]]></category>

		<guid isPermaLink="false">http://alekkus.com/blog/?p=109</guid>
		<description><![CDATA[If you are building your Flash content with Flex Builder 3 or Flash CS3, you will see that both came with a default HTML template that provides a way to embed your compiled SWF file. Although there&#8217;s nothing wrong with that way of doing it, SWFObject seems to be a better way (the author&#8217;s explanation [...]]]></description>
			<content:encoded><![CDATA[<p>If you are building your Flash content with Flex Builder 3 or Flash CS3, you will see that both came with a default HTML template that provides a way to embed your compiled SWF file. Although there&#8217;s nothing wrong with that way of doing it, <a href="http://code.google.com/p/swfobject/">SWFObject</a> seems to be a better way (the author&#8217;s explanation is <a href="http://blog.deconcept.com/swfobject/#whyitsbetter">here</a>). In fact in the CS4 release, Adobe has <a href="http://theflashblog.com/?p=406">made this the standard way</a> of embedding Flash content. </p>
<p>To manually work with SWFObject in Flex Builder, replace the codes in &#8220;html-template/index.template.html&#8221; with the codes below. Then place the following files into the &#8220;html-template&#8221; folder. </p>
<ul>
<li>swfobject.js</li>
<li>expressInstall.swf</li>
</ul>
<p>The files are available <a href="http://code.google.com/p/swfobject/">here</a>, or you can download the my source files to get those files.</p>
<p><strong>[update]</strong> If you are using Flex SDK 3.1 and below, deep linking (more specifically, the BrowserManager class) may not work with SWFObject. If that happens, simply replace the codes in the &#8220;history.js&#8221; file with <a href="http://alekkus.com/flex3/extra/history.js">this</a></p>
<p><strong>Demo:</strong><br />
<a href="http://alekkus.com/flex3/swfobject2.html">SWFObject 2</a> (view source enabled)</p>
<p><strong>Source Codes:</strong></p>
<pre name="code" class="html">

&lt;!-- saved from url=(0014)about:internet --&gt;
&lt;html lang=&quot;en&quot;&gt;

&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;history/history.css&quot; /&gt;
&lt;title&gt;${title}&lt;/title&gt;
&lt;script src=&quot;AC_OETags.js&quot; language=&quot;javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;history/history.js&quot; language=&quot;javascript&quot;&gt;&lt;/script&gt;

&lt;style&gt;
body { margin: 0px; overflow:hidden }
&lt;/style&gt;

&lt;/head&gt;

&lt;body scroll=&quot;no&quot;&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;swfobject.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;

	var flashVars = {};

	var params = { play: &quot;true&quot;,
				   loop: &quot;false&quot;,
				   quality: &quot;high&quot;,
				   wmode: &quot;window&quot;,
				   allowscriptaccess: &quot;sameDomain&quot; };

	var attributes = { id: &quot;${application}&quot; };

	swfobject.embedSWF( &quot;${swf}.swf&quot;,
						&quot;divContent&quot;,
						&quot;100%&quot;, &quot;100%&quot;,
						&quot;9.0.0&quot;,
						&quot;expressInstall.swf&quot;,
						flashVars,
						params,
						attributes );
&lt;/script&gt;

&lt;div id=&quot;divContent&quot;&gt;
	&lt;h1&gt;Alternative content&lt;/h1&gt;
	&lt;p&gt;&lt;a href=&quot;http://www.adobe.com/go/getflashplayer&quot;&gt;&lt;img src=&quot;http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif&quot; alt=&quot;Get Adobe Flash player&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://alekkus.com/blog/2009/02/flex-tutorial-embedding-flash-content-with-swfobject-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex tutorial: URL-based navigation using Deep Linking</title>
		<link>http://alekkus.com/blog/2009/02/flex-tutorial-url-based-navigation-using-deep-linking/</link>
		<comments>http://alekkus.com/blog/2009/02/flex-tutorial-url-based-navigation-using-deep-linking/#comments</comments>
		<pubDate>Tue, 03 Feb 2009 03:41:54 +0000</pubDate>
		<dc:creator>Alekkus</dc:creator>
				<category><![CDATA[Flex 3 (Moxie)]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[BrowserManager]]></category>
		<category><![CDATA[deeplinking]]></category>

		<guid isPermaLink="false">http://alekkus.com/blog/?p=95</guid>
		<description><![CDATA[One of the best new features in Flex 3 is Deep Linking. By default, a Flex application is accessible via one URL; that poses several limitations on the users. Firstly, the browser back/forward buttons no longer works the usual way. Secondly, consider an ecommerce site, if a user wants to show his/her friends a particular [...]]]></description>
			<content:encoded><![CDATA[<p>One of the best new features in Flex 3 is Deep Linking. By default, a Flex application is accessible via one URL; that poses several limitations on the users. Firstly, the browser back/forward buttons no longer works the usual way. Secondly, consider an ecommerce site, if a user wants to show his/her friends a particular product information, he/she can no longer simply give out the url, as the the url will always show the default state/page of the application.</p>
<p>The following shows you how to solve these issues by using the BrowserManager class.</p>
<p><strong>Demo:</strong><br />
<a href="http://alekkus.com/flex3/deep_linking.html">Deep Linking</a> (view source enabled)</p>
<p><strong>Source Codes:</strong></p>
<pre name="code" class="as3">

&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;mx:Application
	xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;
	layout=&quot;absolute&quot;
	backgroundColor=&quot;#F8F8F8&quot;
	creationComplete=&quot;onCreationComplete()&quot;&gt;

&lt;mx:Script&gt;
&lt;![CDATA[
	import mx.events.ItemClickEvent;
	import mx.containers.Canvas;
	import mx.events.BrowserChangeEvent;
	import mx.managers.BrowserManager;
	import mx.managers.IBrowserManager;

	private var _browserManager : IBrowserManager = null;

	private function onCreationComplete() : void
	{
		// 1. add browserManager event listeners here
		_browserManager = BrowserManager.getInstance();
        _browserManager.addEventListener( BrowserChangeEvent.BROWSER_URL_CHANGE, onURLChange ); 		//dispatch when user typed into addr bar
		_browserManager.addEventListener( BrowserChangeEvent.APPLICATION_URL_CHANGE, onURLChange ); 	//necessary to update the url in address bar when gotoURL called has a same base url, orignially used to dispatch when setFragment is called although not use for that purpose. now setFragent is used again.
        _browserManager.init( &quot;&quot; );  

		// 2. explicitly call process url if fragment is empty when loaded
        if ( _browserManager.fragment == &quot;&quot; )
        {
        	onURLChange();
        }
	}

	 private function onURLChange( event:BrowserChangeEvent = null ) : void
  	{
  		switch ( _browserManager.fragment.toLowerCase() )
  		{
  			case &quot;about&quot;:
  			{
  				_browserManager.setTitle( &quot;About us | Alekkus.com&quot; );
  				vsMain.selectedIndex = 1;
  				break;
  			}
  			case &quot;contact&quot;:
  			{
  				_browserManager.setTitle( &quot;Contact us | Alekkus.com&quot; );
  				vsMain.selectedIndex = 2;
  				break;
  			}
  			default:
  			{
  				_browserManager.setTitle( &quot;Home | Alekkus.com&quot; );
  				vsMain.selectedIndex = 0;
  			}
  		}
  	}

  	private function onChildIndexChange( event : ItemClickEvent ) : void
  	{
  		var canvasLabel : String = Canvas( vsMain.getChildAt( event.index ) ).label;

  		_browserManager.setFragment( canvasLabel.toLowerCase() );
  	}
]]&gt;
&lt;/mx:Script&gt;

	&lt;mx:LinkBar x=&quot;10&quot; y=&quot;10&quot; dataProvider=&quot;{ vsMain }&quot; itemClick=&quot;onChildIndexChange( event )&quot;/&gt;

	&lt;mx:ViewStack
		id=&quot;vsMain&quot;
		x=&quot;0&quot; y=&quot;36&quot;
		width=&quot;252&quot; height=&quot;177&quot;&gt;

		&lt;!-- Home --&gt;
		&lt;mx:Canvas
			label=&quot;Home&quot;
			width=&quot;100%&quot; height=&quot;100%&quot;&gt;

			&lt;mx:Label text=&quot;Home page&quot; x=&quot;10&quot; y=&quot;10&quot; fontSize=&quot;28&quot;/&gt;
		&lt;/mx:Canvas&gt;

		&lt;!-- About us --&gt;
		&lt;mx:Canvas
			label=&quot;About&quot;
			width=&quot;100%&quot; height=&quot;100%&quot;&gt;

			&lt;mx:Label text=&quot;About us&quot; x=&quot;10&quot; y=&quot;10&quot; fontSize=&quot;28&quot;/&gt;
		&lt;/mx:Canvas&gt;

		&lt;!-- Contact us --&gt;
		&lt;mx:Canvas
			label=&quot;Contact&quot;
			width=&quot;100%&quot; height=&quot;100%&quot;&gt;

			&lt;mx:Label text=&quot;Contact us&quot; x=&quot;10&quot; y=&quot;10&quot; fontSize=&quot;28&quot;/&gt;
		&lt;/mx:Canvas&gt;
	&lt;/mx:ViewStack&gt;

	&lt;!-- Instructions --&gt;
	&lt;mx:Label x=&quot;10&quot; y=&quot;224&quot; text=&quot;*Notice that the url changes when you navigate thru different pages.&quot;/&gt;
	&lt;mx:Label x=&quot;10&quot; y=&quot;250&quot; text=&quot;*You can also use the browser back/forward button to navigate.&quot;/&gt;
	&lt;mx:Label x=&quot;10&quot; y=&quot;276&quot; text=&quot;*Manually typing in the url also works. e.g. .http://alekkus.com/...#contact&quot;/&gt;

&lt;/mx:Application&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://alekkus.com/blog/2009/02/flex-tutorial-url-based-navigation-using-deep-linking/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Flex tutorial: Resizable window</title>
		<link>http://alekkus.com/blog/2009/02/flex-tutorial-resizable-window/</link>
		<comments>http://alekkus.com/blog/2009/02/flex-tutorial-resizable-window/#comments</comments>
		<pubDate>Sun, 01 Feb 2009 07:04:44 +0000</pubDate>
		<dc:creator>Alekkus</dc:creator>
				<category><![CDATA[Flex 3 (Moxie)]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[transform]]></category>

		<guid isPermaLink="false">http://alekkus.com/blog/?p=55</guid>
		<description><![CDATA[Often, a movable/draggable window is also resizable. The following will show you how to make your customized window resizable.
Demo:
Resizable Window (view source enabled)
Source Codes:


&#60;?xml version=&#34;1.0&#34; encoding=&#34;utf-8&#34;?&#62;
&#60;mx:Application
	xmlns:mx=&#34;http://www.adobe.com/2006/mxml&#34;
	layout=&#34;absolute&#34;
	backgroundColor=&#34;#F8F8F8&#34;&#62;

&#60;mx:Script&#62;
&#60;![CDATA[
	import mx.events.FlexEvent;
	import mx.core.UIComponent;

	private var _window : UIComponent;
	private var _originalWidth : Number;
	private var _originalHeight : Number;
	private var _mouseDownPosition : Point;

	private function onResizeMouseDown( event : MouseEvent ) : void
	{
		// 1. set _window
		_window [...]]]></description>
			<content:encoded><![CDATA[<p>Often, a <a href="http://alekkus.com/blog/2009/01/flex-movable-draggable-window">movable/draggable window</a> is also resizable. The following will show you how to make your customized window resizable.</p>
<p><strong>Demo:</strong><br />
<a href="http://alekkus.com/flex3/resizable_window.html">Resizable Window</a> (view source enabled)</p>
<p><strong>Source Codes:</strong></p>
<pre name="code" class="as3">

&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;mx:Application
	xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;
	layout=&quot;absolute&quot;
	backgroundColor=&quot;#F8F8F8&quot;&gt;

&lt;mx:Script&gt;
&lt;![CDATA[
	import mx.events.FlexEvent;
	import mx.core.UIComponent;

	private var _window : UIComponent;
	private var _originalWidth : Number;
	private var _originalHeight : Number;
	private var _mouseDownPosition : Point;

	private function onResizeMouseDown( event : MouseEvent ) : void
	{
		// 1. set _window
		_window = UIComponent( UIComponent( event.currentTarget ).parent );

		// 2. add mouse move and mouse up event listeners
		this.systemManager.addEventListener( MouseEvent.MOUSE_MOVE, onResizeMouseMove, true );
		this.systemManager.addEventListener( MouseEvent.MOUSE_UP, onResizeMouseUp, true );									

		// 3. save original width, height, rotation
		_originalWidth = _window.width;
		_originalHeight = _window.height;	

		// 4. save mouse down position
		_mouseDownPosition = new Point( event.stageX, event.stageY );
	}

	private function onResizeMouseMove( event : MouseEvent ) : void
	{
		// 1. prevent any other mouse up events to happen
		event.stopImmediatePropagation();

		// 2. calculate new width, height
		var newWidth:Number = _originalWidth + ( event.stageX - _mouseDownPosition.x );
		var newHeight:Number = _originalHeight + ( event.stageY - _mouseDownPosition.y );			

		// 3. resize window
		_window.setActualSize( newWidth, newHeight );
	}

	private function onResizeMouseUp( event : MouseEvent ) : void
	{
		// 1. prevent any other mouse up events to happen
		event.stopImmediatePropagation();	

		// 2. remove event listeners
		this.systemManager.removeEventListener( MouseEvent.MOUSE_MOVE, onResizeMouseMove, true );
		this.systemManager.removeEventListener( MouseEvent.MOUSE_UP, onResizeMouseUp , true );
	}

	private function doDrawTriangle( event : FlexEvent ) : void
	{
		var uiComp : UIComponent = UIComponent( event.currentTarget );

		uiComp.graphics.clear();
		uiComp.graphics.beginFill( 0xB1DAFA );
		uiComp.graphics.moveTo( uiComp.width, 0 );
		uiComp.graphics.lineTo( uiComp.width, uiComp.height );
		uiComp.graphics.lineTo( 0, uiComp.height );
	}
]]&gt;
&lt;/mx:Script&gt;

	&lt;mx:Canvas
		id=&quot;cvsMain&quot;
		x=&quot;37&quot; y=&quot;31&quot; width=&quot;260&quot; height=&quot;160&quot;
		borderColor=&quot;#999999&quot; backgroundColor=&quot;#FFFFFF&quot; borderStyle=&quot;solid&quot; dropShadowEnabled=&quot;true&quot; borderThickness=&quot;2&quot;
		horizontalScrollPolicy=&quot;off&quot; verticalScrollPolicy=&quot;off&quot;&gt;

		&lt;!-- Resize triangle --&gt;
		&lt;mx:UIComponent
			x=&quot;{ cvsMain.width - 24 }&quot; y=&quot;{ cvsMain.height - 24 }&quot;
			width=&quot;20&quot; height=&quot;20&quot;
			creationComplete=&quot;doDrawTriangle( event )&quot;
			mouseDown=&quot;onResizeMouseDown( event )&quot; /&gt;

		&lt;!-- Instruction --&gt;
		&lt;mx:Label x=&quot;16&quot; y=&quot;59&quot; text=&quot;Drag the blue triangle to resize&quot; fontSize=&quot;14&quot;/&gt;
	&lt;/mx:Canvas&gt;
&lt;/mx:Application&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://alekkus.com/blog/2009/02/flex-tutorial-resizable-window/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex tutorial: Movable/Draggable window</title>
		<link>http://alekkus.com/blog/2009/01/flex-tutorial-movable-draggable-window/</link>
		<comments>http://alekkus.com/blog/2009/01/flex-tutorial-movable-draggable-window/#comments</comments>
		<pubDate>Fri, 30 Jan 2009 07:35:14 +0000</pubDate>
		<dc:creator>Alekkus</dc:creator>
				<category><![CDATA[Flex 3 (Moxie)]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[transform]]></category>

		<guid isPermaLink="false">http://alekkus.com/?p=3</guid>
		<description><![CDATA[My very first assignment as a Flex developer back in 2007 was to create a UI for a web-based instant messaging application. Since a user can open multiple chat windows, I needed to make those windows movable. After Googling I can&#8217;t find any hints, but after some trial and errors, I manage to get it [...]]]></description>
			<content:encoded><![CDATA[<p>My very first assignment as a Flex developer back in 2007 was to create a UI for a web-based instant messaging application. Since a user can open multiple chat windows, I needed to make those windows movable. After Googling I can&#8217;t find any hints, but after some trial and errors, I manage to get it worked. </p>
<p>Recently, someone was asking me about similar issue, so I though I&#8217;d post it here and share with anyone that need this. </p>
<p><strong>Demo:</strong><br />
<a href="http://alekkus.com/flex3/draggable_window.html">Movable Window</a> (view source enabled)</p>
<p><strong>Source Codes:</strong></p>
<pre name="code" class="as3">

&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;mx:Application
	xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;
	layout=&quot;absolute&quot;
	backgroundColor=&quot;#F8F8F8&quot;&gt;

&lt;mx:Script&gt;
&lt;![CDATA[
	import mx.core.UIComponent;

	private var _window : UIComponent;
	private var _originalPosition : Point;
	private var _mouseDownPosition : Point;

	private function onTitleBarMouseDown( event : MouseEvent ) : void
	{
		// 1. set _window
		_window = UIComponent( UIComponent( event.currentTarget ).parent );

		// 2. add mouse move and mouse up event listeners
		this.systemManager.addEventListener( MouseEvent.MOUSE_MOVE, doMoving, true );
		this.systemManager.addEventListener( MouseEvent.MOUSE_UP, doCommitMove, true );									

		// 3. save offsets
		_originalPosition = new Point( _window.x, _window.y );
		_mouseDownPosition = new Point( event.stageX, event.stageY );
	}

	private function doMoving( event : MouseEvent ) : void
	{
		// 1. prevent any other mouse up events to happen
		event.stopImmediatePropagation();

		// 2. calculate new position
		var positionToMove : Point = new Point( _originalPosition.x + ( event.stageX - _mouseDownPosition.x ),
								  		   		_originalPosition.y + ( event.stageY - _mouseDownPosition.y ) );
		// 3. move window
		_window.move( positionToMove.x, positionToMove.y );
	}

	private function doCommitMove( event : MouseEvent ) : void
	{
		// 1. prevent any other mouse up events to happen
		event.stopImmediatePropagation();	

		// 2. remove event listeners
		this.systemManager.removeEventListener( MouseEvent.MOUSE_MOVE, doMoving, true );
		this.systemManager.removeEventListener( MouseEvent.MOUSE_UP, doCommitMove , true );
	}
]]&gt;
&lt;/mx:Script&gt;

	&lt;mx:Canvas
		x=&quot;37&quot; y=&quot;31&quot; width=&quot;245&quot; height=&quot;156&quot;
		borderColor=&quot;#999999&quot; backgroundColor=&quot;#FFFFFF&quot; borderStyle=&quot;solid&quot; dropShadowEnabled=&quot;true&quot; borderThickness=&quot;2&quot;&gt;

		&lt;!-- Title Bar--&gt;
		&lt;mx:Canvas
			x=&quot;0&quot; y=&quot;0&quot; width=&quot;100%&quot; height=&quot;35&quot;
			backgroundColor=&quot;#B1DAFA&quot;
			mouseDown=&quot;onTitleBarMouseDown( event )&quot;&gt;

			&lt;mx:Label x=&quot;10&quot; y=&quot;7&quot; text=&quot;Title&quot; fontSize=&quot;14&quot;/&gt;
		&lt;/mx:Canvas&gt;

		&lt;!-- Instruction --&gt;
		&lt;mx:Label x=&quot;27&quot; y=&quot;73&quot; text=&quot;Drag the title bar to move&quot; fontSize=&quot;14&quot;/&gt;
	&lt;/mx:Canvas&gt;
&lt;/mx:Application&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://alekkus.com/blog/2009/01/flex-tutorial-movable-draggable-window/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
