<?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 Morphic Group &#187; ActionScript</title>
	<atom:link href="http://www.themorphicgroup.com/blog/category/technology/actionscript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.themorphicgroup.com/blog</link>
	<description></description>
	<lastBuildDate>Mon, 22 Feb 2010 18:20:39 +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>Flash Camp St Louis 2009 &#8211; Code Samples</title>
		<link>http://www.themorphicgroup.com/blog/2009/09/13/flash-camp-code-samples/</link>
		<comments>http://www.themorphicgroup.com/blog/2009/09/13/flash-camp-code-samples/#comments</comments>
		<pubDate>Mon, 14 Sep 2009 01:09:51 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[City Museum]]></category>
		<category><![CDATA[Dev]]></category>
		<category><![CDATA[Flash Camp]]></category>
		<category><![CDATA[Flash Camp 2009]]></category>
		<category><![CDATA[Flex Builder]]></category>
		<category><![CDATA[FlexBuilder]]></category>
		<category><![CDATA[FlexBuiler]]></category>
		<category><![CDATA[Jason Hanson]]></category>
		<category><![CDATA[St. Louis]]></category>

		<guid isPermaLink="false">http://www.themorphicgroup.com/blog/?p=272</guid>
		<description><![CDATA[I had a great time presenting at Flash Camp St Louis this last Friday. The City Museum was a great venue. All the other speakers did a great job. Thanks JP for putting together such a great event! Here is the sample code I showed in the presentation. Rt-click and select View Source for the [...]]]></description>
			<content:encoded><![CDATA[<p>I had a great time presenting at Flash Camp St Louis this last Friday.  The City Museum was a great venue.  All the other speakers did a great job.  Thanks JP for putting together such a great event!</p>
<p>Here is the sample code I showed in the presentation.  Rt-click and select View Source for the source.</p>
<p><a href="http://www2.themorphicgroup.com/blog/flashcamp2009/singleton/Singleton_Complete.html">http://www2.themorphicgroup.com/blog/flashcamp2009/singleton/Singleton_Complete.html</a><br />
<a href="http://www2.themorphicgroup.com/blog/flashcamp2009/singleton/srcview/index.html">source</a></p>
<p><a href="http://www2.themorphicgroup.com/blog/flashcamp2009/observer/Observer_Complete.html">http://www2.themorphicgroup.com/blog/flashcamp2009/observer/Observer_Complete.html</a><br />
<a href="http://www2.themorphicgroup.com/blog/flashcamp2009/observer/srcview/index.html">source</a></p>
<p><a href="http://www2.themorphicgroup.com/blog/flashcamp2009/event/Event_Complete.html">http://www2.themorphicgroup.com/blog/flashcamp2009/event/Event_Complete.html</a><br />
<a href="http://www2.themorphicgroup.com/blog/flashcamp2009/observer/srcview/index.html">source</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.themorphicgroup.com/blog/2009/09/13/flash-camp-code-samples/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Flash Camp St. Louis 2009 &#8211; This Friday</title>
		<link>http://www.themorphicgroup.com/blog/2009/09/08/flash-camp-st-louis-2009-this-friday/</link>
		<comments>http://www.themorphicgroup.com/blog/2009/09/08/flash-camp-st-louis-2009-this-friday/#comments</comments>
		<pubDate>Tue, 08 Sep 2009 16:30:28 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Adobe Catalyst]]></category>
		<category><![CDATA[City Museum]]></category>
		<category><![CDATA[Dev]]></category>
		<category><![CDATA[Flash Camp]]></category>
		<category><![CDATA[Flash Camp 2009]]></category>
		<category><![CDATA[Flex Builder]]></category>
		<category><![CDATA[Flex Conference]]></category>
		<category><![CDATA[FlexBuilder]]></category>
		<category><![CDATA[TMG]]></category>

		<guid isPermaLink="false">http://www.themorphicgroup.com/blog/?p=262</guid>
		<description><![CDATA[Two TMG employees presenting at Flash Camp St. Louis this Friday at the City Museum, Ben Bishop and Jason Hanson. Should be a good time. If you are in St. Louis and have any interest in Flash, Flex, or Catalyst think about coming. Tickets still available. www.flashcampstlouis.com]]></description>
			<content:encoded><![CDATA[<p>Two TMG employees presenting at Flash Camp St. Louis this Friday at the City Museum, Ben Bishop and Jason Hanson.</p>
<p>Should be a good time.  If you are in St. Louis and have any interest in Flash, Flex, or Catalyst think about coming.  </p>
<p>Tickets still available.</p>
<p><a href="http://www.flashcampstlouis.com/">www.flashcampstlouis.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.themorphicgroup.com/blog/2009/09/08/flash-camp-st-louis-2009-this-friday/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Use Asynchronous Test Methods with FlexUnit 4</title>
		<link>http://www.themorphicgroup.com/blog/2009/07/15/how-to-use-asynchronous-test-methods-with-flexunit-4/</link>
		<comments>http://www.themorphicgroup.com/blog/2009/07/15/how-to-use-asynchronous-test-methods-with-flexunit-4/#comments</comments>
		<pubDate>Wed, 15 Jul 2009 15:38:54 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.themorphicgroup.com/blog/?p=211</guid>
		<description><![CDATA[An essential part of Agile Development is to embrace the use of unit testing throughout the development of your project. Unit tests give the programmer to ability to run automated tests on their code at anytime to ensure that any refactoring or added code has not broken what was previously written. This luxury is a [...]]]></description>
			<content:encoded><![CDATA[<p>An essential part of  Agile Development  is to embrace the use of unit testing throughout the development of your project. Unit tests give the programmer to ability to run automated tests on their code at anytime to ensure that any refactoring or added code has not broken what was previously written. This luxury is a welcome proposition for many programmers.</p>
<p>However, this has proven to be problematic for Flex developers for a variety of reasons. The first reason is that because Flex/Flash is a presentation tier technology a great deal of testing requires user interaction. Another problem is that  Flex/Flash is a client-side technology and therefore data saving and retrieval is an asynchronous process. In this post, I'm going to cover on how to handle the latter with FlexUnit 4.</p>
<p>With the first implementation of FlexUnit, a programmer could handle an asynchronous test by using a combination of timers and the built in addSync method of FlexUnit. Here's an example pulled from this blog <a href="http://life.neophi.com/danielr/2007/03/asynchronous_testing_with_flex.html" target="_blank">post</a>:</p>
<pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _timer<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=timer%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:timer.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Timer</span></a>;
&nbsp;
override <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> tearDown<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
    _timer.<span style="color: #004993;">stop</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
    _timer = <span style="color: #0033ff; font-weight: bold;">null</span>;
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> testTimer<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
    _timer = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=timer%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:timer.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Timer</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">3000</span>, <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span>;
    _timer.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=timerevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:timerevent.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">TimerEvent</span></a>.<span style="color: #004993;">TIMER</span>, incrementCount<span style="color: #000000;">&#41;</span>;
    _timer.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=timerevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:timerevent.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">TimerEvent</span></a>.<span style="color: #004993;">TIMER_COMPLETE</span>, addAsync<span style="color: #000000;">&#40;</span>verifyCount, <span style="color: #000000; font-weight:bold;">3500</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
    _timer.<span style="color: #004993;">start</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span></pre>
<p>As you may have noticed, this code is a bit confusing. Basically what is happening is that FlexUnit is being told to wait 3.5 seconds before checking to see if &quot;verifyCount&quot; has been invoked. While this code works, it's a bit clunky and not very intuitive. You have to create a timer, add event listeners for the timer, and then actually tell the timer to run. This may seem to be a  trivial complaint, but when you have to write a series of tests with dependencies on previously written async tests this can get pretty tedious pretty quickly.</p>
<p>With Flex Unit 4 asynch test functions have been streamlined to look something like this:</p>
<pre class="actionscript3" style="font-family:monospace;">&nbsp;
<span style="color: #000000;">&#91;</span>Test<span style="color: #000000;">&#40;</span>async,timeout=<span style="color: #990000;">&quot;3000&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> UserRegistration<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span>
&nbsp;
	Async.handleEvent<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">this</span>, _service, ServiceEvent.USER_REGISTERED, onUserRegistered<span style="color: #000000;">&#41;</span>;
	_service.registerUser<span style="color: #000000;">&#40;</span>_testEmailStr<span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> onUserRegistered<span style="color: #000000;">&#40;</span>event<span style="color: #000000; font-weight: bold;">:</span>ServiceEvent, param2<span style="color: #000000; font-weight: bold;">:*</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span>
	_testUser = UserVO.fromObject<span style="color: #000000;">&#40;</span>event.<span style="color: #004993;">data</span><span style="color: #000000;">&#41;</span>;
	Assert.assertNotNull<span style="color: #000000;">&#40;</span>_testUser<span style="color: #000000;">&#41;</span>;
	Assert.assertTrue<span style="color: #000000;">&#40;</span>_testUser.email == _testEmailStr<span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #000000;">&#125;</span></pre>
<p>In this example, we have a test function called &quot;UserRegistration.&quot; This function will test if my async call to the server to register a user has worked. Notice the the &quot;Async.handleEvent&quot; line of code. In this line we are telling Flex Unit 4 to listen for an event that &quot;_service&quot; will be broadcasting. This line of code also tells FlexUnit to invoke the handler function &quot;onUserRegistered&quot; if &quot;_service&quot; does broadcast this event. The meta tag line above the declaration for UserRegistration also specifies that this test function should issue a failure notification if the function takes longer than 3 seconds to complete.</p>
<p>As for the actual &quot;onUserRegistered&quot; handler, we run an assertion to make sure the new VO got parsed correctly. Once that is done, we also make sure the properties of the new VO were set correctly.</p>
<p>For more information about FlexUnit 4 be sure to checkout Digital Primate's FlexUnit in 360 seconds <a href="http://blogs.digitalprimates.net/codeSlinger/index.cfm/2009/5/3/FlexUnit-4-in-360-seconds">post</a> as well as O'Reilly's <a href="http://www.insideria.com/2009/05/flashbuilder4-will-support-fle.html">post</a>. If you would like FlexUnit 4 to be directly integrated with your copy of Flash Builder today check this <a href="http://blogs.digitalprimates.net/codeSlinger/index.cfm/FlexUnit">link</a> out as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.themorphicgroup.com/blog/2009/07/15/how-to-use-asynchronous-test-methods-with-flexunit-4/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>How to Make a Flash Application into a Facebook Application and Page Tab</title>
		<link>http://www.themorphicgroup.com/blog/2009/07/09/how-to-make-a-flash-application-in-a-facebook-application-and-page-tab/</link>
		<comments>http://www.themorphicgroup.com/blog/2009/07/09/how-to-make-a-flash-application-in-a-facebook-application-and-page-tab/#comments</comments>
		<pubDate>Thu, 09 Jul 2009 16:22:51 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Facebook Applications]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.themorphicgroup.com/blog/?p=173</guid>
		<description><![CDATA[For the Morphic Group's Facebook page we wanted to repurpose the featured projects part of our current website into a Facebook page tab. After looking at a series of tutorials and poking and prodding till it worked, here is how we did it. What you will need: - A webserver or hosting account that can [...]]]></description>
			<content:encoded><![CDATA[<p>For the Morphic Group's <a href="http://facebook.com">Facebook</a> <a href="http://www.facebook.com/pages/The-Morphic-Group/7660059611?ref=nf">page</a> we wanted to repurpose the featured projects part of our current <a href="http://themorphicgroup.com/#featuredProjects">website</a> into a Facebook page tab. After looking at a series of <a href="http://www.insideria.com/series-facebook-dev.html">tutorials</a> and poking and prodding till it worked, here is how we did <a href="http://apps.facebook.com/tmgportfolio/">it</a>.</p>
<p><strong>What you will need:</strong></p>
<p>- A webserver or hosting account that can run PHP<br />
- A Facebook account<br />
- The Facebook Developer app installed in your Facebook account<br />
- If your Flash app needs to load xml or images from your hosted domain, access to your crossdomain xml file at hosted domain</p>
<p><strong>Part 1 Setup your Flash Application on your Server</strong></p>
<p>1. Create a directory on your web server for all of your files. For TMG, I created a directory &quot;facebook&quot; and inside that folder I created another folder &quot;portfolio.&quot;</p>
<p>2. Upload your Flash app swf and its supporting files. In my case, since my app was built with Flex this consisted of my images and xml assets folder, the generated HTML file, and the compiled swf for my app.</p>
<p>3. Create a &quot;tab&quot; folder. In the &quot;portfolio&quot; folder I previously created, I added a &quot;tab&quot; folder. We need this folder for when a user makes your Facebook app into a tab. When an app is made into a tab, Facebook will want a different set of files to use. This is because developers sometimes want their apps to look or behave differently if their app is implemented as a tab.</p>
<p>4. Copy the files Facebook should use when your application gets implemented as a tab. In my case, I just copied the same files from the &quot;portfolio&quot; directory into the &quot;tab&quot; directory.</p>
<p><strong>Part 2 Setup your Application in Facebook</strong></p>
<p>1. Click on the &quot;Developer&quot; app button under the &quot;Applications&quot; button in your Facebook control bar at the bottom of the page.</p>
<p>2. Click &quot;Set Up New Application&quot; in the upper right of the Developer page.</p>
<p>3. Type in your Application name, accept the Facebook Terms, and click &quot;Save Changes.&quot;</p>
<p>4. You will now be taken to the &quot;Basic&quot; tab of your application. In this tab, you can edit the Application Name, Description, Icon/Logo, Developer Contact Email, and auxilary URLs for your app. For our interactive portfolio, we just updated our description and icon/logo. When done, click &quot;Save Changes.&quot;</p>
<p>5. Next click on &quot;Authentication&quot; on the left. Be sure to check &quot;Users&quot; and &quot;Facebook Pages.&quot; For the Post-Authorize and Post-Remove Callback URLs, enter the following:<br />
http://www2.themorphicgroup.com/{the directory your swf is hosted at on your sever}/index.php  </p>
<p>For the TMG portfolio app it is:</p>
<p>http://www2.themorphicgroup.com/facebook/portfolio/index.php</p>
<p>Click &quot;Save Changes&quot; when you are done.</p>
<p>6. To setup our tab configuration, click &quot;Profiles&quot; in the left menu. Enter in your Tab Name and tab URL. For example, we entered &quot;TMG Portfolio&quot; as the tab name and &quot;tab/tab.php&quot; for the &quot;Tab URL.&quot; The &quot;Tab URL&quot; field basically tells Facebook where to find the files to use for the tab. Click &quot;Save Changes.&quot;</p>
<p>7. Click &quot;Canvas&quot; on the menu to the left. Enter your &quot;Canvas Page URL&quot; (ex: &quot;tmgportfolio&quot;.) Next, enter the &quot;Canvas Callback URL&quot; for your app. This should be the full URL path to where your Flash app resides. For the TMG Portfolio app it is:</p>
<p>http://www2.themorphicgroup.com/facebook/portfolio/</p>
<p>8. Make sure &quot;IFrame&quot; is selected for &quot;Render Method&quot; and then click &quot;Save Changes.&quot;</p>
<p><strong>Part 3 Setup the PHP on your Server</strong></p>
<p>1. Click &quot;Back to My Applications&quot; at the top of the Developer UI.</p>
<p>2. Click &quot;Download the Client Library&quot; link at the bottom of the Developer UI. Once download, extract the files and then upload them to your Flash app's web directory. For the TMG app this directory was:<br />
  /facebook/portfolio/  
</p>
<p>3. Click on the &quot;example code&quot; link three quarters of the way down the page. Follow Step 2: Create an &quot;index.php&quot; File in the &quot;Quick Creation Guide&quot; popup.</p>
<p>4. Modify the index.php file for your Flash app. For TMG Portfolio app this is the only PHP I had:</p>
<p>&lt;?php<br />
  // Copyright 2007 Facebook Corp.  All Rights Reserved. <br />
  // <br />
  // Application: The Morphic Group Portfolio<br />
  // File: 'index.php' <br />
  //   This is a sample skeleton for your application. <br />
// </p>
<p>require_once 'facebook.php';</p>
<p>$appapikey = '#########################';<br />
  $appsecret = '##########################';<br />
  $facebook = new Facebook($appapikey, $appsecret);<br />
  $user_id = $facebook-&gt;require_login();</p>
<p>?&gt;</p>
<p>After the PHP block, I cut and pasted in the HTML for my Flash app that was generated by Flex. Note: I removed the api key and secret for privacy reason.</p>
<p>5. Create your tab.php file. This will be the PHP that will be used to render the tab version of your applicaiton. For our application, this is only one line:<br />
&lt;fb:swf swfbgcolor=&quot;000000&quot; imgstyle=&quot;border-width:3px; border-color:white;&quot; swfsrc='http://www2.themorphicgroup.com/facebook/portfolio/TMG_FB_Portfolio.swf' imgsrc='http://www2.themorphicgroup.com/facebook/portfolio/fbSplash.jpg' width='600' height='570' /&gt; </p>
<p>FBML is a markup language that Facebook uses to render apps. In this example note that we specify an &quot;imgsrc&quot; attribute in addition to the &quot;swfsrc&quot; attribute. The image specified is used as a splash graphic of sorts, because a Flash swf in a tab is not activated until a user clicks on it.</p>
<p><strong>Part 4 Test and Implement Application</strong></p>
<p>1. Click on the link under &quot;Step 3: Test Your Application&quot; in the &quot;Quick Creation Guide&quot; popup, or you can go to your canvas URL directly (ex: http://apps.facebook.com/tmgportfolio.)</p>
<p>2. You should now see your application running in Facebook. </p>
<p>3. Go back to your application's page in &quot;My Applications&quot; and click on &quot;View Application Profile&quot; in the menu on the right.</p>
<p>4. Once on the application's profile page, click &quot;More&quot; in the menu to the left. You should see an option &quot;Add to my Page.&quot; After clicking, you will be asked what page you would like this to be added to.</p>
<p>5. After selecting the appropriate page, your application should now be visible as a tab.</p>
<p>&nbsp;</p>
<p>There you have it. If all went well and I didn't miss anything in this tutorial, you should now have a cooler Facebook page. If there is anything I missed, or if you run into any issues that aren't covered here, please leave a comment and I'll update this blog post.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.themorphicgroup.com/blog/2009/07/09/how-to-make-a-flash-application-in-a-facebook-application-and-page-tab/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Flash ContextMenu</title>
		<link>http://www.themorphicgroup.com/blog/2009/07/06/contextmenu-copy-paste-delete/</link>
		<comments>http://www.themorphicgroup.com/blog/2009/07/06/contextmenu-copy-paste-delete/#comments</comments>
		<pubDate>Mon, 06 Jul 2009 13:45:45 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[adobe]]></category>
		<category><![CDATA[ContextMenu]]></category>
		<category><![CDATA[copy]]></category>
		<category><![CDATA[delete]]></category>
		<category><![CDATA[Flex Builder]]></category>
		<category><![CDATA[FlexBuilder]]></category>
		<category><![CDATA[paste]]></category>
		<category><![CDATA[rt-click menu]]></category>
		<category><![CDATA[The Morphic Group]]></category>

		<guid isPermaLink="false">http://www.themorphicgroup.com/blog/?p=166</guid>
		<description><![CDATA[Recently I attempted at add copy, paste, delete to a ContextMenu (rt-click menu) of a Flash movie. I quickly discovered that copy, paste, and delete are reserved words and cannot be used. I tried the trick of putting a space after the words, i.e. "copy ". That did not work. I found a decent work [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I attempted at add <strong>copy</strong>, <strong>paste</strong>, <strong>delete </strong>to a ContextMenu (rt-click menu) of a Flash movie.  I quickly discovered that copy, paste, and delete are reserved words and cannot be used.  I tried the trick of putting a space after the words, i.e. "copy ".  That did not work.  </p>
<p>I found a decent work around.  I added a non-breaking space to the end of each string and that was enough of a change to get copy, paste, and delete to show up in my context menu.  The unicode character for a non-breaking space is <strong>00A0</strong>.  The syntax looks like this "<strong>\u00A0</strong>".</p>
<pre class="actionscript3" style="font-family:monospace;">elementContextMenu = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=contextmenu%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:contextmenu.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">ContextMenu</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
elementContextMenu.<span style="color: #004993;">hideBuiltInItems</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #6699cc; font-weight: bold;">var</span> cutItem<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=contextmenuitem%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:contextmenuitem.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">ContextMenuItem</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=contextmenuitem%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:contextmenuitem.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">ContextMenuItem</span></a><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Cut<span style="">\u</span>00A0&quot;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #6699cc; font-weight: bold;">var</span> copyItem<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=contextmenuitem%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:contextmenuitem.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">ContextMenuItem</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=contextmenuitem%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:contextmenuitem.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">ContextMenuItem</span></a><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Copy<span style="">\u</span>00A0&quot;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #6699cc; font-weight: bold;">var</span> pasteItem<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=contextmenuitem%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:contextmenuitem.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">ContextMenuItem</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=contextmenuitem%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:contextmenuitem.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">ContextMenuItem</span></a><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Paste<span style="">\u</span>00A0&quot;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
cutItem.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=contextmenuevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:contextmenuevent.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">ContextMenuEvent</span></a>.<span style="color: #004993;">MENU_ITEM_SELECT</span>, onCutItem<span style="color: #000000;">&#41;</span>;
copyItem.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=contextmenuevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:contextmenuevent.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">ContextMenuEvent</span></a>.<span style="color: #004993;">MENU_ITEM_SELECT</span>, onCopyItem<span style="color: #000000;">&#41;</span>;
pasteItem.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=contextmenuevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:contextmenuevent.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">ContextMenuEvent</span></a>.<span style="color: #004993;">MENU_ITEM_SELECT</span>, onPasteItem<span style="color: #000000;">&#41;</span>;
&nbsp;
elementContextMenu.<span style="color: #004993;">customItems</span>.<span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span>cutItem<span style="color: #000000;">&#41;</span>;
elementContextMenu.<span style="color: #004993;">customItems</span>.<span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span>copyItem<span style="color: #000000;">&#41;</span>;
elementContextMenu.<span style="color: #004993;">customItems</span>.<span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span>pasteItem<span style="color: #000000;">&#41;</span>;
&nbsp;
Application.application.<span style="color: #004993;">contextMenu</span> = elementContextMenu;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.themorphicgroup.com/blog/2009/07/06/contextmenu-copy-paste-delete/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Creating a Spark Resizable Title Window with Adobe Catalyst and Flash Builder</title>
		<link>http://www.themorphicgroup.com/blog/2009/06/26/creating-a-spark-resizable-title-window-with-adobe-catalyst-and-flash-builder/</link>
		<comments>http://www.themorphicgroup.com/blog/2009/06/26/creating-a-spark-resizable-title-window-with-adobe-catalyst-and-flash-builder/#comments</comments>
		<pubDate>Fri, 26 Jun 2009 16:41:38 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Adobe Catalyst]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Flash Builder]]></category>
		<category><![CDATA[Spark]]></category>
		<category><![CDATA[SparkSkin]]></category>
		<category><![CDATA[TitleWindow]]></category>

		<guid isPermaLink="false">http://www.themorphicgroup.com/blog/?p=145</guid>
		<description><![CDATA[You may have noticed that with the new Spark components there isn't a new TitleWindow, much like the lack of icon property in a Spark button I wrote about in a previous post. In this tutorial, I'm going to demonstrate how to create a resizable TitleWindow using the new Spark SkinnableContainer component. You can view [...]]]></description>
			<content:encoded><![CDATA[<p>You may have noticed that with the new <a href="http://danorlando.com/?p=374">Spark</a> components there isn't a new <a href="http://livedocs.adobe.com/flex/2/langref/mx/containers/TitleWindow.html">TitleWindow</a>, much like the lack of icon property in a Spark button I wrote about in a previous <a href="http://www.themorphicgroup.com/blog/2009/06/18/how-to-create-a-spark-icon-button-and-skin/">post</a>. In this tutorial, I'm going to demonstrate how to create a resizable TitleWindow using the new Spark <a href="http://livedocs.adobe.com/flex/gumbo/langref/spark/components/SkinnableContainer.html">SkinnableContainer</a> component. You can view the results of this demo <a href="http://www2.themorphicgroup.com/blog/sparkTitleWindow/" target="_blank">here</a> or if you just want to grab the code and be on your way, you can download it <a href="http://www2.themorphicgroup.com/blog/sparkTitleWindow/SparkTitleWindow.zip">here</a>.</p>
<p><strong>Create the UI elements in Catalyst</strong>.</p>
<p>The following screenshot demonstrates how I built and organized the components in my <a href="http://labs.adobe.com/technologies/flashcatalyst/">Catalyst</a> project. For this component, I'm going to need a background, a header, a close button, and a handle to resize the button. I was able to name these components what I wanted by changing their names in the Library panel. Because Catalyst doesn't really let you know the type of components on the stage, it helps to rename these as you build each one.</p>
<p><img src="http://www2.themorphicgroup.com/blog/sparkTitleWindow/catalyst.jpg"/></p>
<p><strong>Import and tweak the Catalyst components in Flash Builder.</strong></p>
<p>After importing the Catalyst project into <a href="http://livedocs.adobe.com/flex/gumbo/html/WS65aa2914f20a58ebd123e2512119993c71-8000.html">Flash Builder</a> I made some changes to the following components:</p>
<p>TitleWindowBG.mxml</p>
<pre class="actionscript3" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?</span>xml <span style="color: #004993;">version</span>=<span style="color: #990000;">&quot;1.0&quot;</span> encoding=<span style="color: #990000;">&quot;utf-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>Group xmlns<span style="color: #000000; font-weight: bold;">:</span>s=<span style="color: #990000;">&quot;library://ns.adobe.com/flex/spark&quot;</span> xmlns<span style="color: #000000; font-weight: bold;">:</span>fx=<span style="color: #990000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>Rect <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;100%&quot;</span> radiusY=<span style="color: #990000;">&quot;10&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;100%&quot;</span> radiusX=<span style="color: #990000;">&quot;10&quot;</span> <span style="color: #004993;">alpha</span>=<span style="color: #990000;">&quot;0.75&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
		<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>fill<span style="color: #000000; font-weight: bold;">&gt;</span>
			<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>SolidColor <span style="color: #004993;">color</span>=<span style="color: #990000;">&quot;#000000&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
		<span style="color: #000000; font-weight: bold;">&lt;/</span>s<span style="color: #000000; font-weight: bold;">:</span>fill<span style="color: #000000; font-weight: bold;">&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;/</span>s<span style="color: #000000; font-weight: bold;">:</span>Rect<span style="color: #000000; font-weight: bold;">&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;/</span>s<span style="color: #000000; font-weight: bold;">:</span>Group<span style="color: #000000; font-weight: bold;">&gt;</span></pre>
<p>With this component I set the height and width of the rectangle to 100%. Currently Catalyst only lets you specify height and widths as fixed numbers.</p>
<p>TitleWindowCloseButton.mxml</p>
<pre class="actionscript3" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?</span>xml <span style="color: #004993;">version</span>=<span style="color: #990000;">&quot;1.0&quot;</span> encoding=<span style="color: #990000;">&quot;utf-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>Skin xmlns<span style="color: #000000; font-weight: bold;">:</span>s=<span style="color: #990000;">&quot;library://ns.adobe.com/flex/spark&quot;</span> xmlns<span style="color: #000000; font-weight: bold;">:</span>fx=<span style="color: #990000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>states<span style="color: #000000; font-weight: bold;">&gt;</span>
		<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>State <span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;up&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
		<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>State <span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;over&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
		<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>State <span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;down&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
		<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>State <span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;disabled&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;/</span>s<span style="color: #000000; font-weight: bold;">:</span>states<span style="color: #000000; font-weight: bold;">&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;</span>fx<span style="color: #000000; font-weight: bold;">:</span>Metadata<span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000;">&#91;</span>HostComponent<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;spark.components.Button&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span><span style="color: #000000; font-weight: bold;">&lt;/</span>fx<span style="color: #000000; font-weight: bold;">:</span>Metadata<span style="color: #000000; font-weight: bold;">&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>Rect <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;21&quot;</span> radiusY=<span style="color: #990000;">&quot;5&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;21&quot;</span> radiusX=<span style="color: #990000;">&quot;5&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
		<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>fill<span style="color: #000000; font-weight: bold;">&gt;</span>
			<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>LinearGradient <span style="color: #004993;">rotation</span>=<span style="color: #990000;">&quot;90&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
				<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>GradientEntry <span style="color: #004993;">color</span>=<span style="color: #990000;">&quot;#7f0000&quot;</span> <span style="color: #004993;">alpha</span>=<span style="color: #990000;">&quot;1.0&quot;</span> ratio=<span style="color: #990000;">&quot;0&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
				<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>GradientEntry <span style="color: #004993;">color</span>=<span style="color: #990000;">&quot;#ff0000&quot;</span> <span style="color: #004993;">alpha</span>=<span style="color: #990000;">&quot;1.0&quot;</span> ratio=<span style="color: #990000;">&quot;1&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
			<span style="color: #000000; font-weight: bold;">&lt;/</span>s<span style="color: #000000; font-weight: bold;">:</span>LinearGradient<span style="color: #000000; font-weight: bold;">&gt;</span>
		<span style="color: #000000; font-weight: bold;">&lt;/</span>s<span style="color: #000000; font-weight: bold;">:</span>fill<span style="color: #000000; font-weight: bold;">&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;/</span>s<span style="color: #000000; font-weight: bold;">:</span>Rect<span style="color: #000000; font-weight: bold;">&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>RichText
		id=<span style="color: #990000;">&quot;labelElement&quot;</span>
		<span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;7&quot;</span> <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;6&quot;</span>
		<span style="color: #004993;">color</span>=<span style="color: #990000;">&quot;#ffffff&quot;</span>
		<span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;(Label)&quot;</span>
		<span style="color: #004993;">fontSize</span>=<span style="color: #990000;">&quot;12&quot;</span> fontFamily=<span style="color: #990000;">&quot;Arial&quot;</span> fontWeight=<span style="color: #990000;">&quot;bold&quot;</span>
		<span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;8&quot;</span> <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;12&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;/</span>s<span style="color: #000000; font-weight: bold;">:</span>Skin<span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;</pre>
<p>I cleaned out some transistion stuff that wasn't necassary.</p>
<p>TitleWindowHeader.mxml</p>
<pre class="actionscript3" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?</span>xml <span style="color: #004993;">version</span>=<span style="color: #990000;">&quot;1.0&quot;</span> encoding=<span style="color: #990000;">&quot;utf-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>Skin xmlns<span style="color: #000000; font-weight: bold;">:</span>s=<span style="color: #990000;">&quot;library://ns.adobe.com/flex/spark&quot;</span> xmlns<span style="color: #000000; font-weight: bold;">:</span>fx=<span style="color: #990000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>states<span style="color: #000000; font-weight: bold;">&gt;</span>
		<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>State <span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;up&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
		<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>State <span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;over&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
		<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>State <span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;down&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
		<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>State <span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;disabled&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;/</span>s<span style="color: #000000; font-weight: bold;">:</span>states<span style="color: #000000; font-weight: bold;">&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;</span>fx<span style="color: #000000; font-weight: bold;">:</span>Metadata<span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000;">&#91;</span>HostComponent<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;spark.components.Button&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span><span style="color: #000000; font-weight: bold;">&lt;/</span>fx<span style="color: #000000; font-weight: bold;">:</span>Metadata<span style="color: #000000; font-weight: bold;">&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>Rect <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;28&quot;</span> radiusY=<span style="color: #990000;">&quot;5&quot;</span> <span style="color: #004993;">left</span>=<span style="color: #990000;">&quot;0&quot;</span> <span style="color: #004993;">right</span>=<span style="color: #990000;">&quot;0&quot;</span> radiusX=<span style="color: #990000;">&quot;5&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
		<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>fill<span style="color: #000000; font-weight: bold;">&gt;</span>
			<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>LinearGradient <span style="color: #004993;">rotation</span>=<span style="color: #990000;">&quot;90&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
				<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>GradientEntry <span style="color: #004993;">color</span>=<span style="color: #990000;">&quot;#ff0000&quot;</span> <span style="color: #004993;">alpha</span>=<span style="color: #990000;">&quot;1.0&quot;</span> ratio=<span style="color: #990000;">&quot;0&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
				<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>GradientEntry <span style="color: #004993;">color</span>=<span style="color: #990000;">&quot;#7f0000&quot;</span> <span style="color: #004993;">alpha</span>=<span style="color: #990000;">&quot;1.0&quot;</span> ratio=<span style="color: #990000;">&quot;1&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
			<span style="color: #000000; font-weight: bold;">&lt;/</span>s<span style="color: #000000; font-weight: bold;">:</span>LinearGradient<span style="color: #000000; font-weight: bold;">&gt;</span>
		<span style="color: #000000; font-weight: bold;">&lt;/</span>s<span style="color: #000000; font-weight: bold;">:</span>fill<span style="color: #000000; font-weight: bold;">&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;/</span>s<span style="color: #000000; font-weight: bold;">:</span>Rect<span style="color: #000000; font-weight: bold;">&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>RichText
		id=<span style="color: #990000;">&quot;labelElement&quot;</span>
		<span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;8&quot;</span>
		<span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;14&quot;</span>
		<span style="color: #004993;">color</span>=<span style="color: #990000;">&quot;#ffffff&quot;</span>
		<span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;(Label)&quot;</span>
		<span style="color: #004993;">fontSize</span>=<span style="color: #990000;">&quot;14&quot;</span> fontFamily=<span style="color: #990000;">&quot;Arial&quot;</span> fontWeight=<span style="color: #990000;">&quot;bold&quot;</span>
		<span style="color: #004993;">left</span>=<span style="color: #990000;">&quot;5&quot;</span> <span style="color: #004993;">right</span>=<span style="color: #990000;">&quot;20&quot;</span>  <span style="color: #000000; font-weight: bold;">/&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;/</span>s<span style="color: #000000; font-weight: bold;">:</span>Skin<span style="color: #000000; font-weight: bold;">&gt;</span></pre>
<p>I set the left and right properties of the Rect and RichText so it would change size with our eventual component.</p>
<p>TitleWindowResizeHandle.mxml</p>
<pre class="actionscript3" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?</span>xml <span style="color: #004993;">version</span>=<span style="color: #990000;">&quot;1.0&quot;</span> encoding=<span style="color: #990000;">&quot;utf-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>Skin
	xmlns<span style="color: #000000; font-weight: bold;">:</span>s=<span style="color: #990000;">&quot;library://ns.adobe.com/flex/spark&quot;</span>
	xmlns<span style="color: #000000; font-weight: bold;">:</span>fx=<span style="color: #990000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span>
	<span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;100%&quot;</span>
	<span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;100%&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>states<span style="color: #000000; font-weight: bold;">&gt;</span>
		<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>State <span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;up&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
		<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>State <span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;over&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
		<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>State <span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;down&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
		<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>State <span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;disabled&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;/</span>s<span style="color: #000000; font-weight: bold;">:</span>states<span style="color: #000000; font-weight: bold;">&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;</span>fx<span style="color: #000000; font-weight: bold;">:</span>Metadata<span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000;">&#91;</span>HostComponent<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;spark.components.Button&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span><span style="color: #000000; font-weight: bold;">&lt;/</span>fx<span style="color: #000000; font-weight: bold;">:</span>Metadata<span style="color: #000000; font-weight: bold;">&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>Group <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;22&quot;</span> <span style="color: #004993;">rotation</span>=<span style="color: #990000;">&quot;-45&quot;</span> <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;100%&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;100%&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>Rect <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;5&quot;</span> radiusY=<span style="color: #990000;">&quot;3&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;31&quot;</span> radiusX=<span style="color: #990000;">&quot;3&quot;</span> <span style="color: #004993;">alpha</span>=<span style="color: #990000;">&quot;0.5&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
			<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>fill<span style="color: #000000; font-weight: bold;">&gt;</span>
				<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>SolidColor <span style="color: #004993;">color</span>=<span style="color: #990000;">&quot;0xFFFFFF&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
			<span style="color: #000000; font-weight: bold;">&lt;/</span>s<span style="color: #000000; font-weight: bold;">:</span>fill<span style="color: #000000; font-weight: bold;">&gt;</span>
		<span style="color: #000000; font-weight: bold;">&lt;/</span>s<span style="color: #000000; font-weight: bold;">:</span>Rect<span style="color: #000000; font-weight: bold;">&gt;</span>
		<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>Rect <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;8&quot;</span> <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;5&quot;</span> radiusX=<span style="color: #990000;">&quot;3&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;18&quot;</span> <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;7&quot;</span> radiusY=<span style="color: #990000;">&quot;3&quot;</span> <span style="color: #004993;">alpha</span>=<span style="color: #990000;">&quot;0.5&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
			<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>fill<span style="color: #000000; font-weight: bold;">&gt;</span>
				<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>SolidColor <span style="color: #004993;">color</span>=<span style="color: #990000;">&quot;0xFFFFFF&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
			<span style="color: #000000; font-weight: bold;">&lt;/</span>s<span style="color: #000000; font-weight: bold;">:</span>fill<span style="color: #000000; font-weight: bold;">&gt;</span>
		<span style="color: #000000; font-weight: bold;">&lt;/</span>s<span style="color: #000000; font-weight: bold;">:</span>Rect<span style="color: #000000; font-weight: bold;">&gt;</span>
		<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>Rect <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;16&quot;</span> <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;5&quot;</span> radiusX=<span style="color: #990000;">&quot;3&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;5&quot;</span> <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;14&quot;</span> radiusY=<span style="color: #990000;">&quot;3&quot;</span> <span style="color: #004993;">alpha</span>=<span style="color: #990000;">&quot;0.5&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
			<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>fill<span style="color: #000000; font-weight: bold;">&gt;</span>
				<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>SolidColor <span style="color: #004993;">color</span>=<span style="color: #990000;">&quot;0xFFFFFF&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
			<span style="color: #000000; font-weight: bold;">&lt;/</span>s<span style="color: #000000; font-weight: bold;">:</span>fill<span style="color: #000000; font-weight: bold;">&gt;</span>
		<span style="color: #000000; font-weight: bold;">&lt;/</span>s<span style="color: #000000; font-weight: bold;">:</span>Rect<span style="color: #000000; font-weight: bold;">&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;/</span>s<span style="color: #000000; font-weight: bold;">:</span>Group<span style="color: #000000; font-weight: bold;">&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>Rect <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;100%&quot;</span> <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;100%&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
		<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>fill<span style="color: #000000; font-weight: bold;">&gt;</span>
			<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>SolidColor <span style="color: #004993;">color</span>=<span style="color: #990000;">&quot;#ffffff&quot;</span> <span style="color: #004993;">alpha</span>=<span style="color: #990000;">&quot;0&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
		<span style="color: #000000; font-weight: bold;">&lt;/</span>s<span style="color: #000000; font-weight: bold;">:</span>fill<span style="color: #000000; font-weight: bold;">&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;/</span>s<span style="color: #000000; font-weight: bold;">:</span>Rect<span style="color: #000000; font-weight: bold;">&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;/</span>s<span style="color: #000000; font-weight: bold;">:</span>Skin<span style="color: #000000; font-weight: bold;">&gt;</span></pre>
<p>With this component I set the height and width of the artwork Group to 100% and added a transparent Rect to help catch mouse events better.</p>
<p><strong>Create a SparkTitleWindow class that extends SkinnableContainer.</strong></p>
<p>For our custom component we create two public bindable properties &quot;title&quot; and &quot;isResizable&quot; so a developer can easier implement the component. We also declare a &quot;close&quot; event that uses the standard <a href="http://livedocs.adobe.com/flex/201/langref/mx/events/CloseEvent.html">CloseEvent</a> object. For the dragging and resizing functionality, we create start and stop methods that start/stop a <a href="http://livedocs.adobe.com/flex/2/langref/flash/utils/Timer.html">Timer</a> that keeps track of the mouse position.</p>
<pre class="actionscript3" style="font-family:monospace;">&nbsp;
<span style="color: #9900cc; font-weight: bold;">package</span> com.tmg.components
<span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span>.<a href="http://www.google.com/search?q=timerevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:timerevent.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">TimerEvent</span></a>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.geom</span>.<a href="http://www.google.com/search?q=point%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:point.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Point</span></a>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.utils</span>.<a href="http://www.google.com/search?q=timer%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:timer.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Timer</span></a>;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">import</span> mx.core.UIComponent;
	<span style="color: #0033ff; font-weight: bold;">import</span> mx.events.CloseEvent;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">import</span> spark.components.SkinnableContainer;
	<span style="color: #000000;">&#91;</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Event</span></a><span style="color: #000000;">&#40;</span><span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;close&quot;</span>, <span style="color: #004993;">type</span>=<span style="color: #990000;">&quot;mx.events.CloseEvent&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> SparkTitleWindow extends SkinnableContainer
	<span style="color: #000000;">&#123;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> static const DRAG_INTERVAL<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Number</span></a> = <span style="color: #000000; font-weight:bold;">1</span>;
		<span style="color: #000000;">&#91;</span>Bindable<span style="color: #000000;">&#93;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> title<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">String</span></a> = <span style="color: #990000;">&quot;&quot;</span>;
		<span style="color: #000000;">&#91;</span>Bindable<span style="color: #000000;">&#93;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> isResizable<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=boolean%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:boolean.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Boolean</span></a> = <span style="color: #0033ff; font-weight: bold;">true</span>;
		<span style="color: #009900;">//drag props</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _dragTimer<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=timer%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:timer.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Timer</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=timer%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:timer.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Timer</span></a><span style="color: #000000;">&#40;</span>DRAG_INTERVAL<span style="color: #000000;">&#41;</span>;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _dragInitPoint<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=point%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:point.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Point</span></a>;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _dragHandle<span style="color: #000000; font-weight: bold;">:</span>UIComponent;
		<span style="color: #009900;">//resize props</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _resizeTimer<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=timer%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:timer.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Timer</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=timer%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:timer.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Timer</span></a><span style="color: #000000;">&#40;</span>DRAG_INTERVAL<span style="color: #000000;">&#41;</span>;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _resizeInitPoint<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=point%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:point.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Point</span></a>;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _resizeHandle<span style="color: #000000; font-weight: bold;">:</span>UIComponent;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> SparkTitleWindow<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> closeWindow<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span>
			<span style="color: #004993;">dispatchEvent</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> CloseEvent<span style="color: #000000;">&#40;</span>CloseEvent.<span style="color: #004993;">CLOSE</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
		<span style="color: #009900;">//drag methods/handlers</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> startWindowDrag<span style="color: #000000;">&#40;</span>dragHandle<span style="color: #000000; font-weight: bold;">:</span>UIComponent<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">this</span>._dragHandle = dragHandle;
			_dragInitPoint = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=point%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:point.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Point</span></a><span style="color: #000000;">&#40;</span>_dragHandle.<span style="color: #004993;">mouseX</span>, _dragHandle.<span style="color: #004993;">mouseY</span><span style="color: #000000;">&#41;</span>;
			_dragTimer.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=timerevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:timerevent.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">TimerEvent</span></a>.<span style="color: #004993;">TIMER</span>, onDragTimerTick, <span style="color: #0033ff; font-weight: bold;">false</span>, <span style="color: #000000; font-weight:bold;">0</span>, <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span>;
			_dragTimer.<span style="color: #004993;">start</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> stopWindowDrag<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span>
			_dragTimer.<span style="color: #004993;">stop</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			_dragTimer.<span style="color: #004993;">removeEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=timerevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:timerevent.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">TimerEvent</span></a>.<span style="color: #004993;">TIMER</span>, onDragTimerTick<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> onDragTimerTick<span style="color: #000000;">&#40;</span>event<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=timerevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:timerevent.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">TimerEvent</span></a><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> currentMousePoint<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=point%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:point.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Point</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=point%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:point.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Point</span></a><span style="color: #000000;">&#40;</span>_dragHandle.<span style="color: #004993;">mouseX</span>, _dragHandle.<span style="color: #004993;">mouseY</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> gPoint<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=point%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:point.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Point</span></a> = _dragHandle.<span style="color: #004993;">localToGlobal</span><span style="color: #000000;">&#40;</span>currentMousePoint<span style="color: #000000;">&#41;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> lPoint<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=point%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:point.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Point</span></a> = <span style="color: #0033ff; font-weight: bold;">this</span>.<span style="color: #004993;">parent</span>.<span style="color: #004993;">globalToLocal</span><span style="color: #000000;">&#40;</span>gPoint<span style="color: #000000;">&#41;</span>;
			<span style="color: #0033ff; font-weight: bold;">this</span>.<span style="color: #004993;">x</span> = lPoint.<span style="color: #004993;">x</span> <span style="color: #000000; font-weight: bold;">-</span> _dragInitPoint.<span style="color: #004993;">x</span>;
			<span style="color: #0033ff; font-weight: bold;">this</span>.<span style="color: #004993;">y</span> = lPoint.<span style="color: #004993;">y</span> <span style="color: #000000; font-weight: bold;">-</span> _dragInitPoint.<span style="color: #004993;">y</span>;
&nbsp;
		<span style="color: #000000;">&#125;</span>
		<span style="color: #009900;">//resize methods/handlers</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> startWindowResize<span style="color: #000000;">&#40;</span>resizeHandle<span style="color: #000000; font-weight: bold;">:</span>UIComponent<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">this</span>._resizeHandle = resizeHandle;
			_resizeInitPoint = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=point%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:point.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Point</span></a><span style="color: #000000;">&#40;</span>_resizeHandle.<span style="color: #004993;">mouseX</span>, _resizeHandle.<span style="color: #004993;">mouseY</span><span style="color: #000000;">&#41;</span>;
			_resizeTimer.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=timerevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:timerevent.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">TimerEvent</span></a>.<span style="color: #004993;">TIMER</span>, onResizeTimerTick, <span style="color: #0033ff; font-weight: bold;">false</span>, <span style="color: #000000; font-weight:bold;">0</span>, <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span>;
			_resizeTimer.<span style="color: #004993;">start</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> stopWindowResize<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span>
			_resizeTimer.<span style="color: #004993;">stop</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			_resizeTimer.<span style="color: #004993;">removeEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=timerevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:timerevent.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">TimerEvent</span></a>.<span style="color: #004993;">TIMER</span>, onResizeTimerTick<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> onResizeTimerTick<span style="color: #000000;">&#40;</span>event<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=timerevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:timerevent.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">TimerEvent</span></a><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> currentMousePoint<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=point%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:point.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Point</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=point%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:point.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Point</span></a><span style="color: #000000;">&#40;</span>_resizeHandle.<span style="color: #004993;">mouseX</span>, _resizeHandle.<span style="color: #004993;">mouseY</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> gPoint<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=point%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:point.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Point</span></a> = _resizeHandle.<span style="color: #004993;">localToGlobal</span><span style="color: #000000;">&#40;</span>currentMousePoint<span style="color: #000000;">&#41;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> lPoint<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=point%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:point.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Point</span></a> = <span style="color: #0033ff; font-weight: bold;">this</span>.<span style="color: #004993;">parent</span>.<span style="color: #004993;">globalToLocal</span><span style="color: #000000;">&#40;</span>gPoint<span style="color: #000000;">&#41;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> newWidth<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Number</span></a> = <span style="color: #0033ff; font-weight: bold;">this</span>.<span style="color: #004993;">width</span> <span style="color: #000000; font-weight: bold;">+</span> lPoint.<span style="color: #004993;">x</span> <span style="color: #000000; font-weight: bold;">-</span> <span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">this</span>.<span style="color: #004993;">width</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #0033ff; font-weight: bold;">this</span>.<span style="color: #004993;">x</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #000000;">&#40;</span>_resizeHandle.<span style="color: #004993;">width</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> newHeight<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Number</span></a> = <span style="color: #0033ff; font-weight: bold;">this</span>.<span style="color: #004993;">height</span> <span style="color: #000000; font-weight: bold;">+</span> lPoint.<span style="color: #004993;">y</span> <span style="color: #000000; font-weight: bold;">-</span> <span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">this</span>.<span style="color: #004993;">height</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #0033ff; font-weight: bold;">this</span>.<span style="color: #004993;">y</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #000000;">&#40;</span>_resizeHandle.<span style="color: #004993;">height</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>newWidth <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #0033ff; font-weight: bold;">this</span>.minWidth<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
				<span style="color: #0033ff; font-weight: bold;">this</span>.<span style="color: #004993;">width</span> = newWidth;
			<span style="color: #000000;">&#125;</span>
			<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>newHeight <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #0033ff; font-weight: bold;">this</span>.minHeight<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
				<span style="color: #0033ff; font-weight: bold;">this</span>.<span style="color: #004993;">height</span> = newHeight;
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre>
<p><strong>Create SparkTitleWindow SparkSkin.</strong></p>
<p>The last step before implementation is create our <a href="http://livedocs.adobe.com/flex/gumbo/langref/spark/skins/SparkSkin.html">SparkSkin</a> mxml component for our window. This where we incorporate the components we created in Catalyst. Note the Group component &quot;contentGroup.&quot; Because our host component is a SkinnableContainer it is required to have this Group object. This is where the contents of our new container will go.</p>
<pre class="actionscript3" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?</span>xml <span style="color: #004993;">version</span>=<span style="color: #990000;">&quot;1.0&quot;</span> encoding=<span style="color: #990000;">&quot;utf-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>Skin
	xmlns<span style="color: #000000; font-weight: bold;">:</span>fx=<span style="color: #990000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span>
	xmlns<span style="color: #000000; font-weight: bold;">:</span>s=<span style="color: #990000;">&quot;library://ns.adobe.com/flex/spark&quot;</span>
	xmlns<span style="color: #000000; font-weight: bold;">:</span>mx=<span style="color: #990000;">&quot;library://ns.adobe.com/flex/halo&quot;</span>
	<span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;100%&quot;</span>
	<span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;100%&quot;</span>
	xmlns<span style="color: #000000; font-weight: bold;">:</span>components=<span style="color: #990000;">&quot;components.*&quot;</span>
	<span style="color: #000000; font-weight: bold;">&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;</span>fx<span style="color: #000000; font-weight: bold;">:</span>Script<span style="color: #000000; font-weight: bold;">&gt;</span>
		<span style="color: #000000; font-weight: bold;">&lt;!</span><span style="color: #000000;">&#91;</span>CDATA<span style="color: #000000;">&#91;</span>
			<span style="color: #0033ff; font-weight: bold;">import</span> components.TitleWindowResizeHandle;
		<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#93;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;/</span>fx<span style="color: #000000; font-weight: bold;">:</span>Script<span style="color: #000000; font-weight: bold;">&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;</span>fx<span style="color: #000000; font-weight: bold;">:</span>Metadata<span style="color: #000000; font-weight: bold;">&gt;</span>
		<span style="color: #000000;">&#91;</span>HostComponent<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;com.tmg.components.SparkTitleWindow&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
	<span style="color: #000000; font-weight: bold;">&lt;/</span>fx<span style="color: #000000; font-weight: bold;">:</span>Metadata<span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>states<span style="color: #000000; font-weight: bold;">&gt;</span>
		<span style="color: #000000; font-weight: bold;">&lt;</span>mx<span style="color: #000000; font-weight: bold;">:</span>State <span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;normal&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;/</span>s<span style="color: #000000; font-weight: bold;">:</span>states<span style="color: #000000; font-weight: bold;">&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>layout<span style="color: #000000; font-weight: bold;">&gt;</span>
		<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>BasicLayout<span style="color: #000000; font-weight: bold;">/&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;/</span>s<span style="color: #000000; font-weight: bold;">:</span>layout<span style="color: #000000; font-weight: bold;">&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;</span>components<span style="color: #000000; font-weight: bold;">:</span>TitleWindowBG
		id=<span style="color: #990000;">&quot;windowBG&quot;</span>
		<span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;100%&quot;</span> <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;100%&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>Button
		id=<span style="color: #990000;">&quot;windowHeader&quot;</span>
		<span style="color: #004993;">left</span>=<span style="color: #990000;">&quot;5&quot;</span> <span style="color: #004993;">top</span>=<span style="color: #990000;">&quot;5&quot;</span> <span style="color: #004993;">right</span>=<span style="color: #990000;">&quot;5&quot;</span>
		skinClass=<span style="color: #990000;">&quot;components.TitleWindowHeader&quot;</span>
		label=<span style="color: #990000;">&quot;{hostComponent.title}&quot;</span>
		<span style="color: #004993;">mouseDown</span>=<span style="color: #990000;">&quot;{ hostComponent.startWindowDrag(windowHeader) }&quot;</span>
		<span style="color: #004993;">mouseUp</span>=<span style="color: #990000;">&quot;{ hostComponent.stopWindowDrag() }&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>Button
		id=<span style="color: #990000;">&quot;closeButton&quot;</span>
		label=<span style="color: #990000;">&quot;X&quot;</span>
		<span style="color: #004993;">buttonMode</span>=<span style="color: #990000;">&quot;true&quot;</span>
		skinClass=<span style="color: #990000;">&quot;components.TitleWindowCloseButton&quot;</span>
		<span style="color: #004993;">right</span>=<span style="color: #990000;">&quot;7&quot;</span> <span style="color: #004993;">top</span>=<span style="color: #990000;">&quot;8&quot;</span>
		<span style="color: #004993;">click</span>=<span style="color: #990000;">&quot;{ hostComponent.closeWindow()}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>Group
		id=<span style="color: #990000;">&quot;contentGroup&quot;</span>
		clipAndEnableScrolling=<span style="color: #990000;">&quot;true&quot;</span>
		<span style="color: #004993;">top</span>=<span style="color: #990000;">&quot;{windowHeader.y + windowHeader.height + 10}&quot;</span>
		<span style="color: #004993;">left</span>=<span style="color: #990000;">&quot;5&quot;</span> <span style="color: #004993;">right</span>=<span style="color: #990000;">&quot;5&quot;</span> <span style="color: #004993;">bottom</span>=<span style="color: #990000;">&quot;5&quot;</span>
		<span style="color: #004993;">color</span>=<span style="color: #990000;">&quot;#ffffff&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;/</span>s<span style="color: #000000; font-weight: bold;">:</span>Group<span style="color: #000000; font-weight: bold;">&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>Button
		id=<span style="color: #990000;">&quot;resizeButton&quot;</span>
		<span style="color: #004993;">right</span>=<span style="color: #990000;">&quot;2&quot;</span> <span style="color: #004993;">bottom</span>=<span style="color: #990000;">&quot;2&quot;</span>
		<span style="color: #004993;">mouseDown</span>=<span style="color: #990000;">&quot;{ hostComponent.startWindowResize(resizeButton)}&quot;</span>
		<span style="color: #004993;">mouseUp</span>=<span style="color: #990000;">&quot;{ hostComponent.stopWindowResize()}&quot;</span>
		<span style="color: #004993;">visible</span>=<span style="color: #990000;">&quot;{ hostComponent.isResizable }&quot;</span>
		skinClass=<span style="color: #990000;">&quot;components.TitleWindowResizeHandle&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;/</span>s<span style="color: #000000; font-weight: bold;">:</span>Skin<span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;</pre>
<p>Also note how we are able to access our newley written public properties and methods via the &quot;<a href="http://livedocs.adobe.com/flex/gumbo/html/WSA95C9644-B650-4783-B5C0-D2C7F95A23E3.html">hostComponent</a>&quot; property.
</p>
<p><strong>Implement new component.</strong></p>
<p>With our new container written and skin created, we can now implement this new window component.</p>
<pre class="actionscript3" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;</span>components<span style="color: #000000; font-weight: bold;">:</span>SparkTitleWindow
		id=<span style="color: #990000;">&quot;myWindow&quot;</span>
		skinClass=<span style="color: #990000;">&quot;com.tmg.skins.SparkTitleWindowSkin&quot;</span>
		title=<span style="color: #990000;">&quot;My Title Window&quot;</span>
		<span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;200&quot;</span> <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;50&quot;</span>
		<span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;300&quot;</span> <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;300&quot;</span>
		<span style="color: #004993;">close</span>=<span style="color: #990000;">&quot;{myWindow.visible=false}&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
		<span style="color: #000000; font-weight: bold;">&lt;</span>components<span style="color: #000000; font-weight: bold;">:</span>layout<span style="color: #000000; font-weight: bold;">&gt;</span>
			<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>VerticalLayout<span style="color: #000000; font-weight: bold;">/&gt;</span>
		<span style="color: #000000; font-weight: bold;">&lt;/</span>components<span style="color: #000000; font-weight: bold;">:</span>layout<span style="color: #000000; font-weight: bold;">&gt;</span>
		<span style="color: #000000; font-weight: bold;">&lt;</span>mx<span style="color: #000000; font-weight: bold;">:</span>Label <span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;These are the contents of my window:&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
		<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>TextInput
			<span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;100%&quot;</span>
			<span style="color: #004993;">color</span>=<span style="color: #990000;">&quot;#000000&quot;</span>
			<span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;A text input...&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
		<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>TextArea
			<span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;100%&quot;</span>
			<span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;A textarea...&quot;</span>
			<span style="color: #004993;">color</span>=<span style="color: #990000;">&quot;#000000&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
		<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>Button label=<span style="color: #990000;">&quot;A Button&quot;</span> <span style="color: #004993;">color</span>=<span style="color: #990000;">&quot;#000000&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;/</span>components<span style="color: #000000; font-weight: bold;">:</span>SparkTitleWindow<span style="color: #000000; font-weight: bold;">&gt;</span></pre>
<p><strong>Summary</strong></p>
<p>There you have it, a brand new container that can be dragged and/or resized. If you don't want to use Catalyst to edit the look and feel of you new component, you could declare style properties in the SparkTitleWindow class and in your skin component bind to these properties. An example of this can be found in my previous Spark <a href="http://www.themorphicgroup.com/blog/2009/06/18/how-to-create-a-spark-icon-button-and-skin/">post</a> where we create an <a href="http://www.themorphicgroup.com/blog/2009/06/18/how-to-create-a-spark-icon-button-and-skin/">IconButton</a>.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.themorphicgroup.com/blog/2009/06/26/creating-a-spark-resizable-title-window-with-adobe-catalyst-and-flash-builder/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>A Chat About PHP with Adobe Flash Builder 4 and Flash Catalyst</title>
		<link>http://www.themorphicgroup.com/blog/2009/06/25/a-chat-about-php-with-flash-builder-4-and-adobe-catalyst/</link>
		<comments>http://www.themorphicgroup.com/blog/2009/06/25/a-chat-about-php-with-flash-builder-4-and-adobe-catalyst/#comments</comments>
		<pubDate>Thu, 25 Jun 2009 19:45:42 +0000</pubDate>
		<dc:creator>Unknown Morphician</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Adobe Catalyst]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[adobe]]></category>
		<category><![CDATA[Adobe Flash Builder 4]]></category>

		<guid isPermaLink="false">http://www.themorphicgroup.com/blog/?p=90</guid>
		<description><![CDATA[With all the hoopla that is going on with the Flash Platform... probably the biggest news comes from Flash Builder 4 (Flex) with Data Services. The new wizards that can introspect your data service and help you create code to build effortlessly (well at least it is a good start). You may use whatever flavor [...]]]></description>
			<content:encoded><![CDATA[<p style="margin-bottom: 0in;">With all the hoopla that is going on with the Flash Platform... probably the biggest news comes from Flash Builder 4 (Flex) with Data Services. The new wizards that can introspect your data service and help you create code to build effortlessly (well at least it is a good start). You may use whatever flavor server-side technology you want - from Blaze DS, Cold Fusion, and PHP. This last technology is the focus of my little article. I also talk little bit about the work flow with Flash Catalyst and Flash Builder.</p>
<p style="margin-bottom: 0in;"><strong>ZEND Framework</strong></p>
<p style="margin-bottom: 0in;">First, I will briefly go over how to create a php data service using the wizard provided in Flash Builder. You first need to set up your project as you would for any service (Properties &gt; Flex Server). Once you have configure your php service Class and Package name, you are prompted to use Zend framework. The big hook here is the AMF support which also helps to introspect objects. I will say that the Zend framework has a lot of powerful features and is well know in the php community. The framework's size is 17 MB and needs to be uploaded to your web site whether you like it or not. You can't skip this step. This cause a couple of concerns. What if you Zend installed locally? What if in the future a new version of Zend is released won't this upload be a bit dated at some point?</p>
<p style="margin-bottom: 0in;"><img class="alignnone size-full wp-image-94" title="flexServer" src="http://www.themorphicgroup.com/blog/wp-content/uploads/2009/06/flexServer.jpg" alt="flexServer" width="470" height="435" /></p>
<p style="margin-bottom: 0in;"><img class="alignnone size-full wp-image-93" title="MyService_ZEND" src="http://www.themorphicgroup.com/blog/wp-content/uploads/2009/06/MyService_ZEND.jpg" alt="MyService_ZEND" width="480" height="482" /></p>
<p><!-- 		@page { margin: 0.79in } 		P { margin-bottom: 0.08in } 		A:link { so-language: zxx } --></p>
<p style="margin-bottom: 0in;">From this point on your can get auto generated value objects, configure return types, bind to components just to name a few features. Here is a few great tutorials that illustrate these features and more with Zend:</p>
<ul>
<li><a href="http://devzone.zend.com/article/4705">Data-centric Adobe Flash Builder development with the Zend Framework </a></li>
<li><a href="http://www.adobe.com/devnet/flashcatalyst/articles/building_datacentric_app_flashcast_flashbuilder.html">Building a data-centric application using Flash Catalyst beta and Flash Builder 4 beta</a></li>
<li><a href="http://www.gotoandlearn.com/play?id=110">Lee Brimelow's Flash Builder 4 beta and Flash Catalyst beta video tutorial</a></li>
</ul>
<p><!-- 		@page { margin: 0.79in } 		P { margin-bottom: 0.08in } --></p>
<p style="margin-bottom: 0in;"><strong>AMFPHP</strong></p>
<p style="margin-bottom: 0in;">For the rest of this article, I will take a slightly different path as far as creating a PHP service. I will discuss how to implement a Flex project using PHP with AMFPHP (About a little over 700 KB).</p>
<p style="margin-bottom: 0in;">To illustrate this process, I will run through a simple example application – “CelebrationEvent”, a check list utility. The premise is to distribute a list of items needed  for a party or celebration for a group of friends. In this application, users will log in and sign up for items to be in charge of bringing to the event.</p>
<p><!-- 		@page { margin: 0.79in } 		P { margin-bottom: 0.08in } --></p>
<p style="margin-bottom: 0in;">For this application, I went through the whole cycle from design to development with Illustrator CS3, Adobe Flash Catalyst, and Adobe Flash Builder 4.  I do have some comments on this work flow (trial and error) but my focus here is the actual service creation itself.</p>
<p style="margin-bottom: 0in;">Here is a screen shot of the work at beginning stage:</p>
<p style="margin-bottom: 0in;"><img class="alignnone size-full wp-image-95" title="CelebrationEventListLayout" src="http://www.themorphicgroup.com/blog/wp-content/uploads/2009/06/CelebrationEventListLayout.jpg" alt="CelebrationEventListLayout" width="480" height="362" /></p>
<p><!-- 		@page { margin: 0.79in } 		P { margin-bottom: 0.08in } --></p>
<p style="margin-bottom: 0in;"><em><strong>Setup Process</strong></em></p>
<p style="margin-bottom: 0in;">Since there is no data service wizard, there is a manual setup process involved. In other words, create a remote object.</p>
<p style="margin-bottom: 0in;">Note: Download <a href="http://www.amfphp.org/" target="_blank">AMFPHP</a> if you haven't already done so already. Get familiar with folder structure and Setup. For “CelebrationEvent”, I'm 		using MySQL database with “phpMyAdmin”</p>
<p><!-- 		@page { margin: 0.79in } 		P { margin-bottom: 0.08in } --></p>
<p><!-- 		@page { margin: 0.79in } 		P { margin-bottom: 0.08in } --></p>
<p style="margin-bottom: 0in;"><strong>Create Database and Tables Structure </strong></p>
<p style="margin-bottom: 0in;"><span style="font-weight: normal;">For this application I c</span>reated the EventCelebration database with these tables:</p>
<ul>
<li>
<p style="margin-bottom: 0in;">EventList – check list items for 	the event</p>
</li>
<li>
<p style="margin-bottom: 0in;">Users – User list</p>
</li>
<li>
<p style="margin-bottom: 0in;">EventListToUser – relationship 	of user to check list.</p>
</li>
</ul>
<p style="margin-bottom: 0in;">
<p style="margin-bottom: 0in;"><strong>Create the backend service – PHP/AMFPHP</strong></p>
<ul>
<li>
<p style="margin-bottom: 0in;">Update globals.php under AMFPHP folder root</p>
<ul>
<li>
<p style="margin-bottom: 0in;">Change "DB_HOST", "DB_USER", "DB_PASS" and "DB_NAME" to the corresponding database setting for host address, database privilage user , password and database name ("EventCelebration")</p>
</li>
</ul>
</li>
<li>
<p style="margin-bottom: 0in;">The Service Class: 	CelebrationEventService.php</p>
<ul>
<li>
<p style="margin-bottom: 0in;">Class has four methods – 		createUser(), loginUser(), getList(), and signUpForItem()</p>
</li>
<li>
<p style="margin-bottom: 0in;">You would add this class file under the “services” folder of your AMF Folder</p>
</li>
</ul>
</li>
<li>
<p style="margin-bottom: 0in;">Value Objects: User.php and EventItem.php</p>
<ul>
<li>
<p style="margin-bottom: 0in;">Note: Make sure you reference the data type mapped to the corresponding actionscript value objects “explicitType”.</p>
</li>
<li>
<p style="margin-bottom: 0in;">You would add these class files under “services/vo/[folder package 	structure]</p>
</li>
<li>
<p style="margin-bottom: 0in;">Example folder: “services/vo/com/themorphicgroup/celebrateEvent”</p>
</li>
<li>
<p style="margin-bottom: 0in;">See Sample Code Below</p>
</li>
</ul>
</li>
</ul>
<div><strong>Code Sample - User VO</strong></div>
<div>
<div>&lt;?php<br />
class User {<br />
var $id;<br />
var $fullName;<br />
var $email;<br />
var $password;</p>
<p>// explicit actionscript package<br />
var $_explicitType = "com.themorphicgroup.celebrateEvent.User";</p>
<p>/**<br />
* Constructor with default values<br />
*/<br />
function User($id = -1, $fullName = "", $email = "", $password = ""){<br />
$this-&gt;id = $id;<br />
$this-&gt;fullName = $fullName;<br />
$this-&gt;email = $email;<br />
$this-&gt;password = $password;<br />
}</p>
<p>}<br />
?&gt;</p></div>
</div>
<p style="margin-bottom: 0in;">
<p style="margin-bottom: 0in;"><strong>Create objects and calls in your project - Flex</strong></p>
<ul>
<li>
<p style="margin-bottom: 0in;">RemoteObject with handlers</p>
<ul>
<li>
<p style="margin-bottom: 0in;">With the way that the project was 		imported into Flash Builder, I decided to create actionscript to 		create the remoteObject instead of MXML reference.</p>
</li>
<li>
<p style="margin-bottom: 0in;">See Sample Code Below</p>
</li>
</ul>
</li>
<li>
<p style="margin-bottom: 0in;">Value Objects: User.as and 	EventItem</p>
<ul>
<li>
<p style="margin-bottom: 0in;">Note: Great feature in Flash 		Builder 4… you can now create your private variables and create 		you getters and setters via right click, Source, Generate 		Getter/Setter. Very cool.</p>
</li>
<li>
<p style="margin-bottom: 0in;">Make sure that you add metadata 		to map these objects to the corresponding PHP objects.</p>
</li>
<li>
<p style="margin-bottom: 0in;">See Sample Code Below</p>
</li>
</ul>
</li>
</ul>
<div><strong>Code Samples - RemoteObject with handlers</strong></div>
<div>Note: Service call are not show here since they are used through out application</div>
<div>
<div>
<pre class="actionscript3" style="font-family:monospace;">...
&nbsp;
<span style="color: #0033ff; font-weight: bold;">import</span> mx.rpc.remoting.RemoteObject;
<span style="color: #0033ff; font-weight: bold;">import</span> mx.rpc.events.ResultEvent;
<span style="color: #0033ff; font-weight: bold;">import</span> mx.rpc.events.FaultEvent;
<span style="color: #0033ff; font-weight: bold;">import</span> mx.controls.Alert;
&nbsp;
...
&nbsp;
<span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #6699cc; font-weight: bold;">var</span> RESULT<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">String</span></a> = <span style="color: #990000;">&quot;result&quot;</span>;
<span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #6699cc; font-weight: bold;">var</span> FAULT<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">String</span></a> = <span style="color: #990000;">&quot;fault&quot;</span>; 
&nbsp;
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _eventList<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=object%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:object.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Object</span></a>;
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _service<span style="color: #000000; font-weight: bold;">:</span>RemoteObject;
&nbsp;
....
&nbsp;
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> createRemoteObject<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
	_service = <span style="color: #0033ff; font-weight: bold;">new</span> RemoteObject<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
	_service.endpoint = <span style="color: #990000;">&quot;http://www.themorphicgroup.com/CelebrationEventList/service/gateway.php&quot;</span>;
	_service.<span style="color: #004993;">source</span>=<span style="color: #990000;">&quot;CelebrationEventService&quot;</span>;
	_service.destination = <span style="color: #990000;">&quot;amfphp&quot;</span>; 
&nbsp;
	_service.showBusyCursor=<span style="color: #0033ff; font-weight: bold;">true</span>;
&nbsp;
	_service.getList.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span>RESULT, getListResultHandler<span style="color: #000000;">&#41;</span>;
	_service.loginUser.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span>RESULT, loginUserResultHandler<span style="color: #000000;">&#41;</span>;
	_service.createUser.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span>RESULT, createUserResultHandler<span style="color: #000000;">&#41;</span>;
	_service.signUpForItem.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span>RESULT, signUpForItemResultHandler<span style="color: #000000;">&#41;</span>;
&nbsp;
	_service.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span>FAULT, faultHandler<span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> getListResultHandler<span style="color: #000000;">&#40;</span>event<span style="color: #000000; font-weight: bold;">:</span>ResultEvent<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
	_eventList = event.result;
&nbsp;
	<span style="color: #6699cc; font-weight: bold;">var</span> dataProvider<span style="color: #000000; font-weight: bold;">:</span>ArrayCollection = <span style="color: #0033ff; font-weight: bold;">new</span> ArrayCollection<span style="color: #000000;">&#40;</span>event.result <span style="color: #0033ff; font-weight: bold;">as</span> <a href="http://www.google.com/search?q=array%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:array.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Array</span></a><span style="color: #000000;">&#41;</span>;
&nbsp;
	list1.dataProvider = dataProvider;
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> loginUserResultHandler<span style="color: #000000;">&#40;</span>event<span style="color: #000000; font-weight: bold;">:</span>ResultEvent<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
	_currentUser = event.result <span style="color: #0033ff; font-weight: bold;">as</span> User;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>event.result <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
		currentState=<span style="color: #990000;">'List'</span>;
		_service.getList<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
	<span style="color: #000000;">&#125;</span><span style="color: #0033ff; font-weight: bold;">else</span><span style="color: #000000;">&#123;</span>
		mx.controls.Alert.<span style="color: #004993;">show</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Login Failed&quot;</span><span style="color: #000000;">&#41;</span>;
	<span style="color: #000000;">&#125;</span>
	inpName.<span style="color: #004993;">text</span> = <span style="color: #990000;">&quot;&quot;</span>;
	inpEmail.<span style="color: #004993;">text</span> = <span style="color: #990000;">&quot;&quot;</span>;
	inpPassword.<span style="color: #004993;">text</span> = <span style="color: #990000;">&quot;&quot;</span>;
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> createUserResultHandler<span style="color: #000000;">&#40;</span>event<span style="color: #000000; font-weight: bold;">:</span>ResultEvent<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>event.result <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
		<span style="color: #6699cc; font-weight: bold;">var</span> user<span style="color: #000000; font-weight: bold;">:</span>User = User<span style="color: #000000;">&#40;</span>event.result <span style="color: #0033ff; font-weight: bold;">as</span> User<span style="color: #000000;">&#41;</span>;
	<span style="color: #000000;">&#125;</span><span style="color: #0033ff; font-weight: bold;">else</span><span style="color: #000000;">&#123;</span>
		mx.controls.Alert.<span style="color: #004993;">show</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;User Creation Failed&quot;</span><span style="color: #000000;">&#41;</span>;
	<span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>user <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
		_service.loginUser<span style="color: #000000;">&#40;</span>user.email, user.password<span style="color: #000000;">&#41;</span>;
	<span style="color: #000000;">&#125;</span><span style="color: #0033ff; font-weight: bold;">else</span><span style="color: #000000;">&#123;</span>
		mx.controls.Alert.<span style="color: #004993;">show</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;User Creation Failed&quot;</span><span style="color: #000000;">&#41;</span>;
	<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> signUpForItemResultHandler<span style="color: #000000;">&#40;</span>event<span style="color: #000000; font-weight: bold;">:</span>ResultEvent<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>event.result<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
		mx.controls.Alert.<span style="color: #004993;">show</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Signed up for item&quot;</span><span style="color: #000000;">&#41;</span>;
	<span style="color: #000000;">&#125;</span><span style="color: #0033ff; font-weight: bold;">else</span><span style="color: #000000;">&#123;</span>
		mx.controls.Alert.<span style="color: #004993;">show</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Item could not be Signed up&quot;</span><span style="color: #000000;">&#41;</span>;
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> faultHandler <span style="color: #000000;">&#40;</span>event<span style="color: #000000; font-weight: bold;">:</span>FaultEvent<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
	mx.controls.Alert.<span style="color: #004993;">show</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Error&quot;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span></pre>
</div>
</div>
<div><strong>Code Sample - User VO</strong></div>
<div>
<div>
<pre class="actionscript3" style="font-family:monospace;">...
<span style="color: #9900cc; font-weight: bold;">package</span> com.themorphicgroup.celebrateEvent
<span style="color: #000000;">&#123;</span>
	<span style="color: #000000;">&#91;</span>RemoteClass<span style="color: #000000;">&#40;</span>alias=<span style="color: #990000;">&quot;com.themorphicgroup.celebrateEvent.User&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> User
	<span style="color: #000000;">&#123;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _id<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">String</span></a>;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _fullName<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">String</span></a>;
    	        <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _email<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">String</span></a>;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _password<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">String</span></a>;
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> User<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span><span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> fullName<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">String</span></a>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">return</span> _fullName;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">set</span> fullName<span style="color: #000000;">&#40;</span>v<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">String</span></a><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			_fullName = v;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> id<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">String</span></a>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">return</span> _id;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">set</span> id<span style="color: #000000;">&#40;</span>v<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">String</span></a><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			_id = v;
		<span style="color: #000000;">&#125;</span>
&nbsp;
    	        <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> email<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">String</span></a>
    	       <span style="color: #000000;">&#123;</span>
    		       <span style="color: #0033ff; font-weight: bold;">return</span> _email;
    	       <span style="color: #000000;">&#125;</span>
&nbsp;
    	       <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">set</span> email<span style="color: #000000;">&#40;</span>v<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">String</span></a><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
    	       <span style="color: #000000;">&#123;</span>
    		      _email = v;
    	       <span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> password<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">String</span></a>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">return</span> _password;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">set</span> password<span style="color: #000000;">&#40;</span>v<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">String</span></a><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			_password = v;
		<span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre>
</div>
</div>
<p>You can find the working application here <a href="http://www2.themorphicgroup.com/projects/celebrationEventList/" target="_blank">"CelebrationEvent"</a>. I am still adding more features and fixing some issues but the setup is the same. Check it out.</p>
<p style="margin-bottom: 0in;"><strong>Array to ArrayCollection</strong></p>
<p style="margin-bottom: 0in;">Just something to point out... One question comes to mind when working with AMFPHP and Flex... How to convert arrays in php to  ArrayCollection for Flex/Actionscript? I found the best idea for me was to convert the array within the result call.</p>
<p style="margin-bottom: 0in;" align="left"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"><span style="color: #6699cc;"><strong>...</strong></span></span></span></p>
<p style="margin-bottom: 0in;" align="left"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"><span style="color: #6699cc;"><strong>var</strong></span><span style="color: #000000;"> dataProvider:ArrayCollection = </span><span style="color: #0033ff;"><strong>new</strong></span><span style="color: #000000;"> ArrayCollection(event.result </span><span style="color: #0033ff;"><strong>as</strong></span><span style="color: #000000;"> Array);</span></span></span></p>
<p style="margin-bottom: 0in;">…</p>
<p style="margin-bottom: 0in;">For more on this subject check out this blog from <a href="http://wadearnold.com/blog/flash/amfphp/amfphp-arraycollection" target="_blank">Wade Arnald - AMFPHP ArrayCollection</a></p>
<p style="margin-bottom: 0in;"><strong>Conclusion</strong></p>
<p style="margin-bottom: 0in;">I can't praise Adobe enough with the improvement of the debugging process. Now you have a network monitor where you can see the data packet and inspect the request and response. You can set conditional breakpoints ..  Check out this video blog by<a href="http://www.iheartair.com/?p=322" target="_blank"> Jun Heider</a> (thanks Seth)</p>
<p style="margin-bottom: 0in;">
<p style="margin-bottom: 0in;">The path from Illustrator file to Flash Catalyst to Flash Builder was pretty straight forward. I did have a few weird moments in Flash Catalyst.</p>
<ul>
<li>
<p style="margin-bottom: 0in;">I don't have Illustrator CS 4. So I 	couldn't edit any text or assets in Flash Catalyst. It would be nice to be 	able to have this functionality but I understand the push 	to most recent version of Adobe products.</p>
</li>
<li>
<p style="margin-bottom: 0in;">In Flash Catalyst, I wanted to change 	every component name to a logical naming convention. That didn't go 	so well. You can select the component in the library but there is no 	preview and no selection on the stage.</p>
</li>
<li>
<p style="margin-bottom: 0in;">Within Flash Catalyst, make sure you copy from the last 	state that you created when creating new states. I made some mistakes in a few tests assuming that I could copy through states. Not a good idea.</p>
</li>
<li>
<p style="margin-bottom: 0in;">The code that is generated when 	you import your Catalyst project to Flash Builder 4 is impressive 	but still bulky. A developer would still have a intense chore to 	wire it up the application properly. And with that … try to use a design pattern 	or established framework with what is given? One big Main class. I'm 	still scratching my head on what to do on that issue.</p>
</li>
</ul>
<p style="margin-bottom: 0in;">
<p style="margin-bottom: 0in;">With all these criticisms I do understand that this is beta software... I will say that Flash Catalyst is a great tool to start putting the pieces together. In fact, I don't think I could start a Flex 4 (with Spark component) project without Flash Catalyst at the start. I have a lot of hope in the evolution of the Flash Platform.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.themorphicgroup.com/blog/2009/06/25/a-chat-about-php-with-flash-builder-4-and-adobe-catalyst/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Adobe Flash Builder and Catalyst Tips, Tricks, and Hacks</title>
		<link>http://www.themorphicgroup.com/blog/2009/06/23/adobe-flash-builder-and-catalyst-tips-tricks-and-hacks/</link>
		<comments>http://www.themorphicgroup.com/blog/2009/06/23/adobe-flash-builder-and-catalyst-tips-tricks-and-hacks/#comments</comments>
		<pubDate>Tue, 23 Jun 2009 17:04:19 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.themorphicgroup.com/blog/?p=86</guid>
		<description><![CDATA[Adobe Catalyst was released at the beginning of June with great fanfare, and with that positive buzz a lot of tutorials have been created that demonstrate how quickly a developer can go from a Catalyst project to a Flash Builder project to a working application. However, there aren't many tutorials on how to go back [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://labs.adobe.com/technologies/flashcatalyst/">Adobe Catalyst</a> was released at the beginning of June with great fanfare, and with that positive buzz a lot of <a href="http://labs.adobe.com/technologies/flashcatalyst/tutorials/">tutorials</a> have been created that demonstrate how quickly a developer can go from a Catalyst project to a <a href="http://livedocs.adobe.com/flex/gumbo/html/WS65aa2914f20a58ebd123e2512119993c71-8000.html">Flash Builder</a> project to a working application. However, there aren't many tutorials on how to go back and forth between Catalyst and Flash Builder during production. The reason is that this type of &quot;roundtrip&quot; functionality doesn't officially exist (yet.) Currently, once a developer modifies the Catalyst generated code to hook buttons to handlers or data lists to services they void their warranty with Catalyst. Conversly, Catalyst can't read fxp files generated by Flash Builder, nor can a developer simply just reimport the project from Catalyst without their custom code getting overwritten.</p>
<p>With these limitations, it seems like Catalyst is limited to prototyping. Subsequently the burden of converting a design to a functioning application and implementing design revisions still predominately rests on the shoulders of the developer. </p>
<p>After working with Catalyst and Flash Builder for the past couple of days, I think I have a process in place that keeps Catalyst involved in the course of a production cycle. With these tips and tricks, you should be able to frequently reimport a Catalyst project and have your Flash Builder project update without having to worry about the aforementioned pitfalls of code getting lost/overwritten.</p>
<p><strong>Keep your Catalyst project flat</strong>.</p>
<p>What do I mean by &quot;flat?&quot; When I first started working with Catalyst, I created complex components within complex components. For example, I would create a screen component. Then inside that screen component, I would create a panel component. Inside that panel component I would create a button. This may seem natural and a great way to organize your UI elements, but because you currently cannot declare what the &quot;id&quot; attribute of a component is in Catalyst there isn't a way for you to do something like put a click handler on your button without going into that panel component and adding it in the code with Flash Builder. This, as I mentioned earlier, voids your warranty with Catalyst. So how can you avoid this situation?</p>
<p>Keep all of your components on the root layer of your project. </p>
<p>Avoid having components embedded in components. </p>
<p>If you do this, when you import your Catalyst project into Flash Builder you'll be able pick and choose what components you want to use and where you will want to use them.</p>
<p><strong>Think in terms of skins and not components.</strong></p>
<p>When I say &quot;skin,&quot; I do not mean a <a href="http://danorlando.com/?p=374">Spark</a> <a href="http://livedocs.adobe.com/flex/gumbo/langref/spark/skins/SparkSkin.html">Skin</a> in the strictest sense. This is because Catalyst can only declare a component as being a <a href="http://livedocs.adobe.com/flex/gumbo/langref/spark/components/Button.html">Button</a>, <a href="http://livedocs.adobe.com/flex/gumbo/langref/spark/components/TextInput.html">TextInput</a>, DataList, or a Custom Component. Hopefully, Adobe will add this feature in a future beta. In the meantime, I tend to create custom components to act as backgrounds and other parts for my Flash Builder components. (I will demonstrate how to execute this later in the post.)</p>
<p><strong> Be sure to give good names to your Catalyst components</strong>.</p>
<p>As you build custom components, be sure to go into the library panel for your project in Catalyst and change the names to something more meaningful than &quot;CustomComponent1.&quot;</p>
<p><strong>Don't touch the components from Catalyst after importing them into Flash Builder.</strong></p>
<p>By default, Catalyst puts all of your custom components in a &quot;components&quot; directory. If you select &quot;code&quot; from the view options in the upper right, you can see this directory structure. When you create a new Flex project from your Catalyst fxp file or import it into an existing Flex project, you will also see this folder. Do not touch or modify the code of the components in this directory. If you do, do so at your own risk. Just keep in mind that all of your code in this components directory will get overwritten  with a later import.</p>
<p>Note: I tried changing this folder structure in code view of Catalyst, but it seems to break the design view of Catalyst.</p>
<p><strong>Implement Catalyst custom components as &quot;skins.&quot;</strong></p>
<p>Here's a mxml component I created in Flash Builder called MyPanel.mxml that uses two custom components I created in Catalyst:</p>
<pre class="actionscript3" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>Group
     xmlns<span style="color: #000000; font-weight: bold;">:</span>fx=<span style="color: #990000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span>
     xmlns<span style="color: #000000; font-weight: bold;">:</span>s=<span style="color: #990000;">&quot;library://ns.adobe.com/flex/spark&quot;</span>
     xmlns<span style="color: #000000; font-weight: bold;">:</span>mx=<span style="color: #990000;">&quot;library://ns.adobe.com/flex/halo&quot;</span>
     <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;100%&quot;</span>
     <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;100%&quot;</span>
     xmlns<span style="color: #000000; font-weight: bold;">:</span>components=<span style="color: #990000;">&quot;components.*&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
     <span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>layout<span style="color: #000000; font-weight: bold;">&gt;</span>
          <span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>BasicLayout<span style="color: #000000; font-weight: bold;">/&gt;</span>
     <span style="color: #000000; font-weight: bold;">&lt;/</span>s<span style="color: #000000; font-weight: bold;">:</span>layout<span style="color: #000000; font-weight: bold;">&gt;</span>
     <span style="color: #000000; font-weight: bold;">&lt;</span>components<span style="color: #000000; font-weight: bold;">:</span>MyCatalystPanelBG id=<span style="color: #990000;">&quot;myPanelBG&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
     <span style="color: #000000; font-weight: bold;">&lt;</span>components<span style="color: #000000; font-weight: bold;">:</span>MyCatalystHeaderBG id=<span style="color: #990000;">&quot;myPanelHeaderBG&quot;</span> <span style="color: #004993;">left</span>=<span style="color: #990000;">&quot;5&quot;</span> <span style="color: #004993;">top</span>=<span style="color: #990000;">&quot;5&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;/</span>s<span style="color: #000000; font-weight: bold;">:</span>Group<span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;</pre>
<p>By using BasicLayout I can overlap these elements and position them exactly where I want. To add the actual contents of this panel (like buttons, textinputs, lists, etc...) I just add them after the two custom Catalyst components like so:</p>
<pre class="actionscript3" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>Group
     xmlns<span style="color: #000000; font-weight: bold;">:</span>fx=<span style="color: #990000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span>
     xmlns<span style="color: #000000; font-weight: bold;">:</span>s=<span style="color: #990000;">&quot;library://ns.adobe.com/flex/spark&quot;</span>
     xmlns<span style="color: #000000; font-weight: bold;">:</span>mx=<span style="color: #990000;">&quot;library://ns.adobe.com/flex/halo&quot;</span>
     <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;100%&quot;</span>
     <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;100%&quot;</span>
     xmlns<span style="color: #000000; font-weight: bold;">:</span>components=<span style="color: #990000;">&quot;components.*&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
     <span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>layout<span style="color: #000000; font-weight: bold;">&gt;</span>
          <span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>BasicLayout<span style="color: #000000; font-weight: bold;">/&gt;</span>
     <span style="color: #000000; font-weight: bold;">&lt;/</span>s<span style="color: #000000; font-weight: bold;">:</span>layout<span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
     <span style="color: #000000; font-weight: bold;">&lt;</span>components<span style="color: #000000; font-weight: bold;">:</span>MyCatalystPanelBG id=<span style="color: #990000;">&quot;myPanelBG&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
     <span style="color: #000000; font-weight: bold;">&lt;</span>components<span style="color: #000000; font-weight: bold;">:</span>MyCatalystHeaderBG id=<span style="color: #990000;">&quot;myPanelHeaderBG&quot;</span> <span style="color: #004993;">left</span>=<span style="color: #990000;">&quot;5&quot;</span> <span style="color: #004993;">top</span>=<span style="color: #990000;">&quot;5&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
&nbsp;
     <span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>TextInput
          id=<span style="color: #990000;">&quot;searchTextInput&quot;</span>
          <span style="color: #004993;">right</span>=<span style="color: #990000;">&quot;7&quot;</span>
          <span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;Enter search criteria here&quot;</span>
          <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;7&quot;</span>
     <span style="color: #000000; font-weight: bold;">/&gt;</span>
     <span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>List
          id=<span style="color: #990000;">&quot;itemsList&quot;</span>
          <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;100%&quot;</span> <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;100%&quot;</span>
          <span style="color: #004993;">top</span>=<span style="color: #990000;">&quot;40&quot;</span>
          <span style="color: #004993;">left</span>=<span style="color: #990000;">&quot;10&quot;</span>
          <span style="color: #004993;">right</span>=<span style="color: #990000;">&quot;10&quot;</span>
          <span style="color: #004993;">bottom</span>=<span style="color: #990000;">&quot;10&quot;</span>
&nbsp;
          <span style="color: #000000; font-weight: bold;">/&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;/</span>s<span style="color: #000000; font-weight: bold;">:</span>Group<span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;</pre>
<p>The beauty with this approach is that if something changes in the Catalyst project, I can import it again without having to worry about losing the business code I have written in Flash Builder.</p>
<p><strong>Use <a href="http://livedocs.adobe.com/flex/gumbo/langref/spark/components/Group.html#propertySummary">mxmlContent</a> to make skins automatically resize</strong>.</p>
<p>You may have noticed in Catalyst you can only declare the height and width of elements as fixed numbers and not percentages. This may be suitable when creating a prototype, but a good Flex app needs to be able to resize as browser height and widths change. The solution? With the new Spark Group component there is a property called &quot;mxmlContent&quot; that is an array of all of the visible children of the component. How do we use this? Let's say the mxml for the component MyCatalystPanelBG looks like this:</p>
<pre class="actionscript3" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>Group xmlns<span style="color: #000000; font-weight: bold;">:</span>s=<span style="color: #990000;">&quot;library://ns.adobe.com/flex/spark&quot;</span> xmlns<span style="color: #000000; font-weight: bold;">:</span>fx=<span style="color: #990000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span> xmlns<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">d</span>=<span style="color: #990000;">&quot;http://ns.adobe.com/fxg/2008/dt&quot;</span> xmlns<span style="color: #000000; font-weight: bold;">:</span>components=<span style="color: #990000;">&quot;components.*&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
     <span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>Rect <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;0.5&quot;</span> <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;700&quot;</span> radiusX=<span style="color: #990000;">&quot;10&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;238&quot;</span> <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;0.5&quot;</span> radiusY=<span style="color: #990000;">&quot;10&quot;</span> <span style="color: #004993;">d</span><span style="color: #000000; font-weight: bold;">:</span>userLabel=<span style="color: #990000;">&quot;PanelBG&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
          <span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>stroke<span style="color: #000000; font-weight: bold;">&gt;</span>
               <span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>SolidColorStroke weight=<span style="color: #990000;">&quot;1&quot;</span> caps=<span style="color: #990000;">&quot;none&quot;</span> joints=<span style="color: #990000;">&quot;miter&quot;</span> miterLimit=<span style="color: #990000;">&quot;4&quot;</span> <span style="color: #004993;">color</span>=<span style="color: #990000;">&quot;#808080&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
          <span style="color: #000000; font-weight: bold;">&lt;/</span>s<span style="color: #000000; font-weight: bold;">:</span>stroke<span style="color: #000000; font-weight: bold;">&gt;</span>
          <span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>fill<span style="color: #000000; font-weight: bold;">&gt;</span>
               <span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>LinearGradient <span style="color: #004993;">rotation</span>=<span style="color: #990000;">&quot;90&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
                    <span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>GradientEntry <span style="color: #004993;">color</span>=<span style="color: #990000;">&quot;#ffffff&quot;</span> <span style="color: #004993;">alpha</span>=<span style="color: #990000;">&quot;1.0&quot;</span> ratio=<span style="color: #990000;">&quot;0&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
                    <span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>GradientEntry <span style="color: #004993;">color</span>=<span style="color: #990000;">&quot;#d8d8d8&quot;</span> <span style="color: #004993;">alpha</span>=<span style="color: #990000;">&quot;1.0&quot;</span> ratio=<span style="color: #990000;">&quot;1&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
               <span style="color: #000000; font-weight: bold;">&lt;/</span>s<span style="color: #000000; font-weight: bold;">:</span>LinearGradient<span style="color: #000000; font-weight: bold;">&gt;</span>
          <span style="color: #000000; font-weight: bold;">&lt;/</span>s<span style="color: #000000; font-weight: bold;">:</span>fill<span style="color: #000000; font-weight: bold;">&gt;</span>
     <span style="color: #000000; font-weight: bold;">&lt;/</span>s<span style="color: #000000; font-weight: bold;">:</span>Rect<span style="color: #000000; font-weight: bold;">&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;/</span>s<span style="color: #000000; font-weight: bold;">:</span>Group<span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;</pre>
<p>We can make this background scale with our panel component by doing the following:</p>
<p>Add a &quot;<a href="http://livedocs.adobe.com/flex/gumbo/langref/mx/core/UIComponent.html#event:creationComplete">creationComplete</a>&quot; handler in MyPanel.mxml.</p>
<pre class="actionscript3" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>Group
     xmlns<span style="color: #000000; font-weight: bold;">:</span>fx=<span style="color: #990000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span>
     xmlns<span style="color: #000000; font-weight: bold;">:</span>s=<span style="color: #990000;">&quot;library://ns.adobe.com/flex/spark&quot;</span>
     xmlns<span style="color: #000000; font-weight: bold;">:</span>mx=<span style="color: #990000;">&quot;library://ns.adobe.com/flex/halo&quot;</span>
     <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;100%&quot;</span>
     <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;100%&quot;</span>
     xmlns<span style="color: #000000; font-weight: bold;">:</span>components=<span style="color: #990000;">&quot;components.*&quot;</span>
     creationComplete=<span style="color: #990000;">&quot;onCC()&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
          <span style="color: #000000; font-weight: bold;">&lt;</span>fx<span style="color: #000000; font-weight: bold;">:</span>Script<span style="color: #000000; font-weight: bold;">&gt;</span>
          <span style="color: #000000; font-weight: bold;">&lt;!</span><span style="color: #000000;">&#91;</span>CDATA<span style="color: #000000;">&#91;</span>
               <span style="color: #0033ff; font-weight: bold;">import</span> spark.primitives.Rect;
               <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> onCC<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span>
                    <span style="color: #6699cc; font-weight: bold;">var</span> r<span style="color: #000000; font-weight: bold;">:</span>Rect = myPanelBG.mxmlContent<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#93;</span> <span style="color: #0033ff; font-weight: bold;">as</span> Rect;
                    r.<span style="color: #004993;">top</span> = <span style="color: #000000; font-weight:bold;">0</span>;
                    r.<span style="color: #004993;">left</span> = <span style="color: #000000; font-weight:bold;">0</span>;
                    r.<span style="color: #004993;">right</span>=<span style="color: #000000; font-weight:bold;">0</span>;
                    r.<span style="color: #004993;">bottom</span>=<span style="color: #000000; font-weight:bold;">0</span>;
               <span style="color: #000000;">&#125;</span>
           <span style="color: #000000;">&#93;</span><span style="color: #000000;">&#93;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
     <span style="color: #000000; font-weight: bold;">&lt;/</span>fx<span style="color: #000000; font-weight: bold;">:</span>Script<span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;</pre>
<p>Also be sure to set the height and width of the &quot;myPanelBG&quot; to 100%.</p>
<pre class="actionscript3" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;</span>components<span style="color: #000000; font-weight: bold;">:</span>MyCatalystPanelBG id=<span style="color: #990000;">&quot;myPanelBG&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;100%&quot;</span> <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;100%&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
&nbsp;</pre>
<p>The mxmlContent property is nice in that you don't have to worry about looping through sub children like you do with &quot;getChildAt(i)&quot; to get to what you want. This line of code basically says &quot;get the first content item which is a rectangle element and set its right, top, bottom, and left properties to 0.&quot;</p>
<p>NOTE: This hack is very dependent that the order of elements don't change in your Catalyst components. Whenever updating these components you may need to check to see if the structure has changed in these components. You could do something like have a loop that goes through all of the items in mxmlContent and changes these properties on any <a href="http://livedocs.adobe.com/flex/gumbo/langref/spark/primitives/Rect.html">Rect</a>s.</p>
<p><strong>To bind strings to text items in a Catalyst custom component, use BindUtil.</strong></p>
<p>Let's say you have a <a href="http://livedocs.adobe.com/flex/gumbo/langref/spark/primitives/RichText.html">RichText</a> component inside your header &quot;skin:&quot;</p>
<pre class="actionscript3" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>Group xmlns<span style="color: #000000; font-weight: bold;">:</span>s=<span style="color: #990000;">&quot;library://ns.adobe.com/flex/spark&quot;</span> xmlns<span style="color: #000000; font-weight: bold;">:</span>fx=<span style="color: #990000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span> xmlns<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">d</span>=<span style="color: #990000;">&quot;http://ns.adobe.com/fxg/2008/dt&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
     <span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>Rect <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;0.5&quot;</span> <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;23&quot;</span> radiusX=<span style="color: #990000;">&quot;5&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;737&quot;</span> <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;0.5&quot;</span> radiusY=<span style="color: #990000;">&quot;5&quot;</span> <span style="color: #004993;">d</span><span style="color: #000000; font-weight: bold;">:</span>userLabel=<span style="color: #990000;">&quot;Header BG&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
          <span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>fill<span style="color: #000000; font-weight: bold;">&gt;</span>
               <span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>LinearGradient <span style="color: #004993;">rotation</span>=<span style="color: #990000;">&quot;90&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
                    <span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>GradientEntry <span style="color: #004993;">color</span>=<span style="color: #990000;">&quot;#bf0000&quot;</span> <span style="color: #004993;">alpha</span>=<span style="color: #990000;">&quot;1.0&quot;</span> ratio=<span style="color: #990000;">&quot;0&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
                    <span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>GradientEntry <span style="color: #004993;">color</span>=<span style="color: #990000;">&quot;#7f0000&quot;</span> <span style="color: #004993;">alpha</span>=<span style="color: #990000;">&quot;1.0&quot;</span> ratio=<span style="color: #990000;">&quot;1&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
               <span style="color: #000000; font-weight: bold;">&lt;/</span>s<span style="color: #000000; font-weight: bold;">:</span>LinearGradient<span style="color: #000000; font-weight: bold;">&gt;</span>
          <span style="color: #000000; font-weight: bold;">&lt;/</span>s<span style="color: #000000; font-weight: bold;">:</span>fill<span style="color: #000000; font-weight: bold;">&gt;</span>
          <span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>stroke<span style="color: #000000; font-weight: bold;">&gt;</span>
               <span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>SolidColorStroke <span style="color: #004993;">color</span>=<span style="color: #990000;">&quot;#7f0000&quot;</span> caps=<span style="color: #990000;">&quot;none&quot;</span> joints=<span style="color: #990000;">&quot;miter&quot;</span> miterLimit=<span style="color: #990000;">&quot;4&quot;</span> weight=<span style="color: #990000;">&quot;1&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
          <span style="color: #000000; font-weight: bold;">&lt;/</span>s<span style="color: #000000; font-weight: bold;">:</span>stroke<span style="color: #000000; font-weight: bold;">&gt;</span>
     <span style="color: #000000; font-weight: bold;">&lt;/</span>s<span style="color: #000000; font-weight: bold;">:</span>Rect<span style="color: #000000; font-weight: bold;">&gt;</span>
     <span style="color: #000000; font-weight: bold;">&lt;</span>s<span style="color: #000000; font-weight: bold;">:</span>RichText <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;5&quot;</span> <span style="color: #004993;">color</span>=<span style="color: #990000;">&quot;#ffffff&quot;</span> <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;7&quot;</span> <span style="color: #004993;">fontSize</span>=<span style="color: #990000;">&quot;17&quot;</span> fontFamily=<span style="color: #990000;">&quot;Arial&quot;</span> fontWeight=<span style="color: #990000;">&quot;bold&quot;</span> <span style="color: #004993;">d</span><span style="color: #000000; font-weight: bold;">:</span>userLabel=<span style="color: #990000;">&quot;Title&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;/</span>s<span style="color: #000000; font-weight: bold;">:</span>Group<span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;</pre>
<p>To bind the RichText component to a property in MyPanel.mxml do the following.</p>
<p>Add a title variable to MyPanel.mxml:</p>
<pre class="actionscript3" style="font-family:monospace;">&nbsp;
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> title<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">String</span></a> = <span style="color: #990000;">&quot;My Panel Title&quot;</span>
&nbsp;</pre>
<p>In the creation complete handler add the following:</p>
<pre class="actionscript3" style="font-family:monospace;">&nbsp;
BindingUtils.bindProperty<span style="color: #000000;">&#40;</span>myPanelHeaderBG.mxmlContent<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#93;</span>, <span style="color: #990000;">&quot;text&quot;</span>, <span style="color: #0033ff; font-weight: bold;">this</span>, <span style="color: #990000;">&quot;title&quot;</span><span style="color: #000000;">&#41;</span>;
&nbsp;</pre>
<p>In this scenario, the RichText component is the second item hence the &quot;mxmlContent[1].&quot; That's all you need.</p>
<p><strong>To manage your Catalyst component's state bind it to your Flash Builder component's state.</strong></p>
<p>Let's say you want your &quot;skin&quot; component to have it's state mirror your component that you've written in Flash Builder. To do this all you have to do is this:</p>
<pre class="actionscript3" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;</span>components<span style="color: #000000; font-weight: bold;">:</span>MyCatalystPanelBG id=<span style="color: #990000;">&quot;myPanelBG&quot;</span> currentState=<span style="color: #990000;">&quot;{this.currentState}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
&nbsp;</pre>
<p>Note: You need to be sure that you've created all of the necessary states in Catalyst for your skin.</p>
<p><strong>Make your bitmap artwork in Catalyst custom components</strong></p>
<p>This will make managing and swapping out bitmaps much easier as your app's design evolves.</p>
<p><strong>Summary</strong></p>
<p>That should basically do it. A lot of what I have prescribed in here is a bit of a hack until Adobe expands Catalyst's abilities beyond prototyping. However, in the meantime this is still a workable solution to leverage Catalysts abilities in your production phase of your project.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.themorphicgroup.com/blog/2009/06/23/adobe-flash-builder-and-catalyst-tips-tricks-and-hacks/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>How to Create a Spark Icon Button and Skin</title>
		<link>http://www.themorphicgroup.com/blog/2009/06/18/how-to-create-a-spark-icon-button-and-skin/</link>
		<comments>http://www.themorphicgroup.com/blog/2009/06/18/how-to-create-a-spark-icon-button-and-skin/#comments</comments>
		<pubDate>Thu, 18 Jun 2009 18:39:29 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.themorphicgroup.com/blog/?p=83</guid>
		<description><![CDATA[With the new spark components in MXML 2009 you may have noticed there is not longer an "icon" style property you can set for a button. So what do you do if you want an icon in your button? One solution is to put the icon in your button skin, but this would require you [...]]]></description>
			<content:encoded><![CDATA[<p>With the new spark components in MXML 2009 you may have noticed there is not longer an "icon" style property you can set for a button. So what do you do if you want an icon in your button?</p>
<p>One solution is to put the icon in your button skin, but this would require you to build multiple skins for multiple icons.</p>
<p>Another solution is to use an Image component as a button. However, let's say we want to have different icons used for different rollover states. We could definitely use MouseEvent event listeners to switch the source property of the Image component. Unfortunately, transparent pixels in an image have been known to cause problems with MouseEvents firing properly. To avoid these type of pitfalls, we are going to create our own custom component by doing the following:<br />
<span id="more-83"></span></p>
<div><strong>Create a new IconButton class that extends spark.components.Button</strong></div>
<div>
<pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> com.tmg.components
<span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> spark.components.Button;
&nbsp;
	<span style="color: #009900;">//icons</span>
	<span style="color: #000000;">&#91;</span>Style<span style="color: #000000;">&#40;</span><span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;iconUp&quot;</span>,<span style="color: #004993;">type</span>=<span style="color: #990000;">&quot;*&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
	<span style="color: #000000;">&#91;</span>Style<span style="color: #000000;">&#40;</span><span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;iconOver&quot;</span>,<span style="color: #004993;">type</span>=<span style="color: #990000;">&quot;*&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
	<span style="color: #000000;">&#91;</span>Style<span style="color: #000000;">&#40;</span><span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;iconDown&quot;</span>,<span style="color: #004993;">type</span>=<span style="color: #990000;">&quot;*&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
	<span style="color: #000000;">&#91;</span>Style<span style="color: #000000;">&#40;</span><span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;iconDisabled&quot;</span>,<span style="color: #004993;">type</span>=<span style="color: #990000;">&quot;*&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
	<span style="color: #009900;">//paddings</span>
	<span style="color: #000000;">&#91;</span>Style<span style="color: #000000;">&#40;</span><span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;paddingLeft&quot;</span>,<span style="color: #004993;">type</span>=<span style="color: #990000;">&quot;Number&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
	<span style="color: #000000;">&#91;</span>Style<span style="color: #000000;">&#40;</span><span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;paddingRight&quot;</span>,<span style="color: #004993;">type</span>=<span style="color: #990000;">&quot;Number&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
	<span style="color: #000000;">&#91;</span>Style<span style="color: #000000;">&#40;</span><span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;paddingTop&quot;</span>,<span style="color: #004993;">type</span>=<span style="color: #990000;">&quot;Number&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
	<span style="color: #000000;">&#91;</span>Style<span style="color: #000000;">&#40;</span><span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;paddingBottom&quot;</span>,<span style="color: #004993;">type</span>=<span style="color: #990000;">&quot;Number&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> IconButton extends Button
	<span style="color: #000000;">&#123;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> IconButton<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre>
</div>
<div>
<p>In this class we define Style Metadata tags to let Flash Builder know what styles are available for this component in addition to the default style properties of Button. With this component, we want the developer to be able to specify images for different states of the button. We also want to give the developer the ability to specify the padding around the elements of our button.</p>
</div>
<div><strong>Create a skin mxml component</strong></div>
<div>
<pre class="mxml" style="font-family:monospace;">&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:SparkSkin</span></span>
<span style="color: #000000;">	xmlns:fx=<span style="color: #ff0000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span></span>
<span style="color: #000000;">	xmlns:s=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&quot;</span></span>
<span style="color: #000000;">	xmlns:mx=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/halo&quot;</span></span>
<span style="color: #000000;">	currentStateChanging=<span style="color: #ff0000;">&quot;onCurrentStateChanging(event)&quot;</span></span>
<span style="color: #000000;">	<span style="color: #7400FF;">&gt;</span></span>
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Metadata</span><span style="color: #7400FF;">&gt;</span></span>
		[HostComponent(&quot;com.freckle.oceania.client.view.components.IconButton&quot;)]
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Metadata</span><span style="color: #7400FF;">&gt;</span></span>
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Script</span><span style="color: #7400FF;">&gt;</span></span>
		<span style="color: #000000;">&lt;!<span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span></span>
<span style="color: #000000;">			import mx.events.StateChangeEvent;</span>
&nbsp;
<span style="color: #000000;">			private function onCurrentStateChanging<span style="color: #66cc66;">&#40;</span>event:StateChangeEvent<span style="color: #66cc66;">&#41;</span>:void<span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">				switch<span style="color: #66cc66;">&#40;</span>event.newState<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">					case <span style="color: #ff0000;">&quot;up&quot;</span>:</span>
<span style="color: #000000;">						setIcon<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;iconUp&quot;</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">						break;</span>
<span style="color: #000000;">					case <span style="color: #ff0000;">&quot;over&quot;</span>:</span>
<span style="color: #000000;">						setIcon<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;iconOver&quot;</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">						break;</span>
<span style="color: #000000;">					case <span style="color: #ff0000;">&quot;down&quot;</span>:</span>
<span style="color: #000000;">						setIcon<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;iconDown&quot;</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">						break;</span>
<span style="color: #000000;">					case <span style="color: #ff0000;">&quot;disabled&quot;</span>:</span>
<span style="color: #000000;">						setIcon<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;iconDisabled&quot;</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">						break;</span>
<span style="color: #000000;">				<span style="color: #66cc66;">&#125;</span></span>
<span style="color: #000000;">			<span style="color: #66cc66;">&#125;</span></span>
<span style="color: #000000;">			private function setIcon<span style="color: #66cc66;">&#40;</span>type:String<span style="color: #66cc66;">&#41;</span>:void<span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">				if<span style="color: #66cc66;">&#40;</span>hostComponent.getStyle<span style="color: #66cc66;">&#40;</span>type<span style="color: #66cc66;">&#41;</span> != null<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">					icon.source = hostComponent.getStyle<span style="color: #66cc66;">&#40;</span>type<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">				<span style="color: #66cc66;">&#125;</span></span>
<span style="color: #000000;">			<span style="color: #66cc66;">&#125;</span></span>
&nbsp;
<span style="color: #000000;">		<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #7400FF;">&gt;</span></span>
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Script</span><span style="color: #7400FF;">&gt;</span></span>
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:layout</span><span style="color: #7400FF;">&gt;</span></span>
		<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:BasicLayout</span><span style="color: #7400FF;">/&gt;</span></span>
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:layout</span><span style="color: #7400FF;">&gt;</span></span>
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:states</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:State</span> name=<span style="color: #ff0000;">&quot;up&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:State</span> name=<span style="color: #ff0000;">&quot;over&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:State</span> name=<span style="color: #ff0000;">&quot;down&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:State</span> name=<span style="color: #ff0000;">&quot;disabled&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:states</span><span style="color: #7400FF;">&gt;</span></span> 
&nbsp;
 	<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Rect</span> left=<span style="color: #ff0000;">&quot;0&quot;</span> right=<span style="color: #ff0000;">&quot;0&quot;</span> top=<span style="color: #ff0000;">&quot;0&quot;</span> bottom=<span style="color: #ff0000;">&quot;0&quot;</span> width=<span style="color: #ff0000;">&quot;69&quot;</span> height=<span style="color: #ff0000;">&quot;20&quot;</span> radiusX=<span style="color: #ff0000;">&quot;2&quot;</span> radiusY=<span style="color: #ff0000;">&quot;2&quot;</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:stroke</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:SolidColorStroke</span> id=<span style="color: #ff0000;">&quot;outline&quot;</span> weight=<span style="color: #ff0000;">&quot;1&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:stroke</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:fill</span><span style="color: #7400FF;">&gt;</span></span>
        	<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:LinearGradient</span><span style="color: #7400FF;">&gt;</span></span>
        		<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:GradientEntry</span> color=<span style="color: #ff0000;">&quot;#ffffff&quot;</span> ratio=<span style="color: #ff0000;">&quot;0&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
        		<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:GradientEntry</span> color=<span style="color: #ff0000;">&quot;#cccccc&quot;</span> ratio=<span style="color: #ff0000;">&quot;1&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
        	<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:LinearGradient</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:fill</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Rect</span><span style="color: #7400FF;">&gt;</span></span>
 	<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Group</span></span>
<span style="color: #000000;"> 		horizontalCenter=<span style="color: #ff0000;">&quot;0&quot;</span></span>
<span style="color: #000000;"> 		verticalCenter=<span style="color: #ff0000;">&quot;0&quot;</span></span>
<span style="color: #000000;"> 		<span style="color: #7400FF;">&gt;</span></span>
 		<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:layout</span><span style="color: #7400FF;">&gt;</span></span>
 			<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:HorizontalLayout</span></span>
<span style="color: #000000;"> 				paddingBottom=<span style="color: #ff0000;">&quot;{ hostComponent.getStyle('paddingBottom')}&quot;</span></span>
<span style="color: #000000;"> 				paddingTop=<span style="color: #ff0000;">&quot;{ hostComponent.getStyle('paddingTop')}&quot;</span></span>
<span style="color: #000000;"> 				paddingLeft=<span style="color: #ff0000;">&quot;{ hostComponent.getStyle('paddingLeft')}&quot;</span></span>
<span style="color: #000000;"> 				paddingRight=<span style="color: #ff0000;">&quot;{ hostComponent.getStyle('paddingRight')}&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
 		<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:layout</span><span style="color: #7400FF;">&gt;</span></span>
 		<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Image</span></span>
<span style="color: #000000;">	    	id=<span style="color: #ff0000;">&quot;icon&quot;</span></span>
<span style="color: #000000;">	    	source=<span style="color: #ff0000;">&quot;{hostComponent.getStyle('iconUp')}&quot;</span></span>
<span style="color: #000000;">	    	verticalCenter=<span style="color: #ff0000;">&quot;0&quot;</span></span>
<span style="color: #000000;">	    	alpha=<span style="color: #ff0000;">&quot;{(this.currentState == 'up')?.5:1}&quot;</span></span>
<span style="color: #000000;">	    	<span style="color: #7400FF;">/&gt;</span></span>
	    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:SimpleText</span></span>
<span style="color: #000000;">	    	text=<span style="color: #ff0000;">&quot;{hostComponent.label}&quot;</span></span>
<span style="color: #000000;">	    	verticalCenter=<span style="color: #ff0000;">&quot;0&quot;</span></span>
<span style="color: #000000;">	    	includeInLayout=<span style="color: #ff0000;">&quot;{( hostComponent.label != '' )}&quot;</span></span>
<span style="color: #000000;">	    	visible=<span style="color: #ff0000;">&quot;{( hostComponent.label != '' )}&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
 	<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Group</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:SparkSkin</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;</pre>
</div>
<p>One of the first things you may notice is the Metadata tag declaring the Hostcomponent. This is important because it lets this skin component know what kind of component will be using this skin. Note the SimpleText component's text property is set to the hostComponent's label property.</p>
<p>Another key element to this piece of code is the event handler for when the state changes. As you may have guessed from the contents of the states tag, the hostComponent changes the state of this skin for the different button mouse states. By listening to this event, we can change the current source of the icon image component.</p>
<p>This brings us to our last step...</p>
<div><strong>Implement the new component</strong></div>
<div>
<pre class="mxml" style="font-family:monospace;"><span style="color: #000000;"><span style="color: #7400FF;">&lt;components:IconButton</span></span>
<span style="color: #000000;">		width=<span style="color: #ff0000;">&quot;100%&quot;</span></span>
<span style="color: #000000;">		iconUp=<span style="color: #ff0000;">&quot;assets/images/icons/toolbar/arrow_out.png&quot;</span></span>
<span style="color: #000000;">		iconDisabled=<span style="color: #ff0000;">&quot;assets/images/icons/toolbar/arrow_out_disabled.png&quot;</span></span>
<span style="color: #000000;">		fontFamily=<span style="color: #ff0000;">&quot;Times&quot;</span></span>
<span style="color: #000000;">		fontWeight=<span style="color: #ff0000;">&quot;bold&quot;</span></span>
<span style="color: #000000;">		skinClass=<span style="color: #ff0000;">&quot;com.tmg.skins.IconButtonSkin&quot;</span></span>
<span style="color: #000000;">		paddingLeft=<span style="color: #ff0000;">&quot;5&quot;</span></span>
<span style="color: #000000;">		paddingTop=<span style="color: #ff0000;">&quot;5&quot;</span></span>
<span style="color: #000000;">		paddingRight=<span style="color: #ff0000;">&quot;5&quot;</span></span>
<span style="color: #000000;">		paddingBottom=<span style="color: #ff0000;">&quot;5&quot;</span></span>
<span style="color: #000000;">		<span style="color: #7400FF;">/&gt;</span></span>
&nbsp;</pre>
</div>
<p>When implementing your own skins, be sure to set the skinClass property. In this implementation we just set the iconUp and iconDisabled properties. Because of how we wrote the set icon method in our skin, the skin will only use the icons that have been declared. As for the label, we have also coded the skin to not show the text component if the label text is empty, but in this case we do have a label.</p>
<div><strong>Summary</strong></div>
<p>So there you have it, a brand new component that uses the new MXML 2009 Spark architecture for skinning. With this new approach, we can break out our UI code into it's own file/component. A benefit of this new method is that we don't have much code in the actual component class. By using component skins, we can not only define the look via MXML but we can also add some logic/code. For example, it would be really easy to add a method that spins the icon on rollover or to change the text of label when disabled.</p>
<p>For more information about this, check out: <a href="https://xd.adobe.com/#/videos/video/165">https://xd.adobe.com/#/videos/video/165</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.themorphicgroup.com/blog/2009/06/18/how-to-create-a-spark-icon-button-and-skin/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Web Ads with ClickTags</title>
		<link>http://www.themorphicgroup.com/blog/2009/04/10/web-ads-with-clicktags/</link>
		<comments>http://www.themorphicgroup.com/blog/2009/04/10/web-ads-with-clicktags/#comments</comments>
		<pubDate>Fri, 10 Apr 2009 20:54:47 +0000</pubDate>
		<dc:creator>Unknown Morphician</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[ClickTag]]></category>
		<category><![CDATA[flash cs3]]></category>
		<category><![CDATA[Web Ad]]></category>

		<guid isPermaLink="false">http://www.themorphicgroup.com/blog/?p=74</guid>
		<description><![CDATA[When creating web ads for third party companies, you maybe asked to add a clickTag, a reference to an external variable. The variable is passed from within the html Object/Embed tags via query string or FlashVar parameter. This allows an ad manager to track the click-through of the Flash SWF. Usually, the ad manager would [...]]]></description>
			<content:encoded><![CDATA[<p>When creating web ads for third party companies, you maybe asked to add a clickTag,<br />
a reference to an external variable. The variable is passed from within the html Object/Embed tags via query string or FlashVar parameter. This allows an ad manager to track the click-through of the<br />
Flash SWF. Usually, the ad manager would create an ad server value with the target url address. As the developer, you need to reference this variable from within your project.</p>
<p>Let's walk though a solution for building a Flash ad (in AS 3.0) with a clickTag. <em>Note: In most cases, ad companies and developers are required to use AS 2.0. There are plenty of great articles that discuss this implementation. There is an adobe article that is widely used <a href="http://www.adobe.com/resources/richmedia/tracking/designers_guide/" target="_new">Designer's Guide: Building Macromedia Flash Banners with Tracking Capabilities</a>. This article will not discuss this how to create ads with clickTags using AS 2.0 .</em></p>
<p>The ad manager will also want to prevent the click-through target from being blocked by any<br />
popup blockers. This usually the case with certain web browsers like IE 7.0+. Note: At this<br />
time there is a new Flash player version out (version 11). I don't know if this issue is fixed.</p>
<p style="margin-bottom: 0in;">So we have three requirements …</p>
<ul>
<li>
<p style="margin-bottom: 0in;">Get a reference to the clickTag 	variable</p>
</li>
<li>
<p style="margin-bottom: 0in;">Build your web ad with AS 3.0</p>
</li>
<li>
<p style="margin-bottom: 0in;">Handle the issue with the Popup 	Blockers</p>
</li>
</ul>
<p>Here is an example of code for satisfying these requirements.</p>
<p>html embed parameter<br />
...<br />
&lt;param name="FlashVars" value="clickTag=http://www.adserver.com/target.php?track=1123" /&gt;<br />
...</p>
<p>actionscript code</p>
<pre><code>
package
{

import flash.external.ExternalInterface;
import flash.net.navigateToURL;
import flash.net.URLRequest;

public class Main extends MovieClip
{
  private var paramList:Object;
  public var clickTag:String = ""; 

  function Main()
  {
    paramList = this.root.loaderInfo.parameters;

    if(paramList["clickTag"] != null)
    {
        clickTag = paramList["clickTag"];
    }

    clickTagBtn.addEventListener(MouseEvent.CLICK, onClick);

  } 

  function onClick( event:MouseEvent ):void
  {
    if( clickTag != ""  )
    {
      var req:URLRequest = new URLRequest(clickTag);

      if ( !ExternalInterface.available )
      {
        navigateToURL(req, "_blank");
      }
      else
      {
        var strUserAgent:String =
          String(ExternalInterface.call(
		"function() {return navigator.userAgent;}"
		)).toLowerCase();

        if ( strUserAgent.indexOf("firefox") != -1 )
        {
          ExternalInterface.call( "window.open", req.url, "_blank" );
        }
        else
        {
          if( strUserAgent.indexOf("msie") != -1 &amp;&amp;
            uint(strUserAgent.substr(strUserAgent.indexOf("msie") + 5, 3)) &gt;= 7 )
          {
            ExternalInterface.call("window.open", req.url, "_top");
          }
          else
          {
            navigateToURL(req, "_top");
          }
        }
      }
    }

  }

}

}

</code></pre>
<p>I am assuming that you are using Flash CS 3 or greater and that Main is your document class for your fla project.</p>
<p style="margin-bottom: 0in;">First I need to get the get the value of the clickTag.</p>
<ul>
<li>
<p style="margin-bottom: 0in;">Reference the 	loaderInfo.parameters as an Object and then reference the key value 	of clickTag.</p>
</li>
<li>
<p style="margin-bottom: 0in;">The character's case is very 	important. Letter case is important, otherwise you won't be able to 	reference this value.</p>
</li>
</ul>
<p style="margin-bottom: 0in;">
<p style="margin-bottom: 0in;">The key to handling the issue with popup blockers is to use a little javascript, with the help of External interface.</p>
<ul>
<li>
<p style="margin-bottom: 0in;">If ExternalInterface is not available, use 	NavigateToUrl directly.</p>
</li>
<li>
<p style="margin-bottom: 0in;">Get the userAgent (browser) 	information via javascript. I use this info to handle browser 	different quirks.</p>
</li>
<li>
<p style="margin-bottom: 0in;">Call the javascript method 	window.open to open the link specified by the clickTag value.  It is 	absolutely necessary to enable AllowScripting for “sameDomain” 	or “always” . Otherwise a security sandbox error will display.</p>
</li>
</ul>
<p>This solution should get you out of most jams in regards to ClickTag functionality using AS 3.0 .</p>
]]></content:encoded>
			<wfw:commentRss>http://www.themorphicgroup.com/blog/2009/04/10/web-ads-with-clicktags/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Paginated DataGrid with Sorting</title>
		<link>http://www.themorphicgroup.com/blog/2009/04/04/paginated-datagrid-with-sorting/</link>
		<comments>http://www.themorphicgroup.com/blog/2009/04/04/paginated-datagrid-with-sorting/#comments</comments>
		<pubDate>Sun, 05 Apr 2009 02:18:48 +0000</pubDate>
		<dc:creator>Unknown Morphician</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[flex DataGrid pagination sorting]]></category>

		<guid isPermaLink="false">http://www.themorphicgroup.com/blog/?p=78</guid>
		<description><![CDATA[In a recent project we built a DataGrid that showed paginated data from a web service. That itself was pretty straight-forward. It eventually required sorting. And of course the sorting feature with DataGrid would only sort the data within a single page when we wanted the sorting to be applied to the entire data set. [...]]]></description>
			<content:encoded><![CDATA[<p>In a recent project we built a DataGrid that showed paginated data from a web service. That itself was pretty straight-forward. It eventually required sorting. And of course the sorting feature with DataGrid would only sort the data within a single page when we wanted the sorting to be applied to the entire data set. So now what? To avoid writing a new DataGrid from scratch, I reread the docs and then dug into the source code ... something I find myself doing all the time. I found that the solution involved listening for and canceling an event and using 2 mx_internal variables.</p>
<p>To demonstrate the paginated sorting, I wrote up the following example that uses hard-coded data:<br />
<a href="http://www2.themorphicgroup.com/projects/examples/paginateddatagrid/" target="_new">PaginatedDataGridExample</a><br />
<a href="http://www2.themorphicgroup.com/projects/examples/paginateddatagrid/srcview/" target="_new">Source View</a></p>
<p>Click on the column headers to sort the data and see that the sorting is applied across the entire data set.</p>
<h3>Pagination</h3>
<p>The PaginatedDataGrid class uses the entireDataProvider property as input to contain the entire data set. The normal dataProvider property represents the data for each page. The bulk of the work is done by the populatePage() method:</p>
<pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #339966; font-weight: bold;">function</span> populatePage<span style="color: #000000;">&#40;</span>pageNum<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">int</span></a><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>_entireDataProvider == <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
		<span style="color: #0033ff; font-weight: bold;">return</span>;
	<span style="color: #000000;">&#125;</span>
	<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">start</span><span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">int</span></a> = pageNum <span style="color: #000000; font-weight: bold;">*</span> pageSize;
	<span style="color: #6699cc; font-weight: bold;">var</span> end<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">int</span></a> = <span style="color: #004993;">start</span> <span style="color: #000000; font-weight: bold;">+</span> pageSize;
	end = <a href="http://www.google.com/search?q=math%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:math.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Math</span></a>.<span style="color: #004993;">min</span><span style="color: #000000;">&#40;</span>_entireCollection.<span style="color: #004993;">length</span>, end<span style="color: #000000;">&#41;</span>;
	_pageDataProvider.<span style="color: #004993;">splice</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span>;
	<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">int</span></a> = <span style="color: #004993;">start</span>; i <span style="color: #000000; font-weight: bold;">&amp;</span>lt; end; i<span style="color: #000000; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
		_pageDataProvider.<span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span>_entireCollection.getItemAt<span style="color: #000000;">&#40;</span>i<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
	<span style="color: #000000;">&#125;</span>
	<span style="color: #0033ff; font-weight: bold;">super</span>.dataProvider = _pageDataProvider;
	<span style="color: #009900;">// apply sorting that was lost due to dataProvider change</span>
	<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>_savedSortDirection <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
		sortIndex = _savedSortIndex;
		sortDirection = _savedSortDirection;
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre>
<p>The properties page, pageCount, isFirstPage, and isLastPage are used by the application to navigate the PaginatedDataGrid:</p>
<pre class="actionscript3" style="font-family:monospace;">&nbsp;</pre>
<h3>Sorting</h3>
<p>We know from the Flex docs that the DataGrid dispatches the DataGridEvent.HEADER_RELEASE event. This event is dispatched by the mouseUpHandler() method in DataGridHeader and the event is cancelable. The PaginatedDataGrid listens for this event and handles it with the following method:</p>
<pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #339966; font-weight: bold;">function</span> headerReleaseHandler<span style="color: #000000;">&#40;</span>event<span style="color: #000000; font-weight: bold;">:</span>DataGridEvent<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
	event.<span style="color: #004993;">preventDefault</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
	sortByColumn<span style="color: #000000;">&#40;</span>event.columnIndex<span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span></pre>
<p>The sortByColumn() method was largely copied from the sortByColumn() method from DataGrid. It determines how to sort and applies the sort information. It uses mx_internal properties so we had to import and use that namespace:</p>
<pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">import</span> mx.events.DataGridEvent;</pre>
<pre class="actionscript3" style="font-family:monospace;">use <span style="color: #004993;">namespace</span> mx_internal;</pre>
<p>The significant modifications to sortByColumn() are in the following lines:</p>
<pre class="actionscript3" style="font-family:monospace;"><span style="color: #009900;">// save sort information to be applied when dataProvider changes</span>
_savedSortIndex = sortIndex;
_savedSortDirection = sortDirection;</pre>
<pre class="actionscript3" style="font-family:monospace;"> _entireCollection.<span style="color: #004993;">sort</span> = s;
 _entireCollection.refresh<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
populatePage<span style="color: #000000;">&#40;</span>page<span style="color: #000000;">&#41;</span>;</pre>
<p>Note that the sort is applied to  _entireCollection which is an ArrayCollection and whose source data is entireDataProvider. The current page is then repopulated with the newly sorted data.</p>
<h3>What if I'm using web services?</h3>
<p>If you want to modify PaginatedDataGrid to work with web services, you will not need a good chunk of the code starting with entireDataProvider. I would start by editing the page setter function which is the entry point of data population. If you're using sorting, you'll have to grab that data from sortIndex/sortDirection and pass them as parameters to the service (reformatted as necessary). If the feature requires additional filtering then you would create methods to set that information and then pass it along when requesting data for a page. This is a bit abstract I know. If you're comfortable with web services, then with this example you should have all the tools you'll need.</p>
<h3>Final Thoughts</h3>
<p>The more I read Flex source, the more I cry. Just kidding. I'm actually happy to find that between protected and mx_internal properties and methods, I'm able to customize (and fix) the code for my specific requirements.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.themorphicgroup.com/blog/2009/04/04/paginated-datagrid-with-sorting/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Embeding Fonts for use in TextFormat and CSS</title>
		<link>http://www.themorphicgroup.com/blog/2009/03/20/embeding-fonts-for-use-in-textformat-and-css/</link>
		<comments>http://www.themorphicgroup.com/blog/2009/03/20/embeding-fonts-for-use-in-textformat-and-css/#comments</comments>
		<pubDate>Fri, 20 Mar 2009 19:07:17 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[embed]]></category>
		<category><![CDATA[FlexBuiler]]></category>
		<category><![CDATA[font]]></category>
		<category><![CDATA[registerFont]]></category>
		<category><![CDATA[style]]></category>
		<category><![CDATA[swf]]></category>
		<category><![CDATA[TextFormat]]></category>
		<category><![CDATA[ttf]]></category>

		<guid isPermaLink="false">http://www.themorphicgroup.com/blog/?p=76</guid>
		<description><![CDATA[I regularly have problems embedding fonts in my SWF files. There are a variety of different ways to embed fonts; many of which are detailed in the documentation. I am going to show my preferred way to embed fonts that solve many of the problems are arise when embedding fonts in other ways. One of the biggest issues that I [...]]]></description>
			<content:encoded><![CDATA[<p><span>I regularly have problems embedding fonts in my SWF files.  There are a variety of different ways to embed fonts; many of which are detailed in the documentation. <span> </span>I am going to show my preferred way to embed fonts that solve many of the problems are arise when embedding fonts in other ways.</span></p>
<p><span>One of the biggest issues that I have run into is making a font available for use in both a .css file and in a TextFormat object.<span> </span>It is difficult for me to reference a font that is embedded in a .css file from an AS3 code line that is setting the properties of a new TextFormat object, for instance. <span> </span>This solution also works with both projects that use the mx.core.* framework (a Flex Project) and also pure AS3 projects. <span> </span>This solution works with BitmapFonts like the ones you might find on <a href="http://www.fontsforflash.com/">http://www.fontsforflash.com/</a>.</span></p>
<p>The solution involves making a Fonts.as class that embeds the font definitions and registers them with the global Font object.  This enables referencing of fonts by name from anywhere within your application - CSS, AS3, or MXML files.  I like to make a Flex Library project to hold all the font information.  This allows me to use the same embed code for multiple project - and if desired - make the font.swc into an RSL for runtime sharing between multiple SWFs on your Web site.  You could potentially also achieve runtime loaded font definitions with this method - but that is a story for a different day.</p>
<h2><span><span style="color: #0000ff;"><strong><span style="color: #008000;">PART 1</span></strong><span style="color: #008000;"> - Make the</span></span><strong><span style="color: #0000ff;"><span style="color: #008000;"> font Flex Library Project</span></span></strong><span style="color: #0000ff;"><span style="color: #008000;"> project</span></span></span></h2>
<p><span><strong>Step 1</strong> – Open <strong>Flex Builder</strong> and make a new <strong>Flex Library Project</strong>.<span> </span>Name the project <strong>font</strong>.</span></p>
<p><span><strong>Step 2</strong> – Add font assets.<span> </span>I prefer to create a src/assets/fonts/ directory to hold my assets.<span> </span>The font assets can be either<br />
A) .TTF file<br />
B). SWF file by following the instructions from the docs found here: <a title="http://livedocs.adobe.com/flex/3/html/help.html?content=fonts_09.html" href="http://livedocs.adobe.com/flex/3/html/help.html?content=fonts_09.html" target="_blank">http://livedocs.adobe.com/flex/3/html/help.html?content=fonts_09.html</a></span></p>
<p><span><strong>Step 3</strong> – Create a new .as file in your /src directory named <strong>Fonts.as</strong></span></p>
<p><strong>Step 4</strong> - Add this code to <strong>Fonts.as</strong></p>
<pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.text</span>.<a href="http://www.google.com/search?q=font%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:font.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Font</span></a>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.text</span>.<a href="http://www.google.com/search?q=textformat%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textformat.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">TextFormat</span></a>;
&nbsp;
	<span style="color: #3f5fbf;">/**
	 *  This class sets up the fonts for the application.
	 */</span>
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> Fonts
	<span style="color: #000000;">&#123;</span>
	<span style="color: #009900;">// Embed a TTF file</span>
        <span style="color: #000000;">&#91;</span>Embed<span style="color: #000000;">&#40;</span><span style="color: #004993;">source</span>=<span style="color: #990000;">'assets/fonts/BOOTLE__.TTF'</span>, <span style="color: #004993;">fontName</span>=<span style="color: #990000;">'BOOTLE'</span>, mimeType=<span style="color: #990000;">'application/x-font'</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span> <span style="color: #009900;">// http://famousfonts.smackbomb.com/fonts/thebeatles.php</span>
        <span style="color: #0033ff; font-weight: bold;">private</span> static <span style="color: #6699cc; font-weight: bold;">var</span> BOOTLE<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=class%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:class.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Class</span></a>;
&nbsp;
        <span style="color: #000000;">&#91;</span>Embed<span style="color: #000000;">&#40;</span><span style="color: #004993;">source</span>=<span style="color: #990000;">'assets/fonts/squealer.TTF'</span>, <span style="color: #004993;">fontName</span>=<span style="color: #990000;">'Squealer'</span>, mimeType=<span style="color: #990000;">'application/x-font'</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span> <span style="color: #009900;">// http://famousfonts.smackbomb.com/fonts/acdc.php</span>
        <span style="color: #0033ff; font-weight: bold;">private</span> static <span style="color: #6699cc; font-weight: bold;">var</span> Squealer<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=class%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:class.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Class</span></a>;
&nbsp;
        <span style="color: #009900;">// Embed a font located inside a SWF file</span>
        <span style="color: #000000;">&#91;</span>Embed<span style="color: #000000;">&#40;</span><span style="color: #004993;">source</span>=<span style="color: #990000;">'assets/fonts/embededFonts.swf'</span>, <span style="color: #004993;">fontName</span>=<span style="color: #990000;">'Frutiger LT 45 Light'</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
        <span style="color: #0033ff; font-weight: bold;">private</span> static <span style="color: #6699cc; font-weight: bold;">var</span> FrutigerLT45Light<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=class%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:class.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Class</span></a>;
&nbsp;
	<span style="color: #000000;">&#91;</span>Embed<span style="color: #000000;">&#40;</span><span style="color: #004993;">source</span>=<span style="color: #990000;">'assets/fonts/embededFonts.swf'</span>, <span style="color: #004993;">fontName</span>=<span style="color: #990000;">'Frutiger LT 45 Light'</span>, fontWeight=<span style="color: #990000;">'bold'</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
        <span style="color: #0033ff; font-weight: bold;">private</span> static <span style="color: #6699cc; font-weight: bold;">var</span> FrutigerLT45LightBold<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=class%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:class.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Class</span></a>;
&nbsp;
	<span style="color: #000000;">&#91;</span>Embed<span style="color: #000000;">&#40;</span><span style="color: #004993;">source</span>=<span style="color: #990000;">'assets/fonts/embededFonts.swf'</span>, <span style="color: #004993;">fontName</span>=<span style="color: #990000;">'Frutiger LT 45 Light'</span>, <span style="color: #004993;">fontStyle</span>=<span style="color: #990000;">'italic'</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
        <span style="color: #0033ff; font-weight: bold;">private</span> static <span style="color: #6699cc; font-weight: bold;">var</span> FrutigerLT45LightItalic<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=class%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:class.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Class</span></a>;
&nbsp;
	<span style="color: #000000;">&#91;</span>Embed<span style="color: #000000;">&#40;</span><span style="color: #004993;">source</span>=<span style="color: #990000;">'assets/fonts/embededFonts.swf'</span>, <span style="color: #004993;">fontName</span>=<span style="color: #990000;">'Frutiger LT 45 Light'</span>, fontWeight=<span style="color: #990000;">'bold'</span>, <span style="color: #004993;">fontStyle</span>=<span style="color: #990000;">'italic'</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
        <span style="color: #0033ff; font-weight: bold;">private</span> static <span style="color: #6699cc; font-weight: bold;">var</span> FrutigerLT45LightBoldItalic<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=class%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:class.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Class</span></a>;
&nbsp;
		<span style="color: #3f5fbf;">/**
		 * Constuctor
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> Fonts<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #009900;">// Register the font with the global Font manager class</span>
			<a href="http://www.google.com/search?q=font%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:font.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Font</span></a>.<span style="color: #004993;">registerFont</span><span style="color: #000000;">&#40;</span>BOOTLE<span style="color: #000000;">&#41;</span>;
			<a href="http://www.google.com/search?q=font%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:font.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Font</span></a>.<span style="color: #004993;">registerFont</span><span style="color: #000000;">&#40;</span>Squealer<span style="color: #000000;">&#41;</span>;
			<a href="http://www.google.com/search?q=font%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:font.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Font</span></a>.<span style="color: #004993;">registerFont</span><span style="color: #000000;">&#40;</span>FrutigerLT45Light<span style="color: #000000;">&#41;</span>;
			<a href="http://www.google.com/search?q=font%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:font.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Font</span></a>.<span style="color: #004993;">registerFont</span><span style="color: #000000;">&#40;</span>FrutigerLT45LightBold<span style="color: #000000;">&#41;</span>;
			<a href="http://www.google.com/search?q=font%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:font.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Font</span></a>.<span style="color: #004993;">registerFont</span><span style="color: #000000;">&#40;</span>FrutigerLT45LightItalic<span style="color: #000000;">&#41;</span>;
			<a href="http://www.google.com/search?q=font%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:font.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Font</span></a>.<span style="color: #004993;">registerFont</span><span style="color: #000000;">&#40;</span>FrutigerLT45LightBoldItalic<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #3f5fbf;">/**
		 * A utility function
		 *
		 * @param font	A font object
		 * @return 	A sting of the font name combined with the font style
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #339966; font-weight: bold;">function</span> getUniqueFontName<span style="color: #000000;">&#40;</span><span style="color: #004993;">font</span><span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=font%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:font.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Font</span></a><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">String</span></a>
		<span style="color: #000000;">&#123;</span>
            		<span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #004993;">font</span>.<span style="color: #004993;">fontName</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #990000;">&quot;:&quot;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #004993;">font</span>.<span style="color: #004993;">fontStyle</span>;
		<span style="color: #000000;">&#125;</span>
		<span style="color: #009900;">// A convienent place to declare TextFormat objects that will be used in multiple location</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #6699cc; font-weight: bold;">var</span> textFormat1<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=textformat%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textformat.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">TextFormat</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=textformat%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textformat.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">TextFormat</span></a><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Squealer&quot;</span>, <span style="color: #000000; font-weight:bold;">12</span>, 0x000000<span style="color: #000000;">&#41;</span>;
		<span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #6699cc; font-weight: bold;">var</span> textFormat2<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=textformat%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textformat.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">TextFormat</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=textformat%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textformat.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">TextFormat</span></a><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;BOOTLE&quot;</span>, <span style="color: #000000; font-weight:bold;">12</span>, 0x000000<span style="color: #000000;">&#41;</span>;
		<span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #6699cc; font-weight: bold;">var</span> textFormat3<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=textformat%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textformat.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">TextFormat</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=textformat%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textformat.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">TextFormat</span></a><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Frutiger LT 45 Light&quot;</span>, <span style="color: #000000; font-weight:bold;">14</span>, 0x000000<span style="color: #000000;">&#41;</span>;
		<span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #6699cc; font-weight: bold;">var</span> textFormat3Bold<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=textformat%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textformat.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">TextFormat</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=textformat%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textformat.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">TextFormat</span></a><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Frutiger LT 45 Light&quot;</span>, <span style="color: #000000; font-weight:bold;">14</span>, 0x000000, <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #6699cc; font-weight: bold;">var</span> textFormat3Italic<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=textformat%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textformat.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">TextFormat</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=textformat%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textformat.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">TextFormat</span></a><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Frutiger LT 45 Light&quot;</span>, <span style="color: #000000; font-weight:bold;">14</span>, 0x000000, <span style="color: #0033ff; font-weight: bold;">null</span>, <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #6699cc; font-weight: bold;">var</span> textFormat3BoldItalic<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=textformat%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textformat.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">TextFormat</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=textformat%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textformat.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">TextFormat</span></a><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Frutiger LT 45 Light&quot;</span>, <span style="color: #000000; font-weight:bold;">14</span>, 0x000000, <span style="color: #0033ff; font-weight: bold;">true</span>, <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span>;
&nbsp;
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre>
<h2><span><span style="color: #0000ff;"><span style="color: #008000;">PART 2 – Make a project(s) that will use the </span></span><strong><span style="color: #0000ff;"><span style="color: #008000;">font Flex Library Project</span></span></strong></span></h2>
<p><span><strong>- AS3 PROJECT</strong> –<br />
<strong>Step 1</strong> - Create a new <strong>ActionScript Project</strong><span>  </span>(File --&gt;</span><span> New --&gt;</span><span> ActionScript Project)</span></p>
<ul>
<li>Name the project <strong>AS3FontTest</strong></li>
<li>Click<strong> Next </strong>button</li>
<li>Click <strong>Library Path</strong> tab</li>
<li>Click <strong>Add Project </strong>button</li>
<li>Select<strong> font </strong>and click<strong> OK</strong></li>
<li>Click<strong> Finish </strong>button</li>
</ul>
<p><strong></strong></p>
<p><strong> </strong><br />
<strong>Step 2</strong> - Add this code to the AS3FontTest.as file</p>
<pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> <span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<a href="http://www.google.com/search?q=sprite%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:sprite.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Sprite</span></a>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<a href="http://www.google.com/search?q=stagealign%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:stagealign.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">StageAlign</span></a>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<a href="http://www.google.com/search?q=stagescalemode%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:stagescalemode.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">StageScaleMode</span></a>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.text</span>.<a href="http://www.google.com/search?q=antialiastype%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:antialiastype.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">AntiAliasType</span></a>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.text</span>.<a href="http://www.google.com/search?q=gridfittype%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:gridfittype.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">GridFitType</span></a>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.text</span>.<a href="http://www.google.com/search?q=textfield%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textfield.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">TextField</span></a>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.text</span>.<a href="http://www.google.com/search?q=textformat%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textformat.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">TextFormat</span></a>;
&nbsp;
	<span style="color: #009900;">// Use meta-data to set the height and width of the SWF</span>
	<span style="color: #000000;">&#91;</span>SWF<span style="color: #000000;">&#40;</span><span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;200&quot;</span>, <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;200&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
&nbsp;
	<span style="color: #3f5fbf;">/**
	 *  Class used to test embeded font
	 */</span>
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> AS3FontTest extends <a href="http://www.google.com/search?q=sprite%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:sprite.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Sprite</span></a>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> tf<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=textfield%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textfield.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">TextField</span></a>;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> yPos<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">int</span></a> = <span style="color: #000000; font-weight:bold;">0</span>;
&nbsp;
		<span style="color: #3f5fbf;">/**
		 * Constructor
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> AS3FontTest<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #009900;">// Set some SWF paramaters</span>
			<span style="color: #004993;">stage</span>.<span style="color: #004993;">scaleMode</span> = <a href="http://www.google.com/search?q=stagescalemode%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:stagescalemode.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">StageScaleMode</span></a>.<span style="color: #004993;">NO_SCALE</span>;
			<span style="color: #004993;">stage</span>.<span style="color: #004993;">align</span> = <a href="http://www.google.com/search?q=stagealign%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:stagealign.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">StageAlign</span></a>.<span style="color: #004993;">TOP_LEFT</span>;
&nbsp;
			<span style="color: #009900;">// Draw the text</span>
			<span style="color: #004993;">draw</span><span style="color: #000000;">&#40;</span>Fonts.textFormat1<span style="color: #000000;">&#41;</span>; <span style="color: #009900;">// Use the static instance of a TextFormat object from the Fonts.as class</span>
			<span style="color: #004993;">draw</span><span style="color: #000000;">&#40;</span>Fonts.textFormat2<span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">draw</span><span style="color: #000000;">&#40;</span>Fonts.textFormat3<span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">draw</span><span style="color: #000000;">&#40;</span>Fonts.textFormat3Bold<span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">draw</span><span style="color: #000000;">&#40;</span>Fonts.textFormat3Italic<span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">draw</span><span style="color: #000000;">&#40;</span>Fonts.textFormat3BoldItalic<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #3f5fbf;">/**
		 * Method used to draw the UI bits and attach them to the screen
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">draw</span><span style="color: #000000;">&#40;</span>textFormat<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=textformat%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textformat.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">TextFormat</span></a><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			tf = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=textfield%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textfield.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">TextField</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			tf.<span style="color: #004993;">defaultTextFormat</span> = textFormat;
			tf.<span style="color: #004993;">embedFonts</span> = <span style="color: #0033ff; font-weight: bold;">true</span>;
			tf.<span style="color: #004993;">antiAliasType</span> = <a href="http://www.google.com/search?q=antialiastype%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:antialiastype.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">AntiAliasType</span></a>.<span style="color: #004993;">ADVANCED</span>; <span style="color: #009900;">// Set this to what looks best for your font</span>
			tf.<span style="color: #004993;">thickness</span> = <span style="color: #000000; font-weight:bold;">0</span>; <span style="color: #009900;">// Set this to what looks best for your font</span>
			tf.<span style="color: #004993;">sharpness</span> = <span style="color: #000000; font-weight:bold;">0</span>; <span style="color: #009900;">// Set this to what looks best for your font</span>
			tf.<span style="color: #004993;">gridFitType</span> = <a href="http://www.google.com/search?q=gridfittype%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:gridfittype.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">GridFitType</span></a>.<span style="color: #004993;">SUBPIXEL</span>; <span style="color: #009900;">// Set this to what looks best for your font</span>
			tf.<span style="color: #004993;">x</span> = <span style="color: #000000; font-weight:bold;">10</span>;
			tf.<span style="color: #004993;">y</span> = <span style="color: #000000; font-weight:bold;">10</span> <span style="color: #000000; font-weight: bold;">+</span> yPos;
			tf.<span style="color: #004993;">width</span> = <span style="color: #000000; font-weight:bold;">180</span>;
			tf.<span style="color: #004993;">text</span> = <span style="color: #990000;">&quot;ABC123&quot;</span>;
&nbsp;
			<span style="color: #009900;">// Add the created TextField to the stage</span>
			<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>tf<span style="color: #000000;">&#41;</span>;
&nbsp;
			yPos <span style="color: #000000; font-weight: bold;">+</span>= <span style="color: #000000; font-weight:bold;">18</span>;
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre>
<p><strong>Step 3</strong> - Run the project and you should see the embedded font(s) as expected<strong></strong></p>
<p><span><strong>- FLEX PROJECT –</strong><br />
<strong>Step 1</strong> - Create a new <strong>Flex Project <span><span style="font-weight: normal;">(File --&gt;</span></span><span><span style="font-weight: normal;"> New --&gt;</span></span><span><span style="font-weight: normal;"> ActionScript Project)</span></span></strong></span></p>
<ul>
<li>Name the project <strong>FlexFontTest</strong></li>
<li>Click <strong>Next </strong>button</li>
<li>Click <strong>Library Path</strong> tab</li>
<li>Click <strong>Add Project</strong> button</li>
<li>Select <strong>font </strong>and click <strong>OK</strong></li>
<li>Click <strong>Finish </strong>button</li>
</ul>
<p><span><strong>Step 2 -</strong> Make a new directory <strong>/src/assets/styles</strong></span></p>
<p><span><strong>Step 3</strong> -  Make a new CSS file in that directory named <strong>styles.css</strong><br />
<strong>Step 4</strong> -  Add this code to <strong>styles.css</strong></span></p>
<pre class="actionscript3" style="font-family:monospace;"><span style="color: #3f5fbf;">/* CSS file */</span>
.bootle <span style="color: #000000;">&#123;</span>
    fontFamily<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #990000;">&quot;BOOTLE&quot;</span>;
    font<span style="color: #000000; font-weight: bold;">-</span><span style="color: #004993;">size</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">12</span>;
    <span style="color: #004993;">color</span><span style="color: #000000; font-weight: bold;">:</span> #000000;
<span style="color: #000000;">&#125;</span>
.squealer <span style="color: #000000;">&#123;</span>
    fontFamily<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #990000;">&quot;Squealer&quot;</span>;
    font<span style="color: #000000; font-weight: bold;">-</span><span style="color: #004993;">size</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">12</span>;
    <span style="color: #004993;">color</span><span style="color: #000000; font-weight: bold;">:</span> #000000;
<span style="color: #000000;">&#125;</span>
.frutiger <span style="color: #000000;">&#123;</span>
    fontFamily<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #990000;">&quot;Frutiger LT 45 Light&quot;</span>;
    font<span style="color: #000000; font-weight: bold;">-</span><span style="color: #004993;">size</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">12</span>;
    <span style="color: #004993;">color</span><span style="color: #000000; font-weight: bold;">:</span> #000000;
<span style="color: #000000;">&#125;</span>
.frutigerBold <span style="color: #000000;">&#123;</span>
    fontFamily<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #990000;">&quot;Frutiger LT 45 Light&quot;</span>;
    font<span style="color: #000000; font-weight: bold;">-</span><span style="color: #004993;">size</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">12</span>;
    font<span style="color: #000000; font-weight: bold;">-</span>weight<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">bold</span>;
    <span style="color: #004993;">color</span><span style="color: #000000; font-weight: bold;">:</span> #000000;
<span style="color: #000000;">&#125;</span>
.frutigerItalic <span style="color: #000000;">&#123;</span>
    fontFamily<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #990000;">&quot;Frutiger LT 45 Light&quot;</span>;
    font<span style="color: #000000; font-weight: bold;">-</span><span style="color: #004993;">size</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">12</span>;
    font<span style="color: #000000; font-weight: bold;">-</span>style<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">italic</span>;
    <span style="color: #004993;">color</span><span style="color: #000000; font-weight: bold;">:</span> #000000;
<span style="color: #000000;">&#125;</span>
.frutigerBoldItalic <span style="color: #000000;">&#123;</span>
    fontFamily<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #990000;">&quot;Frutiger LT 45 Light&quot;</span>;
    font<span style="color: #000000; font-weight: bold;">-</span><span style="color: #004993;">size</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">12</span>;
    font<span style="color: #000000; font-weight: bold;">-</span>weight<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">bold</span>;
    font<span style="color: #000000; font-weight: bold;">-</span>style<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">italic</span>;
    <span style="color: #004993;">color</span><span style="color: #000000; font-weight: bold;">:</span> #000000;
<span style="color: #000000;">&#125;</span></pre>
<p><strong>Step 5</strong> -  Add this code to the <strong>FlexFontText.mxml </strong>file that was created when you made the project<br />
<code></p>
<pre class="actionscript3" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?</span>xml <span style="color: #004993;">version</span>=<span style="color: #990000;">&quot;1.0&quot;</span> encoding=<span style="color: #990000;">&quot;utf-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;</span>mx<span style="color: #000000; font-weight: bold;">:</span>Application xmlns<span style="color: #000000; font-weight: bold;">:</span>mx=<span style="color: #990000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> layout=<span style="color: #990000;">&quot;absolute&quot;</span>
	creationComplete=<span style="color: #990000;">&quot;created()&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;</span>mx<span style="color: #000000; font-weight: bold;">:</span>Script<span style="color: #000000; font-weight: bold;">&gt;</span>
		<span style="color: #000000; font-weight: bold;">&lt;!</span><span style="color: #000000;">&#91;</span>CDATA<span style="color: #000000;">&#91;</span>
			<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> created<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
			<span style="color: #000000;">&#123;</span>
				<span style="color: #009900;">// Instantiate the Fonts class</span>
				<span style="color: #0033ff; font-weight: bold;">new</span> Fonts<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
				<span style="color: #009900;">// Reference the embeded font name by it's string name</span>
				<span style="color: #6699cc; font-weight: bold;">var</span> tf<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=textfield%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textfield.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">TextField</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=textfield%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textfield.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">TextField</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
				tf.<span style="color: #004993;">defaultTextFormat</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=textformat%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textformat.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">TextFormat</span></a><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Frutiger LT 45 Light&quot;</span>, <span style="color: #000000; font-weight:bold;">12</span>, 0x000000<span style="color: #000000;">&#41;</span>;
				tf.<span style="color: #004993;">embedFonts</span> = <span style="color: #0033ff; font-weight: bold;">true</span>;
				tf.<span style="color: #004993;">antiAliasType</span> = <a href="http://www.google.com/search?q=antialiastype%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:antialiastype.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">AntiAliasType</span></a>.<span style="color: #004993;">ADVANCED</span>;
				tf.<span style="color: #004993;">text</span> = <span style="color: #990000;">&quot;ABC 123&quot;</span>;
&nbsp;
				fontHolder.<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>tf<span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#93;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;/</span>mx<span style="color: #000000; font-weight: bold;">:</span>Script<span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">&lt;</span>mx<span style="color: #000000; font-weight: bold;">:</span>Style <span style="color: #004993;">source</span>=<span style="color: #990000;">&quot;/assets/styles/styles.css&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">&lt;</span>mx<span style="color: #000000; font-weight: bold;">:</span>VBox <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;10&quot;</span> <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;10&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
		<span style="color: #000000; font-weight: bold;">&lt;</span>mx<span style="color: #000000; font-weight: bold;">:</span>UIComponent id=<span style="color: #990000;">&quot;fontHolder&quot;</span> <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;20&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
		<span style="color: #000000; font-weight: bold;">&lt;</span>mx<span style="color: #000000; font-weight: bold;">:</span>Text styleName=<span style="color: #990000;">&quot;bootle&quot;</span> <span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;ABC 123&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
		<span style="color: #000000; font-weight: bold;">&lt;</span>mx<span style="color: #000000; font-weight: bold;">:</span>Text styleName=<span style="color: #990000;">&quot;squealer&quot;</span> <span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;ABC 123&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
		<span style="color: #000000; font-weight: bold;">&lt;</span>mx<span style="color: #000000; font-weight: bold;">:</span>Text styleName=<span style="color: #990000;">&quot;frutiger&quot;</span> <span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;ABC 123&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
		<span style="color: #000000; font-weight: bold;">&lt;</span>mx<span style="color: #000000; font-weight: bold;">:</span>Text styleName=<span style="color: #990000;">&quot;frutigerBold&quot;</span> <span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;ABC 123&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
		<span style="color: #000000; font-weight: bold;">&lt;</span>mx<span style="color: #000000; font-weight: bold;">:</span>Text styleName=<span style="color: #990000;">&quot;frutigerItalic&quot;</span> <span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;ABC 123&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
		<span style="color: #000000; font-weight: bold;">&lt;</span>mx<span style="color: #000000; font-weight: bold;">:</span>Text styleName=<span style="color: #990000;">&quot;frutigerBoldItalic&quot;</span> <span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;ABC 123&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;/</span>mx<span style="color: #000000; font-weight: bold;">:</span>VBox<span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;/</span>mx<span style="color: #000000; font-weight: bold;">:</span>Application<span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;</pre>
<p></code></p>
<p><span><strong>Step 6</strong> - Run the project and you should see the embedded font(s)</span></p>
<p><span>I hope this illustrated a way to simplify font embedding in Flash that allows for use in TextFormat object or in CSS files.</span></p>
<p><span>--jason</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.themorphicgroup.com/blog/2009/03/20/embeding-fonts-for-use-in-textformat-and-css/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Setting Parameters With The Same Name Using URLVariables</title>
		<link>http://www.themorphicgroup.com/blog/2009/03/20/setting-parameters-with-the-same-name-using-urlvariables/</link>
		<comments>http://www.themorphicgroup.com/blog/2009/03/20/setting-parameters-with-the-same-name-using-urlvariables/#comments</comments>
		<pubDate>Fri, 20 Mar 2009 12:34:54 +0000</pubDate>
		<dc:creator>Unknown Morphician</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Array]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[parameters]]></category>
		<category><![CDATA[URLVariables]]></category>

		<guid isPermaLink="false">http://www.themorphicgroup.com/blog/?p=77</guid>
		<description><![CDATA[The ability to set and send form parameters with the same name is available with URLVariables though it's not quite documented very well (at all?). Below are 4 examples of setting 2 values with same parameter name. The first example results in 1 parameter. The rest result in 2 parameters as expected. &#160; // results [...]]]></description>
			<content:encoded><![CDATA[<p>The ability to set and send form parameters with the same name is available with URLVariables though it's not quite documented very well (at all?).</p>
<p>Below are 4 examples of setting 2 values with same parameter name. The first example results in 1 parameter. The rest result in 2 parameters as expected.</p>
<pre class="actionscript3" style="font-family:monospace;">&nbsp;
<span style="color: #009900;">// results in 1 parameter</span>
<span style="color: #6699cc; font-weight: bold;">var</span> urlVarsA<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=urlvariables%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:urlvariables.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">URLVariables</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=urlvariables%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:urlvariables.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">URLVariables</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
urlVarsA<span style="color: #000000;">&#91;</span><span style="color: #990000;">&quot;foo&quot;</span><span style="color: #000000;">&#93;</span> = <span style="color: #990000;">&quot;Hello&quot;</span>;
urlVarsA<span style="color: #000000;">&#91;</span><span style="color: #990000;">&quot;foo&quot;</span><span style="color: #000000;">&#93;</span> = <span style="color: #990000;">&quot;World!&quot;</span>; <span style="color: #009900;">// this overwrites the previous</span>
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>urlVarsA<span style="color: #000000;">&#41;</span>; <span style="color: #009900;">// foo=World%21</span>
&nbsp;
<span style="color: #009900;">// results in 2 parameters as expected</span>
<span style="color: #6699cc; font-weight: bold;">var</span> urlVarsB<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=urlvariables%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:urlvariables.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">URLVariables</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=urlvariables%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:urlvariables.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">URLVariables</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
urlVarsB.<span style="color: #004993;">decode</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;foo=Hello&quot;</span><span style="color: #000000;">&#41;</span>;
urlVarsB.<span style="color: #004993;">decode</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;foo=World!&quot;</span><span style="color: #000000;">&#41;</span>; <span style="color: #009900;">// decode() has logic to detect existing params</span>
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>urlVarsB<span style="color: #000000;">&#41;</span>; <span style="color: #009900;">// foo=Hello&amp;foo=World%21</span>
&nbsp;
<span style="color: #009900;">// results in 2 parameters as expected</span>
<span style="color: #6699cc; font-weight: bold;">var</span> urlVarsC<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=urlvariables%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:urlvariables.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">URLVariables</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=urlvariables%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:urlvariables.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">URLVariables</span></a><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;foo=Hello&amp;foo=World!&quot;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>urlVarsC<span style="color: #000000;">&#41;</span>; <span style="color: #009900;">// foo=Hello&amp;foo=World%21</span>
&nbsp;
<span style="color: #009900;">// results in 2 parameters as expected</span>
<span style="color: #6699cc; font-weight: bold;">var</span> urlVarsD<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=urlvariables%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:urlvariables.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">URLVariables</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=urlvariables%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:urlvariables.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">URLVariables</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
urlVarsD<span style="color: #000000;">&#91;</span><span style="color: #990000;">&quot;foo&quot;</span><span style="color: #000000;">&#93;</span> = <span style="color: #000000;">&#91;</span><span style="color: #990000;">&quot;Hello&quot;</span>, <span style="color: #990000;">&quot;World!&quot;</span><span style="color: #000000;">&#93;</span>; <span style="color: #009900;">// Arrays are special to URLVariables</span>
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>urlVarsD<span style="color: #000000;">&#41;</span>; <span style="color: #009900;">// foo=Hello&amp;foo=World%21</span>
&nbsp;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.themorphicgroup.com/blog/2009/03/20/setting-parameters-with-the-same-name-using-urlvariables/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Building a Facebook application with Ribbit and Flash</title>
		<link>http://www.themorphicgroup.com/blog/2009/02/18/building-a-facebook-application-with-ribbit-and-flash/</link>
		<comments>http://www.themorphicgroup.com/blog/2009/02/18/building-a-facebook-application-with-ribbit-and-flash/#comments</comments>
		<pubDate>Wed, 18 Feb 2009 17:47:19 +0000</pubDate>
		<dc:creator>Unknown Morphician</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Reviews]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[flash cs3]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Ribbit]]></category>

		<guid isPermaLink="false">http://www.themorphicgroup.com/blog/?p=73</guid>
		<description><![CDATA[For me, Facebook (free-access social networking website) is a guilty pleasure. I've spent more time on this site than I care to admit. When the chance came, I set out to use my mighty morphic skills to build a Facebook application. My goal was to create an application that makes phone calls from within Facebook. [...]]]></description>
			<content:encoded><![CDATA[<p>For me, Facebook (free-access social networking website) is a guilty pleasure. I've spent more time on this site than I care to admit. When the chance came, I set out to use my mighty morphic skills to build a Facebook application. My goal was to create an application that makes phone calls from within Facebook. I had a little help by using Ribbit as my co-pilot.</p>
<p>What is <a href="http://www.ribbit.com/" target="_blank">Ribbit</a>? It is an application framework that allows you to interact with telephone networks. You can basically send text message and make phone calls to mobile and regular phones. Right now, you can a request <a href="http://www.ribbit.com/reserve.php" target="_blank">Ribbit account</a> to use applications that utilize this platform. The Ribbit legal info can be found <a href="http://www.ribbit.com/legal/" target="_blank">here</a>. (For this blog, I am going to assume that you are a developer who is or will be using this platform for your application. You can get an account <a href="http://developer.ribbit.com/register" target="_blank">here</a>.)  </p>
<p>The concept was straight forward. Display my friends and create a phone book by adding their phone number, and call them up through the main application swf. My application uses Flash, Javascript, PHP, Ribbit Framework, Facebook API, and MySql database. I will primarily discuss the Facebook API FBML (Facebook Markup Language) with PHP, and how I used the Ribbit API in Flash.</p>
<p>First, it is a good idea to get acquainted with Facebook API by review and/or creating sample Facebook applications. You first need to look over at the <a href="http://developers.facebook.com/get_started.php" target="_blank">developer section</a>. As it states, you should be familiar with HTML, scripting languages such as PHP and JavaScript and a database like MySQL (if you want to contain any application state). You will be essentially hosting your application and interfacing with the Facebook site via their interface and setup. View the <a href="http://wiki.developers.facebook.com/index.php/Random_questions#Basic_Application_Architecture" target="_blank">Basic Application Architecture</a> to get an idea of how the system works. It is also helpful to run through their sample applications to understand what you can and can't do. <a href="http://wiki.developers.facebook.com/index.php/Demos" target="_blank">Demo Applications</a></p>
<p>Here are a few good links I found helpful:<br />
- <a href="http://wiki.developers.facebook.com/index.php/Creating_Your_First_Application" target="_blank">Creating your first application</a><br />
- <a href="http://wiki.developers.facebook.com/index.php/Main_Page" target="_blank">Developers Wiki Page</a><br />
- <a href="http://www.sitepoint.com/article/developing-facebook-platform/" target="_blank">Developing with the Facebook Platform and PHP</a><br />
- <a href="http://wiki.developers.facebook.com/index.php/FBML" target="_blank">FBML Reference</a><br />
- <a href="http://developers.facebook.com/tools.php" target="_blank">Test data retrieval of Platform</a><br />
- <a href="http://svn.facebook.com/svnroot/platform/clients/packages/facebook-platform.tar.gz" target="_blank">PHP Client files for Facebook integration</a></p>
<p>You can either build your application using FBML (self defined markup language) or in an external web site with an iframe. For my application I used FBML. There are some HTML and Javascript techniques that will not work well with FBML. The parsing of the markup causes issues when you use quotes or parenthesis in a particular ways. It is a matter of trial and error (Error 500 to be exact).</p>
<p>Here are some tips:<br />
- Avoid using inline Javascript, use function calls.<br />
- Use a tool like Firebug to debug Javascript.<br />
- I would also suggest enabling PHP log errors on your hosting server to troubleshoot issues cause on the server-end.<br />
- Remember that the tags need to be written well formed. You must make sure you close tags.<br />
- When you set up your application in the <a href="http://www.facebook.com/developers/" target="_blank">developer page</a>, make sure that the canvas url is all in lower-case.<br />
All in all, I always found a solution that would work. So don't give up.</p>
<p>FBML has tags for rendering flash and javascript bridge embed code. From the documentation, this tag (Fb:fbjs-bridge) seems to be fairly new. There must have been a big request for this feature because the rendered html in the FB:swf has allowScriptAccess set to none.  As the documentation states "Facebook prevents direct script access from flash"(1). The Javascript bridge is essential for interaction with the flash swf.<br />
- <a href="http://www2.themorphicgroup.com/projects/examples/FBJS/FBJS_flash.zip" target="_blank">code sample including javascript, php library and fla</a><br />
- <a href="http://wiki.developers.facebook.com/index.php/Fb:swf" target="_blank">info on FB:swf</a> (1)<br />
- <a href="http://wiki.developers.facebook.com/index.php/Fb:fbjs-bridge" target="_blank">info on Fb:fbjs-bridge</a></p>
<p>Make sure that you add this file at the root of your web domain to prevent security issues:<br />
...<br />
&lt;?xml version="1.0"?&gt;<br />
&lt;cross-domain-policy&gt;<br />
&lt;allow-access-from domain="apps.facebook.com" /&gt;<br />
&lt;allow-access-from domain="apps.*.facebook.com" /&gt;<br />
&lt;/cross-domain-policy&gt;<br />
...</p>
<p>Now that we have the basics down on setting up the application for Facebook, I will give a few highlights of my application (Call a Friend). I won't go through the setup and actions (update, select and insert query) of the database and html form.</p>
<p><img src="http://www2.themorphicgroup.com/projects/examples/FBJS/facebook_friendList.jpg" alt="Screen shot of Friend list" width="375" height="468" /></p>
<p>- To display all my friends, I reference get_friends() method from my instance of the Application API and run through the array object returned.<br />
Something like this:<br />
php<br />
....<br />
foreach($fb_friends as $friend){<br />
$fbml .= '&lt;div style="clear: both; padding: 3px;" &gt;'<br />
.   '&lt;fb:profile-pic  uid="' . $friend . '" size="square"/&gt; '<br />
.   '&lt;div height="20"&gt;&lt;fb:name  uid="' . $friend . '" capitalize="true"/&gt;&lt;/div&gt;'<br />
}<br />
echo $fbml;<br />
....</p>
<p>- Within that listing of friends, I make a call to a Javascript function to send up the phone number<br />
Something like this:<br />
php<br />
...<br />
$info = '555-555-5555';<br />
$fbml .= "&lt;input type='button' name='callButton' value='Call Friend' onClick=callFriendPhone('" . $info . "') /&gt; ";<br />
echo $fbml;<br />
...</p>
<p>html<br />
...<br />
&lt;fb:fbjs_bridge /&gt;<br />
&lt;div id="swfContainer"&gt;&lt;/div&gt;<br />
...</p>
<p>javascript<br />
...<br />
var swf = document.createElement('fb:swf');<br />
swf.setId('my_swf_id');<br />
swf.setWidth('200');<br />
swf.setHeight('100');<br />
swf.setSWFSrc('[absolute path]fbjs.swf');<br />
document.getElementById('swfContainer').appendChild(swf);<br />
function callFriendPhone(phone){<br />
document.getElementById('my_swf_id').callSWF('callFriend', phone);<br />
}<br />
...</p>
<p>So just to explain the Javascript... I'm getting the reference of the swf tag container. Which calls the internal actionscript method callFriend() with parameter (phone number). Make sure that the fb:fbjs_bridge tag is included on the page. Notice that the fb:swf tag is created dynamically and added to a div section. Check out my <a href="http://www2.themorphicgroup.com/projects/examples/FBJS/FBJS_flash.zip" target="_blank">code sample</a> as an example of this functionality.</p>
<p>This is a good time to talk about the embedded Flash Application which interacts with Ribbit. Before hand, I created a developer account on <a href="http://developer.ribbit.com" target="_blank">http://developer.ribbit.com</a>. From there I downloaded the flash kit. Using Flash CS3 to build my swf, I referenced the classes for Ribbit by adding the "RibbitAPI_2.5.0.1070.CS3" component into my library. If you haven't already, I would highly suggest playing around with the samples and reading the documentation on this site.</p>
<p>There are three parts to my application:<br />
<img src="http://www2.themorphicgroup.com/projects/examples/FBJS/flash_login.jpg" alt="login interface" /><br />
The login window allows the user to login with their username and password.</p>
<p><img src="http://www2.themorphicgroup.com/projects/examples/FBJS/flash_phone.jpg" alt="phone interface" /><br />
The phone interface contains the status, phone number input, volume control of mic and sound, and digit buttons. This interface references a local connection to the Javascript/Flash bridge.</p>
<p><img src="http://www2.themorphicgroup.com/projects/examples/FBJS/flash_callLog.jpg" alt="call logs interface" /><br />
Lastly, the call log interface displays data grid consisting of recent calls.</p>
<p>These parts interact with my service manager that holds the Ribbit Framework reference. It's main purpose is to pass the application and developer id to the service, log into the service and add event listeners to Ribbit's AuthenticationEvent and Ribbit Callmanager's CallEvent. After logging into the Ribbit service, I reference Ribbit's callManager object to make and end phone calls. This object is also used to get call logs to display all recent calls made with this account and reference the call state ( Ringing, Answered, etc.). <a href="http://www2.themorphicgroup.com/projects/examples/FBJS/RibbitServiceManager.as" target="_blank">View Source of RibbitServiceManager.as</a></p>
<p>All in all, the Ribbit framework was straight forward and easy to use. The developer site gives a lot of helpful information on getting your application up and running. The only drawback I had was that I could not allow users to log out. I'm getting this error: "TypeError: Error #1009: Cannot access a property or method of a null object reference." within the Ribbit API. There seems to be a problem with the current library component. Here are a few forum posting that I found <a href="http://developer.ribbit.com/forums/viewtopic.php?t=282&amp;highlight=typeerror+error+1009+cannot+access+property++method+null+object+reference" target="_blank">Forum post 1</a> <a href="http://developer.ribbit.com/forums/viewtopic.php?t=305&amp;highlight=typeerror+error+1009+cannot+access+property++method+null+object+reference" target="_blank">Forum post 2</a> .<a href="http://developer.ribbit.com/forums/viewtopic.php?t=305&amp;highlight=typeerror+error+1009+cannot+access+property++method+null+object+reference" target="_blank"><br />
</a></p>
<p>Maybe I'm getting this error because I'm not using their visual components. My colleague Seth is building a cool Ribbit app in Flex. I don't think he is having the same problem that I have. For now, I've disabled this feature in my application.</p>
<p>Well... I had a lot of fun building this application. If you have Facebook and want to check it out, hit this link : <a href="http://apps.facebook.com/callafriend/" target="_blank">http://apps.facebook.com/callafriend/</a></p>
<p>This application is still a beta. It will only be used as a demo. It may be changed or reset at any given time.</p>
<p>I welcome any feedback or comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.themorphicgroup.com/blog/2009/02/18/building-a-facebook-application-with-ribbit-and-flash/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>FABridge Error: &#8220;You are trying to call recursively into the Flash Player which is not allowed&#8230;&#8221;</title>
		<link>http://www.themorphicgroup.com/blog/2009/02/14/fabridge-error-you-are-trying-to-call-recursively-into-the-flash-player-which-is-not-allowed/</link>
		<comments>http://www.themorphicgroup.com/blog/2009/02/14/fabridge-error-you-are-trying-to-call-recursively-into-the-flash-player-which-is-not-allowed/#comments</comments>
		<pubDate>Sat, 14 Feb 2009 22:06:10 +0000</pubDate>
		<dc:creator>Unknown Morphician</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[FABridge EventsToCallLater MethodsToCallLater]]></category>

		<guid isPermaLink="false">http://www.themorphicgroup.com/blog/?p=71</guid>
		<description><![CDATA[Like many people, I've been using the FABridge a lot and loving the simplicity it provides. Also like many people I've run into the following JavaScript error thrown by the FABridge:  You are trying to call recursively into the Flash Player which is not allowed. In most cases the JavaScript setTimeout function, can be used [...]]]></description>
			<content:encoded><![CDATA[<p>Like many people, I've been using the FABridge a lot and loving the simplicity it provides. Also like many people I've run into the following JavaScript error thrown by the FABridge: </p>
<blockquote><p><em>You are trying to call recursively into the Flash Player which is not allowed. In most cases the JavaScript setTimeout function, can be used as a workaround.</em></p></blockquote>
<p>In a pinch, I've worked around this error using the suggested JS setTimeout() function or by retrieving data by other means. I've finally decided to see if there was a better way and found one.</p>
<p><span style="color: #808080;">For the impatient (like myself), the solution is to use the following FABridge static constants: </span></p>
<blockquote>
<pre><span style="font-family: 'Courier New'; line-height: 18px; white-space: pre; "><span style="color: #808080;">FABridge.EventsToCallLater
FABridge.MethodsToCallLater </span></span></pre>
</blockquote>
<p>Let's look at a test project:</p>
<ul>
<li><a title="FABridge Test" href="http://www2.themorphicgroup.com/projects/examples/fabridgetest/" target="_blank">FABridge Test</a></li>
<li><a title="FABridge Test Source View" href="http://www2.themorphicgroup.com/projects/examples/fabridgetest/srcview/" target="_blank">FABridge Test Source View</a></li>
</ul>
<p>Open the FABridge Test and you'll see a bunch of links. Click <strong>FireBugLite</strong> to open a console. Then click <strong>embedSwf()</strong> to embed the swf which will output to the console when the FABridge has initialized (see the JavaScript callback() method on the HTML page . You should then see the following in the console:</p>
<blockquote>
<pre>
<div class="logRow">embedSwf
franky.name: franky
franky.children.length: <span class="objectBox-number">2
franky.children[0]: <span class="objectBox-object">Object
franky.children[0].name: john</span></span></div>
</pre>
</blockquote>
<p>The JS callback() method is a simple demonstration of getting data from the SWF through the FABridge.  Now click on the <strong>requestRingo()</strong> link.  That calls the following JS code:</p>
<blockquote>
<pre>getRoot().requestRingo();</pre>
</blockquote>
<p>That in turn calls the following ActionScipt code in FABridgetTest.as which dispatches a ringoRequested event:</p>
<blockquote>
<pre>public function requestRingo():void {
    var e:NodeEvent = new NodeEvent("ringoRequested");
     e.node = new Node("ringo", 14);
     e.node.children.push(new Node("dingo", 2));
     dispatchEvent(e); // dispatch right away
}</pre>
</blockquote>
<p>In the JavaScript, we've added an event listener for that event in the callback() method. The JS requestRingoHandler() method is called as a result:</p>
<blockquote>
<pre>function requestRingoHandler(event) {
    console.log("ringo");
      try {
         var ringo = event.getNode();
         console.log("ringo.name:", ringo.getName());
         console.log("ringo.children[0].name:", ringo.getChildren()[0].getName());
    } catch (e) {
        console.log("error:", e.message);
    }
}</pre>
</blockquote>
<p>So we've click on the <strong>requestRingo()</strong> link and will get the following output in the console:</p>
<blockquote>
<pre>ringo
error: You are trying to call recursively into the Flash Player which is not allowed. In most cases the JavaScript setTimeout function, can be used as a workaround.</pre>
</blockquote>
<div class="logRow">The error occurred because in requestRingoHandler(), we're accessing properties of the given event object and in this case the event was dispatched immediately when calling the AS requestRingo() method. We could avoid the error by dispatching the event after a delay. A more general solution would better of course. So now click on the <strong>setEventsToCallLater("fabridgetest::NodeEvent")</strong> link. Click on <strong>requestRingo()</strong> again and you'll get the following output:</div>
<div class="logRow">
<blockquote>
<pre>
<div class="logRow">ringo
ringo.name: ringo
ringo.children[0].name: dingo</div>
</pre>
</blockquote>
</div>
<p>The setEventsToCallLater() method registered the fabridgetest::NodeEvent class with the FABridge as an event to dispatch after a delay. This registration is done using the FABridge.EventsToCallLater Object constant. In a normal application you'd hard code these registrations, e.g.</p>
<blockquote>
<pre>FABridge.EventsToCallLater["fabridgetest::NodeEvent"] = "true";</pre>
</blockquote>
<p>You can also register the general flash.events.::Event class to cover all cases, but there may be performance concerns so that will have to be tested before I use it in production code.  </p>
<p>In addition to the EventsToCallLater constant, FABridge has the MethodsToCallLater constant which is the same thing but for specified methods for classes. The FABridge registers the following automatically:</p>
<blockquote>
<pre>MethodsToCallLater["mx.collections::ArrayCollection"]="refresh,removeItemAt";</pre>
</blockquote>
<p>Between EventsToCallLater and MethodsToCallLater you should be able to avoid many of the "<em>You are trying to call recursively into the Flash Player...</em>" errors.</p>
<p>Have you successfully uses these constants? Are there any pitfalls and/or performance issues?</p>
<p> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.themorphicgroup.com/blog/2009/02/14/fabridge-error-you-are-trying-to-call-recursively-into-the-flash-player-which-is-not-allowed/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Mysterious Default XML Namespace Issue</title>
		<link>http://www.themorphicgroup.com/blog/2009/02/09/mysterious-default-xml-namespace-issue/</link>
		<comments>http://www.themorphicgroup.com/blog/2009/02/09/mysterious-default-xml-namespace-issue/#comments</comments>
		<pubDate>Tue, 10 Feb 2009 03:19:56 +0000</pubDate>
		<dc:creator>Unknown Morphician</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[default xml namespace]]></category>

		<guid isPermaLink="false">http://www.themorphicgroup.com/blog/?p=70</guid>
		<description><![CDATA[I've been working with a RESTful service layer a lot recently that uses XML with a default namespace. In an ActionScript library project I have some delegate and model classes that natually use the default xml namespace directive. Once in a while I ran into a mysterious issue where the namespace doesn't seem to be [...]]]></description>
			<content:encoded><![CDATA[<p>I've been working with a RESTful service layer a lot recently that uses XML with a default namespace. In an ActionScript library project I have some delegate and model classes that natually use the default xml namespace directive. Once in a while I ran into a mysterious issue where the namespace doesn't seem to be applied, causing my XPath expressions to not find the values that are right there staring at me. When I stepped through the code I was able to see and trace out the complete XML value.  I was baffled and found myself in a tailspin of trying random things to solve the issue. It turned out that all I needed to do was clean the projects (duh).  I suspect that there's a small Flex compiler issue that messes with the application of namespaces. I'm curious if anyone else has had this issue and/or has a better explanation. If you've had this or a similar sounding issue, remember that it may not always be the code.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.themorphicgroup.com/blog/2009/02/09/mysterious-default-xml-namespace-issue/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Slider Track Click And Drag</title>
		<link>http://www.themorphicgroup.com/blog/2009/01/07/slider-track-click-and-drag/</link>
		<comments>http://www.themorphicgroup.com/blog/2009/01/07/slider-track-click-and-drag/#comments</comments>
		<pubDate>Wed, 07 Jan 2009 05:43:02 +0000</pubDate>
		<dc:creator>Unknown Morphician</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.themorphicgroup.com/blog/?p=64</guid>
		<description><![CDATA[The default Flex Slider component allows you to click the track to update the thumb position but does not begin the dragging of the thumb. I wanted that drag behavior but didn't want to write my own Slider from scratch. I love to read code so I looked at the mx source and found a [...]]]></description>
			<content:encoded><![CDATA[<p>The default Flex Slider component allows you to click the track to update the thumb position but does not begin the dragging of the thumb. I wanted that drag behavior but didn't want to write my own Slider from scratch. I love to read code so I looked at the mx source and found a simple way to add that functionality in a Slider subclass.</p>
<p>In mx.controls.sliderClasses.Slider, there is a trackHitArea var who's mouseDown events are registered to a track_mouseDownHandler() method. That private method has all the logic to update the position of the  thumb. But for dragging, that is initiated by the thumb (SliderThumb class), not the trackHitArea.</p>
<p><a href="http://www2.themorphicgroup.com/projects/examples/slidertrackclickanddrag/" target="_blank">Click here for a small app that shows the original Slider and the new Slider subclass side-by-side.</a> Right-click for source.</p>
<p>I ended up replicating the track_mouseDownHandler() method and changing the end of the logic to dispatch the mouseDown event through the thumb object itself to initiate dragging (and maintain the original dragging behavior as if you clicked directly on the thumb). Luckily there were enough public/protected/mx_internal namespaced methods to maintain the same logic from the original track_mouseDownHandler(). I also added an allowTrackClickDragSliderThumb Boolean to be able to maintain the original track click behavior.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.themorphicgroup.com/blog/2009/01/07/slider-track-click-and-drag/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Deconstruction and reconstruction of a ByteArray</title>
		<link>http://www.themorphicgroup.com/blog/2008/12/02/deconstruction-and-reconstruction-of-a-bytearray/</link>
		<comments>http://www.themorphicgroup.com/blog/2008/12/02/deconstruction-and-reconstruction-of-a-bytearray/#comments</comments>
		<pubDate>Tue, 02 Dec 2008 17:59:57 +0000</pubDate>
		<dc:creator>Unknown Morphician</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[ByteArray]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://www.themorphicgroup.com/blog/?p=59</guid>
		<description><![CDATA[Many times you may come up with tasks that seem pretty straight forward but involve a bit of researching. In a recent project, I needed to find a way pass a dynamically generated image from one flex application (swf) to another. My senior developer suggested that I pass the ByteArray data of the image via [...]]]></description>
			<content:encoded><![CDATA[<p>Many times you may come up with tasks that seem pretty straight forward but involve a bit of researching. In a recent project, I needed to find a way pass a dynamically generated image from one flex application (swf) to another. My senior developer suggested that I pass the ByteArray data of the image via local connection. But there is one small problem. There is a size limit for local connection, 40K. So the original data needs to be cut into smaller pieces, sent via LC and then reconstructed into the complete image data. (Note: LC = Local Connection)</p>
<p>I would suggest creating a unique local connection name between your applications (swfs). Check out Joey’s blog on this task - <a href="http://www.themorphicgroup.com/blog/2008/05/30/unique-local-connection-names/" target="_blank">unique local connection names</a>. In this project summary, I will not reference a unique connection name.</p>
<p>Here is the set up… In the first swf, I’ve set up a LC object (transSendLC) and an image object (imgOriginal). The second app (swf) somewhat mimics the first app (swf). The only difference is that I created a custom class, inheriting from LC. I’ve added a method for receiving the ByteArray and a Bitmap object. The bitmap object can be used to bind to the Image source. Note: You don’t need to create a custom class. I found that it made sense for my particular flex project.</p>
<p>Within my first app (swf), I have supplied an image (imgOriginal). Now with I need to chop up the data and send it to the second app (swf).</p>
<pre>
<code>
Example Code:
...
var width:Number = imgOriginal.width
var height:Number = imgOriginal.height;
var bytes:ByteArray =
   imgOriginal.bitmapData.getPixels(new Rectangle(0, 0, width, height))

var tempByteArray:ByteArray;

// limit byteArray to 40K - localconnection limit
var byteLimit:uint = uint(40000);

if(bytes.length &gt; byteLimit){

   var currentSize:uint = byteLimit;
   var position:uint = 0;
   var totalSize:uint = 0;

   while(totalSize &lt; bytes.length){
      tempByteArray = new ByteArray();
      tempByteArray.length = currentSize;

      // Write bytes from position to current size
      tempByteArray.writeBytes(bytes, position, currentSize);

      //send ByteArray chunk
      transSendLC.send(uniqueLCName, "sendSnapShot",
              tempByteArray, bytes.length, width, height);

      //get current total and get next position
      totalSize = totalSize + tempByteArray.length;
      position = totalSize;

      //set current size based on limit
      currentSize = bytes.length - totalSize;
      if(currentSize &gt;  byteLimit){
         currentSize = byteLimit;
      }
  }
  else{
     //less than limit - send Byte Array
     bytes.writeBytes(tempByteArray, 0, uint(bytes.length));
     imgLCSend.send(uniqueLCName, "sendByteArrayData",
                 tempByteArray, bytes.length, width, height);
  }
...
</code>
</pre>
<p>Next in my second app (swf), I need to build the sendCopy method within my custom object (inheriting from LC). Note: It is assumed that you have logic to connect the shared local connection name, a Bitmap and a ByteArray object in your custom class.</p>
<pre>
<code>
Example Code:
public function sendByteArrayData(bytes:Object, bytesLength:Number,
                              width:Number, height:Number):void {
   var byteArray:ByteArray = bytes as ByteArray;

   //New ByteArray size
   if(byteArraySnapShot == null){
      byteArraySnapShot = new ByteArray();
      byteArraySnapShot.length = bytesLength;
      byteArraySnapShot.position = 0;
   }

   //Write byte array
   byteArraySnapShot.writeBytes(byteArray);

   //Once length/size is filled based on total bytes create bitmap
   if(byteArraySnapShot.bytesAvailable == 0){
      var bitmapDataSnapShot:BitmapData = new BitmapData(width, height);
      byteArraySnapShot.position = 0;
      bitmapDataSnapShot.setPixels(new Rectangle(0, 0, width, height),
            byteArraySnapShot);

      var bitmapSnapShot:Bitmap = new Bitmap(bitmapDataSnapShot);
      snapShotImg = bitmapSnapShot;

      byteArraySnapShot = null;
   }

}

</code>
</pre>
<p>There perhaps a few ways to achieve the functionality.  My purpose here is to show the process of reading and writing ByteArray in a real world application set. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.themorphicgroup.com/blog/2008/12/02/deconstruction-and-reconstruction-of-a-bytearray/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Architecting Flex Applications Presentation</title>
		<link>http://www.themorphicgroup.com/blog/2008/10/11/architecting-flex-applications-presentation/</link>
		<comments>http://www.themorphicgroup.com/blog/2008/10/11/architecting-flex-applications-presentation/#comments</comments>
		<pubDate>Sat, 11 Oct 2008 15:57:45 +0000</pubDate>
		<dc:creator>Joey</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.themorphicgroup.com/blog/?p=57</guid>
		<description><![CDATA[For those attending the user group meetings where I present on the topic of Architecting Flex Applications you may have interest in downloading the code for the sample application. The sample application is from Programming Flex 3, where you can find more detailed information and explanations about the application itself. However, the code is fairly [...]]]></description>
			<content:encoded><![CDATA[<p>For those attending the user group meetings where I present on the topic of Architecting Flex Applications you may have interest in downloading the code for the sample application. The sample application is from Programming Flex 3, where you can find more detailed information and explanations about the application itself. However, the code is fairly well commented as well, and the application code is a free download. You can download it from the Google Code site using SVN or as a .zip file. If you are using SVN then go to <a title="http://code.google.com/p/flickrflex/source/checkout" href="http://code.google.com/p/flickrflex/source/checkout" target="_blank">http://code.google.com/p/flickrflex/source/checkout</a> to view the repository URL. If you want to download the code as a .zip then go to <a title="http://code.google.com/p/flickrflex/downloads/list" href="http://code.google.com/p/flickrflex/downloads/list" target="_blank">http://code.google.com/p/flickrflex/downloads/list</a>. I've also converted the presentation slides to a Google presentation document, which you can view at <a title="http://docs.google.com/Presentation?id=dgr5k2pm_19c64zt3cx" href="http://docs.google.com/Presentation?id=dgr5k2pm_19c64zt3cx" target="_blank">http://docs.google.com/Presentation?id=dgr5k2pm_19c64zt3cx</a>.</p>
<p>If you have questions then you can certainly post comments. Since I'm traveling I cannot guarantee a fast reply. However, I will field comments when possible, and other readers might have useful replies as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.themorphicgroup.com/blog/2008/10/11/architecting-flex-applications-presentation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dynamically Getting JavaScript Properties</title>
		<link>http://www.themorphicgroup.com/blog/2008/07/23/dynamically-getting-javascript-properties/</link>
		<comments>http://www.themorphicgroup.com/blog/2008/07/23/dynamically-getting-javascript-properties/#comments</comments>
		<pubDate>Thu, 24 Jul 2008 03:44:35 +0000</pubDate>
		<dc:creator>Unknown Morphician</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.themorphicgroup.com/blog/?p=38</guid>
		<description><![CDATA[Jumping off of Joey's post about anonymous functions from externalinterface, here's a quick and perhaps obvious method of dynamically getting JavaScript properties: package examples { import flash.external.ExternalInterface; public class JavaScript { public static function getProperty(name:String):Object { var property:Object; if (ExternalInterface.available) { property = ExternalInterface.call("function() { return " + name +"; }"); } else { property [...]]]></description>
			<content:encoded><![CDATA[<p>Jumping off of Joey's post about <a href="http://www.themorphicgroup.com/blog/2008/06/05/anonymous-functions-from-externalinterface/">anonymous functions from externalinterface</a>, here's a quick and perhaps obvious method of dynamically getting JavaScript properties:</p>
<pre>
<code>
package examples {

import flash.external.ExternalInterface;

public class JavaScript {

    public static function getProperty(name:String):Object {
        var property:Object;
        if (ExternalInterface.available) {
            property = ExternalInterface.call("function() { return " + name +"; }");
        } else {
            property = new Object()
        }
        return property;
    }

    public function JavaScript() {}
}
}
</code>
</pre>
<p>The getProperty() method creates a dynamic anonymous function that simply returns a value.<br />
With such a utility, you can easily access JavaScript properties like so:</p>
<pre>
<code>
trace(JavaScript.getProperty("window.location.href"));
</code>
</pre>
<p>Who needs the FABridge? Just kidding...</p>
]]></content:encoded>
			<wfw:commentRss>http://www.themorphicgroup.com/blog/2008/07/23/dynamically-getting-javascript-properties/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>LineLimitText Component: Text With maxLines Property</title>
		<link>http://www.themorphicgroup.com/blog/2008/06/17/linelimittext-component-text-with-maxlines-property/</link>
		<comments>http://www.themorphicgroup.com/blog/2008/06/17/linelimittext-component-text-with-maxlines-property/#comments</comments>
		<pubDate>Tue, 17 Jun 2008 20:46:48 +0000</pubDate>
		<dc:creator>Unknown Morphician</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.themorphicgroup.com/blog/?p=11</guid>
		<description><![CDATA[A little while ago I worked on a project that required some Flex screens to have text fields display dynamic text using a specified maximum number of lines. A simple solution would be to merely define a height on a Text component. In this case there were other components that flowed in the layout below [...]]]></description>
			<content:encoded><![CDATA[<p>A little while ago I worked on a project that required some Flex screens to have text fields display dynamic text using a specified maximum number of lines. A simple solution would be to merely define a height on a Text component. In this case there were other components that flowed in the layout below the text field. Setting a height would show an unnecessary space for text that had fewer than the maximum number of lines. Also setting a height wouldn't work well with changing the text styles.</p>
<p>So what was I to do? After reading the Flex docs and scanning the Text, Label, and TextField source, I decided to subclass the Text component. Here is the resulting component:</p>
<pre><code>
package com.themorphicgroup.controls {

   import flash.text.TextLineMetrics;

   import mx.core.mx_internal;
   import mx.core.UITextField;
   import mx.controls.Text;

   use namespace mx_internal;

   public class LineLimitText extends Text {

       protected var _maxLines:uint = 0; // max lines to show; 0 = do nothing;
       private var _isTruncated:Boolean = false;
      private var explicitHTMLText:String = null; 

      public function get maxLines():uint {
         return _maxLines;
      }

      public function set maxLines(value:uint):void {
         if (_maxLines != value) {
            _maxLines = value;
            invalidateDisplayList();
            invalidateSize();
         }
      }

      /**
       * Returns the number of lines displayed.
       */
      public function get numLines():int {
         var lines:int;

         if (_maxLines &gt; 0) {
            var metrics:TextLineMetrics = textField.getLineMetrics(0);
            var textHeight:Number = Math.ceil(metrics.height) * _maxLines;
            if (textField.height &gt; textHeight) {
               lines = _maxLines;
            } else {
               lines = textField.numLines;
            }
         } else {
            lines = textField.numLines;
         }
         return lines;
      }

      override public function set text(value:String):void {
         super.text = value;
         explicitHTMLText = null;
      }

       override public function set htmlText(value:String):void {
          super.htmlText = value;
          explicitHTMLText = value;
       }

      /**
       * Overriding measure and trucating the lines here.
       * If not HTML and is truncated, add ellipses.
       */
      override protected function measure():void {
         super.measure();

         // if not html
         if (!isHTML) {
            // if previously truncated, reset the text to the original
            if (_isTruncated) {
               textField.text = super.text;
               textField.validateNow();
            }
         }         

         // if want to limit lines
         if ((_maxLines &gt; 0) &amp;&amp; (textField.numLines &gt; _maxLines)) {
            // if not html
            if (!isHTML) {
               _isTruncated = true;

               var newText:String = "";
               var line:String;
               // loop through lines and collect text
               for (var i:uint = 0; i &lt; _maxLines; i++) {
                  line = textField.getLineText(i);
                  if (i &lt; (_maxLines - 1)) {
                     newText += line;
                  // if on last line
                  } else {
                     // remove end and add ...'s
                     line = line.substr(0, line.length - 3);         // cut 3 chars off end
                     line = line.substr(0, line.lastIndexOf(" "));   // cut at last space
                     newText += (line + "...");
                  }
               }
            }

            // calc and set the measured height
            var metrics:TextLineMetrics = textField.getLineMetrics(0);
            var newTextHeight:Number = Math.ceil(metrics.height) * _maxLines;
            measuredHeight = newTextHeight + UITextField.TEXT_HEIGHT_PADDING;

            // if not html
            if (!isHTML) {
               textField.text = newText;
            }
         } else {
            // if not html
            if (!isHTML) {
               // if truncated before, but dont need it anymore, reset size
               if (_isTruncated) {
                  textField.autoSize = "left";
                  measuredHeight = textField.textHeight + UITextField.TEXT_HEIGHT_PADDING;
               }
               _isTruncated = false;
            }
         }
      }

       private function get isHTML():Boolean {
         return explicitHTMLText != null;
      }
   }
}
</code></pre>
<p>The key to this component was overriding the protected measure() method and accessing the protected textField variable. The measure() method uses the new maxLines property and limits the number of lines in the textField if necessary. Now this new measure() method is more expensive so I wouldn't go and use it everywhere.</p>
<p>Here is an example application that uses LineLimitText:</p>
<pre>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:controls="com.themorphicgroup.controls.*" layout="absolute"&gt;
   &lt;mx:Script&gt;
      &lt;![CDATA[
         [Bindable]
         private var _lipsum:String = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aliquam et mi. Sed mi. In sit amet tortor. Curabitur eget neque. Ut nisi quam, convallis eget, elementum at, condimentum vitae, lorem. Vestibulum adipiscing hendrerit ligula. Donec vitae dolor id libero ultricies condimentum. Nulla dapibus sapien. Aliquam consectetuer lacus non nisl. Suspendisse rutrum. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.";
      ]]&gt;
   &lt;/mx:Script&gt;
   &lt;mx:Style&gt;
      FormItem {
         backgroundColor: #FFFFFF;
      }
   &lt;/mx:Style&gt;
   &lt;mx:Form&gt;
      &lt;mx:FormItem label="mx:Label, width=200"&gt;
         &lt;mx:Label text="{_lipsum}" width="200"/&gt;
      &lt;/mx:FormItem&gt;
      &lt;mx:FormItem label="mx:Text, width=200"&gt;
         &lt;mx:Text text="{_lipsum}" width="200"/&gt;
      &lt;/mx:FormItem&gt;
      &lt;mx:FormItem label="mx:Text, width=200, height=60"&gt;
         &lt;mx:Text text="{_lipsum}" width="200" height="60"/&gt;
      &lt;/mx:FormItem&gt;
      &lt;mx:FormItem label="controls:LineLimitText, width=200"&gt;
         &lt;controls:LineLimitText text="{_lipsum}" maxLines="4" width="200" color="#FF0000"/&gt;
      &lt;/mx:FormItem&gt;
   &lt;/mx:Form&gt;
&lt;/mx:Application&gt;
</pre>
<p>This results in the following screenshot:</p>
<p><img class="alignnone size-full wp-image-28" title="linelimittextexample" src="http://www.themorphicgroup.com/blog/wp-content/uploads/2008/06/linelimittextexample.jpg" alt="" width="423" height="386" /></p>
<p>The text in red in the screenshot uses LineLimitText. Also in the screenshot is a Text component with a defined height. That one doesn't have the fancy ellipses though. This component was an interesting exercise in understanding Flex components, reading docs and source.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.themorphicgroup.com/blog/2008/06/17/linelimittext-component-text-with-maxlines-property/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Better Unit Tests With FlexUnit</title>
		<link>http://www.themorphicgroup.com/blog/2008/06/17/better-unit-tests-with-flexunit/</link>
		<comments>http://www.themorphicgroup.com/blog/2008/06/17/better-unit-tests-with-flexunit/#comments</comments>
		<pubDate>Tue, 17 Jun 2008 12:55:11 +0000</pubDate>
		<dc:creator>Joey</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.themorphicgroup.com/blog/?p=27</guid>
		<description><![CDATA[This is probably not news. In fact, it's definitely not _new_ news on account of I learned about it from Theo Hultberg's blog from a post from last year (http://blog.iconara.net/2007/02/06/flexunit/). However, it was, rather embarassingly, news to me, and therefore I'll post it just in case someone else doesn't know this. You can write unit [...]]]></description>
			<content:encoded><![CDATA[<p>This is probably not news. In fact, it's definitely not _new_ news on account of I learned about it from Theo Hultberg's blog from a post from last year (http://blog.iconara.net/2007/02/06/flexunit/). However, it was, rather embarassingly, news to me, and therefore I'll post it just in case someone else doesn't know this. You can write unit tests with FlexUnit using what is probably a more familiar structure to most people than the structure promoted by the FlexUnit documentation.</p>
<p>I've been using FlexUnit for a few years. And during this time I naively thought you _had_ to write tests using the structure that Darron Schall wrote about (http://www.darronschall.com/weblog/archives/000216.cfm). However, I never really cared much for that structure. I found it strange, and it didn't provide the flexibility I wanted in unit tests. For client work I just accepted this. However, recently I started writing a new chapter for the pending Programming Flex 3, and I decided to mention unit tests with FlexUnit. It was at that point that I thought "there must be a better way to write these tests." It was only then that I ran a Google search and read Theo's blog post.</p>
<p>Although Theo's blog post describes how you can alternately write FlexUnit tests I'll summarize with examples as well.</p>
<p>Basically, the popular FlexUnit approach is to use a static method that returns a TestSuite for every test, and the test's constructor accepts a string parameter naming the test method to run. This is the approach that Darron writes about. It's an approach that was unfamiliar to me until working with FlexUnit. My previous experience with unit testing was purely via the (excellent) book Test Driven Development By Example, and in that book the tests are structured differently. Theo describes how to structure tests in that way. That way requires that the test constructor does not require a parameter, and instead the test runner will run all methods on the test class where the method names start with "test". I'll show a simple example.<br />
Consider the following, very complex and useful class that you need to test.</p>
<pre><code>
package {
	public class Adder {

		public function Adder() {
		}

		public function add(a:Number, b:Number):Number {
			return a + b;
		}

	}
}
</code></pre>
<p>The following shows a simple example test case class. This class defines three test methods, which is clear because the method names start with "test".</p>
<pre><code>
package {
	import flexunit.framework.TestCase;

	public class AdderTest extends TestCase {

		public function AdderTest() {
			super();
		}

		public function testPositiveInts():void {
			var adder:Adder = new Adder();
			assertEquals(adder.add(5, 4), 9);
		}

		public function testNegativeInts():void {
			var adder:Adder = new Adder();
			assertEquals(adder.add(-5, -4), -9);
		}

		public function testNaN():void {
			var adder:Adder = new Adder();
			assertTrue(isNaN(adder.add(5, NaN)));
		}

	}
}
</code></pre>
<p>The test runner looks like the following.</p>
<pre>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="creationCompleteHandler();" xmlns:flexui="flexunit.flexui.*"&gt;
	&lt;mx:Script&gt;
		&lt;![CDATA[
			import flexunit.framework.TestSuite;

			private function creationCompleteHandler():void {
				var suite:TestSuite = new TestSuite();
				suite.addTestSuite(AdderTest);
				testRunner.test = suite;
				testRunner.startTest();
			}

		]]&gt;
	&lt;/mx:Script&gt;
	&lt;flexui:TestRunnerBase id="testRunner" width="100%" height="100%" /&gt;
&lt;/mx:Application&gt;
<code>

</code></pre>
<p>Note that we use addTestSuite() to add a reference to the test case class to the test runner. This will automatically run all the methods starting with "test".<br />
Apart from the simplicity and clarity of this way of structuring tests you also get to use setUp() and tearDown(), which automatically run before and after every test method. The following is another example illustrating setUp() and tearDown(). This time we'll use a sort-of VO class called Example that has a static method for creating a new Example object from XML data.</p>
<pre><code>
package {
	public class Example {

		private var _a:String;
		private var _b:String;

		public function get a():String {
			return _a;
		}

		public function set a(value:String):void {
			_a = value;
		}

		public function get b():String {
			return _b;
		}

		public function set b(value:String):void {
			_b = value;
		}		

		public function Example() {
		}

		static public function parseFromXml(xml:XML):Example {
			var example:Example = new Example();
			example.a = xml.a.toString();
			example.b = xml.b.toString();
			return example;
		}

	}
}
</code></pre>
<p>The test for this looks like the following.</p>
<pre><code>
package {
	import flexunit.framework.TestCase;

	public class ExampleTest extends TestCase {

		private var _example:Example;

		public function ExampleTest() {
			super();
		}

		override public function setUp():void {
			_example = Example.parseFromXml(<a>Value 1</a><strong>Value 2</strong>);
		}

		override public function tearDown():void {
			_example = null;
		}

		public function testA():void {
			assertEquals(_example.a, "Value 1");
		}

		public function testB():void {
			assertEquals(_example.b, "Value 2");
		}

	}
}
</code></pre>
<p>Notice that both setUp() and tearDown() are overridden.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.themorphicgroup.com/blog/2008/06/17/better-unit-tests-with-flexunit/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Flash Video: The Best of Both Worlds (or how I learned to love Cue Points)</title>
		<link>http://www.themorphicgroup.com/blog/2008/06/11/flash-video-the-best-of-both-worlds-or-how-i-learned-to-love-cue-points/</link>
		<comments>http://www.themorphicgroup.com/blog/2008/06/11/flash-video-the-best-of-both-worlds-or-how-i-learned-to-love-cue-points/#comments</comments>
		<pubDate>Wed, 11 Jun 2008 18:21:25 +0000</pubDate>
		<dc:creator>Unknown Morphician</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://www.themorphicgroup.com/blog/?p=26</guid>
		<description><![CDATA[Video is the word. It is now used every capacity on the net. The idea of using video with animation is not new. Some would swear by using After Effects solely and not consider building flash timeline animation with video. In some case, you use what you know. And at The Morphic Group, we know [...]]]></description>
			<content:encoded><![CDATA[<p>Video is the word. It is now used every capacity on the net. The idea of using video with animation is not new. Some would swear by using After Effects solely and not consider building flash timeline animation with video. In some case, you use what you know. And at The Morphic Group, we know Flash and Actionscript.</p>
<p>We were asked to build a presentation that featured video of a person talking about the client’s product while presenting statistic and data in an exciting visual way. We decided to do this presentation with Flash Timeline animation, Actionscript, FLV video files and some luck. The idea was to get a production house to produce video excerpts with alpha layers. A script was conceived and the video assets were delivered within a few weeks to a month (give or take the corrections and post-production snafus). While we were waiting for the video to arrive, I built the shell application that would house the video sections (SWF files with external video). Each section would contain the various video takes in the order of the production script. You never know how a script like this will play until you actually build the different sections. This was definitely the case for this project.</p>
<p>For me…. The developer… I wanted to control everything to the nth degree. The shell loads all of the video sections (swfs), animates the transition moving from one section to another via script, and has a navigation link bar with a drop down menu, all the things we do best in the programming structured discipline. But for the video sections themselves, it is a different story. I needed to consider the best environment for the animator/designer to work freely, to give them enough space for their animations and somehow gel the programming and video together.</p>
<p>That is where cue points come in (and save the day). The designer/animator created a list of titles for the animation in order of the video script. We developed a system where the cue point names would be the frame titles for the main movie clip; which would house the animations. I embedded cue points into the video to then play animation content at different instances of the presentation. This planning and collaborating was done well before any flash production started.</p>
<p>Example event handler for the cue points from the FLVPlayback (videoPlayer)<br />
….<br />
videoPlayer.addEventListener("cuePoint", onCuePointHandler);<br />
….</p>
<p>function onCuePointHandler(event:MetadataEvent){</p>
<p>var cuePointName:String = event.info.name;<br />
mainAnimation.gotoAndStop(cuePointName);<br />
}</p>
<p>This is not a perfect system by any means. Most developer would poo poo the notion of using FLVPlayback, instead creating a video player class and going the route of a fully Actionscript solution. But I needed to keep in mind that the animator/designer would be using the timeline as his tool. We needed to see everything on the timeline. Animators/designers who work with the timeline seem to come up with amazing yet manageable animations that could never be created via script. Besides, it is a visual medium after all.</p>
<p>After creating one video section, we began to developer an organic workflow with the other sections. I built the FLAs with the cue point embedded video and code for referencing frame sections (named by the animation names). The designer/Animator added animations within the empty frame sections that are called based on the cue points fired. We had a system and we stuck to it throughout the project. The results were easy to see. The process of removing and moving parts that did not work was simple.</p>
<p>It is true that nothing is ever written in stone when you create a presentation like this.  Here is an example of this fact. When we tested pieces of the presentation on the web, we noticed a big problem. The video did not always synch up with animation. Keep in mind that most of the animations consisted of movie clips embedded within movie clips. The solution was to create additional cue points, directly fire (or play) beginning/ending animations when needed and remove unnecessary frames. This improved the performance greatly and solved the lag problem on the web.</p>
<p>I will be honest with you. This approach is a bit wacky. In fact, I would revise the process if another projects like this comes up again. It got the job done and it did not break the original plan and system. As long as you keep things consistent and have a plan, you will always find a way out of any jam.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.themorphicgroup.com/blog/2008/06/11/flash-video-the-best-of-both-worlds-or-how-i-learned-to-love-cue-points/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Anonymous Functions From ExternalInterface</title>
		<link>http://www.themorphicgroup.com/blog/2008/06/05/anonymous-functions-from-externalinterface/</link>
		<comments>http://www.themorphicgroup.com/blog/2008/06/05/anonymous-functions-from-externalinterface/#comments</comments>
		<pubDate>Thu, 05 Jun 2008 14:49:05 +0000</pubDate>
		<dc:creator>Joey</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.themorphicgroup.com/blog/?p=25</guid>
		<description><![CDATA[I've been working on an ActionScript library for a project. One of the recent and new requirements for this library is that it has to interface with a JavaScript API for a browser plugin. The JavaScript API for this particular plugin requires constructing instances of JavaScript objects, maintaining persistent references to those objects, calling methods [...]]]></description>
			<content:encoded><![CDATA[<p>I've been working on an ActionScript library for a project. One of the recent and new requirements for this library is that it has to interface with a JavaScript API for a browser plugin. The JavaScript API for this particular plugin requires constructing instances of JavaScript objects, maintaining persistent references to those objects, calling methods on those objects, creating divs, changing styles for divs and JavaScript objects, etc. Rather than create another set of JavaScript functions and require yet another &lt;script&gt; tag in the HTML page I figured it would be nicer to encapsulate everything into ActionScript.</p>
<p>Perhaps what I'm about to say is common knowledge and nothing of any interest to anyone. However, I thought it was interesting and worth posting about. The first parameter for the ExternalInterface.call() method is a string containing a name of a JavaScript function. When executed the call() method effectively appends the function call operator (the () ) to the function name and evaluates that expression. I hadn't seen an example using an anonymous function definition in place of a function name, but I figured it might work, and it does. I figured this would work because in JavaScript you can do the following.</p>
<pre><code>
function() { alert('example'); }();
</code></pre>
<p>Notice the function call operator appended to the anonymous function. It causes the function to execute in JavaScript. Therefore, I figured that from ActionScript you could do the following.</p>
<pre><code>
ExternalInterface.call("function() { alert('example'); }");
</code></pre>
<p>That will work, which is neat. Not only that, but you can easily pass values from ActionScript to the JavaScript. The most obvious way to do that is as in the following example.</p>
<pre><code>
var message:String = "example";
ExternalInterface.call("function() { alert('" + message + "'); }");
</code></pre>
<p>However, you can also pass values as in the following example, which is a little nicer, in my opinion.</p>
<pre><code>
ExternalInterface.call("function(message) { alert(message); }", "example");
</code></pre>
<p>These examples are really simple to illustrate the point. However, you can also create much more complex functions. In fact, you can define functions that define functions, as in the following example.</p>
<pre><code>
var javascript:String = "function() { " +
                                    "timeoutHandler = function() { " +
                                        "alert('example', 2000); + "
                                    "};" +
                                    "setTimeout(timeoutHandler); }";
ExternalInterface.call(javascript);
</code></pre>
<p>In the library I wrote the functions configure event handlers for JavaScript events, and they use ExternalInterface callbacks to call ActionScript functions when the events are dispatched.</p>
<p>I guess this use of anonymous functions might not be the most efficient way to write or run JavaScript. It might even be bad memory management. I don't claim to be a JavaScript expert. I just think it's a neat use of ExternalInterface, and it has been very useful.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.themorphicgroup.com/blog/2008/06/05/anonymous-functions-from-externalinterface/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Unique Local Connection Names</title>
		<link>http://www.themorphicgroup.com/blog/2008/05/30/unique-local-connection-names/</link>
		<comments>http://www.themorphicgroup.com/blog/2008/05/30/unique-local-connection-names/#comments</comments>
		<pubDate>Fri, 30 May 2008 15:06:13 +0000</pubDate>
		<dc:creator>Joey</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Adobe AIR]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.themorphicgroup.com/blog/?p=24</guid>
		<description><![CDATA[Occasionally I have the sense that I might be doing something as a workaround that is completely unnecessary, as though I'm jumping through hoops, listening for an exact sequence of one hundred events, and then squinting my eyes and tilting the monitor just right in order to assign text to a text field when I [...]]]></description>
			<content:encoded><![CDATA[<p>Occasionally I have the sense that I might be doing something as a workaround that is completely unnecessary, as though I'm jumping through hoops, listening for an exact sequence of one hundred events, and then squinting my eyes and tilting the monitor just right in order to assign text to a text field when I can achieve the same thing simply and directly with one line of code. All out of ignorance that there is a simpler way. This might be one of those occasions. If it is then it wouldn't be the first.</p>
<p>In this case I had a requirement to create a unique name to use when connecting a LocalConnection. The idea is that two .swf files need to communicate over this LocalConnection, and both of them need to know the name of the connection. Seems simple enough. I could just hard code the same value into both .swf files. However, the deal is that these two .swf files exist in the same HTML page, and I also would like to be able to open more than one instance of the HTML page in different browser windows. If the name of the connection is hard coded into the .swf files then it will work for one instance of the page, but subsequent instances will throw errors because the connection will already be in use. In such cases the error might be something like the following (which is particularly unhelpful in diagnosing the actual error since it doesn't really indicate what caused the error.)</p>
<p>Error #2044: Unhandled statusEvent:. level=error, code=</p>
<p>Note that you might see this error in other cases, and it doesn't necessarily indicate that the solution described in this post is appropriate. This error could be caused by lots of different scenarios. For example, you would see this error if you were trying to send requests across domains and the .swf files weren't properly configured (see allowDomain() in the LocalConnection documentation.) Probably the best way to determine the actual cause is to listen for status events on all LocalConnection object, and log the status codes. However, in this particular case the errors were because an .swf (in a new HTML window) was trying to establish a connection using the same name as a pre-existing connection.</p>
<p>One obvious solution to this would be to create a unique name using JavaScript, and then I can pass that in to each of the .swf files using FlashVars. That would allow each HTML page to create a unique name and pass in the same name to each of the .swf files, ensuring that those two .swf files can communicate over the same channel, but other .swf files in other pages wouldn't conflict. That would work except that in this particular case one of the .swf files is not embedded directly in the HTML page, and it does not have access to the JavaScript in the HTML page. This is because one of the two .swf files is embedded inside another plugin that is, itself embedded in the HTML, and that plugin doesn't have a way to pass a value from the HTML page to the Flash Player instance it embeds.</p>
<p>Therefore, the solution I'm using follows. Note that we'll refer to the .swf files as sending.swf and receiving.swf. In this case sending.swf is the instance embedded in the HTML page directly, and receiving.swf is embedded in the plugin.</p>
<ol>
<li>Initially receiving.swf calls connect() for a LocalConnection object using a hard coded value of _defaultConnection.</li>
<li>Receiving.swf's local connection client defines a method called setNewConnectionName(), which accepts a string parameter. When this method is called it first calls close() for the LocalConnection object, and then it calls connect(), using the parameter value.</li>
<li>Once both .swfs are loaded into their respective players sending.swf creates a new, unique connection name. You could use any algorithm to create a unique name. In this case I use the following: var connectionName:String = "_" + (new Date()).getTime();</li>
<li>Then sending.swf calls send("_defaultConnection", "setNewConnectionName", connectionName); for the LocalConection object.</li>
<li>After that point sending.swf always calls send() with the new, unique connection name.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.themorphicgroup.com/blog/2008/05/30/unique-local-connection-names/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
