<?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>Jeff dePascale &#187; Flex SDK</title>
	<atom:link href="http://www.jeffdepascale.com/index.php/tags/flex-sdk/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jeffdepascale.com</link>
	<description>Blogging on and developing web and mobile technologies</description>
	<lastBuildDate>Mon, 12 Apr 2010 18:09:02 +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>Creating partial package SWC files</title>
		<link>http://www.jeffdepascale.com/index.php/flash/creating-partial-package-swc-files/</link>
		<comments>http://www.jeffdepascale.com/index.php/flash/creating-partial-package-swc-files/#comments</comments>
		<pubDate>Tue, 01 Sep 2009 18:04:20 +0000</pubDate>
		<dc:creator>Jeff dePascale</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[FlashDevelop]]></category>
		<category><![CDATA[Flex SDK]]></category>
		<category><![CDATA[Fosfr]]></category>
		<category><![CDATA[SWC]]></category>

		<guid isPermaLink="false">http://www.jeffdepascale.com/?p=158</guid>
		<description><![CDATA[If you're a Flex developer, SWC's are nothing new to you. But for Flash dev's, SWC files are one of those 'yea I've seen those, but I don't totally understand how, what, or why I'm supposed to use them' things in Flash development. They're incredibly useful - if you know exactly how to use them. [...]]]></description>
			<content:encoded><![CDATA[<p>If you're a Flex developer, SWC's are nothing new to you. But for Flash dev's, SWC files are one of those 'yea I've seen those, but I don't totally understand how, what, or why I'm supposed to use them' things in Flash development. They're incredibly useful - if you know exactly how to use them. Especially in CS3 (CS4 made it a little less painless with the explicit abiliy to specify SWC files as internal or external libraries). Unfortunately, generating them can be even more confusing. there just isn't much documentation, and if you use the flex sdk and/or FlashDevelop, the compc.exe command line options are daunting. </p>
<p><span id="more-158"></span></p>
<p>Luckily, it isn't as hard as it seems. For developers, one of the best uses for SWC (Flash builds require a matching SWF file as well) files in flash AS3 dev is packing up pre compiled libraries for use at runtime ( you can also package assets, but that isn't what we are here to talk about). It's pretty straightforward using the export SWC option under publish settings. But what if you need to export only a portion of the package as a SWC/SWF library? </p>
<p>I did some searching, and the few topics I found that mentioned this had replies that questioned the merits of the idea instead of proposing how to go about it. In my case, for Fosfr, I was looking to produce an external library file, but needed to include about 13kb of the entire 50kb package in the core SWF file to properly launch the loading process of the framework, which would then go and get the rest of the library before running any code that needed the full framework library. So there are legitimate cases where you may want to do this. And actually, it can be done.</p>
<p>So, how to go about it? The problem lies in that generating SWC files pulls all classes referenced from your chosen classes along with them into the SWC. so, say you are using TweenLite in your package that you wish to turn into a SWC. Check the SWC afterwards and you'll see that the TweenLite package got sucked in there too. So how can this be avoided? To do it you'll need to use one of the powers of SWC's themselves -compile time class referencing - and one of their usage nuisances - priority of classpaths over SWCs in Flash. </p>
<p>Here's the steps to generate a partial package SWC:</p>
<p>1 - Create an FLA to make a SWC and generate a full SWC of the entire package you wish to generate as a SWC. Dont worry about file size or excess files, this file is for reference. </p>
<p>2 - Take the SWC and place it next to that same FLA (CS3) or in publish setting specify the SWC as an external library (CS4). Now, go back to your class package. Save a backup copy first, then in the package folder, erase all of the classes you'd like to EXCLUDE from the SWC library. </p>
<p>3 - Generate another SWC  (give it a different name). If you did this right, this new SWC will only contain the classes you have left in the package folder. Since the Flash compiler prioritizes classpaths over SWC files, the compiler found the source for those files in the right place, so it placed them in the new SWC. When it got to one it couldnt find, it then searched your external library SWC's, in this case the one holding the whole package and said 'yes, here it is, it compiles and I'm cool with it'. Since it is an external library though, it doesn't pull the class into the new SWC. The result? a partial package SWC and SWF library, containing only the .as files you explicitly wanted contained inside. </p>
<p>This leaves two open ends. </p>
<p>First, you must be positive that you aren't referencing any of the classes you left out before you load in the full library for use (remember proper loader context, ApplicationDomain.currentDomain, to access those classes at runtime). </p>
<p>Second, what about that full library? now you have a full library that has files you've since duplicated in the new smaller SWC. Well, you can, if you wish, reverse the process and go back and use this new smaller SWC as an external lib and remove the classes contained inside from your package, and recompile. What you'll wind up  with is a full package split cleanly between two SWC files. Pretty nifty. It's a fair amount of work, and it should be easier, and maybe it is - if someone has a better solution, please share!</p>



		<!-- Added by WP-DragToShare-eXtended Plugin -->
		<script type="text/javascript">
			dtsv.dtse_post_158_permalink = 'http://www.jeffdepascale.com/index.php/flash/creating-partial-package-swc-files/';
			dtsv.dtse_post_158_title = 'Creating partial package SWC files';
		</script>
		<!-- End of WP-DragToShare-eXtended Plugin -->]]></content:encoded>
			<wfw:commentRss>http://www.jeffdepascale.com/index.php/flash/creating-partial-package-swc-files/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>
