<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss'><id>tag:blogger.com,1999:blog-3120990982483200327</id><updated>2009-02-20T17:55:53.097-08:00</updated><title type='text'>Screaming From Beneath The Waves</title><subtitle type='html'>Flex/Flash Actionscript Development, Record Reviews, etc.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://red-light-runner.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3120990982483200327/posts/default'/><link rel='alternate' type='text/html' href='http://red-light-runner.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>John DeIorio</name><uri>http://www.blogger.com/profile/00559451564901445340</uri><email>noreply@blogger.com</email></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>1</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3120990982483200327.post-5874938785718497584</id><published>2008-04-08T11:10:00.000-07:00</published><updated>2008-04-08T14:13:35.784-07:00</updated><title type='text'>Create an SWC from an AS3 Class in Flex</title><content type='html'>You can compile actionscript class files into binary SWC files for easier distribution and reuse by using the compc.exe tool in the Flex SDK. For instance, the entire Cairngorm framework source code is also available as an SWC, and is easily added to your project by simply copying and pasting the swc into your "lib" folder in your Flex Project (Rather than copying the "com" directory, specifying the global source path, etc... ). So here is a simple example of how to compile a class into an swc and test it in another project:&lt;br /&gt;1. Create a new folder called "swc", and place it somewhere easy to access, such as "d:\flex\swc"&lt;br /&gt;2. Create a simple actionscript class, such as the following "Hello.as" file, and place it in the "swc" folder.&lt;br /&gt;package swc&lt;br /&gt;{&lt;br /&gt;public class Hello&lt;br /&gt;{&lt;br /&gt;public function Hello()&lt;br /&gt;{&lt;br /&gt;    trace("hello");&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;2. Locate your compc.exe file in the Flex SDK. If you are using Flexbuilder 3, it should be located in the "C:\Program Files\Adobe\Flex Builder 3\sdks\3.0.0\bin" directory.&lt;br /&gt;3. Run the compc.exe file by navigating to the same directory via the command prompt, then type the following in &lt;span style="color: rgb(255, 0, 0); font-weight: bold;"&gt;RED&lt;/span&gt; on the same line (separated here only for readability) :&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 0, 0);"&gt;compc.exe&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 0, 0);"&gt;-source-path=D:\flex&lt;/span&gt; &lt;span style="color: rgb(102, 102, 204);"&gt;[path to your package]&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0); font-weight: bold;"&gt;-include-classes swc.Hello&lt;/span&gt; &lt;span style="color: rgb(102, 51, 255);"&gt;[this dot notation must match exactly the same as designated by the package in the class]&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0); font-weight: bold;"&gt;-output=D:\flex\swc\bin\myHello.swc&lt;/span&gt; &lt;span style="color: rgb(102, 51, 255);"&gt;[where you want the swc generated and it's name]&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;4. When you hit return, a folder called "bin" will be created with the swc file inside it. Create a new Flexbuilder 3 project, and simply place this swc into the &lt;span style="font-weight: bold;"&gt;libs&lt;/span&gt; directory. That's it! It is now ready to be accessed via AS3 or through the mxml, such as in the following example:&lt;mx:application mx="http://www.adobe.com/2006/mxml" layout="absolute" swc="swc.*"&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 204, 0); font-weight: bold;"&gt;        &lt;/span&gt;&lt;/mx:application&gt;&lt;span style="color: rgb(51, 204, 0);"&gt;//instantiated through actionscript&lt;/span&gt;&lt;mx:application mx="http://www.adobe.com/2006/mxml" layout="absolute" swc="swc.*"&gt;&lt;span style="color: rgb(51, 204, 0); font-weight: bold;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 204, 0); font-weight: bold;"&gt;        import swc.Hello;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 204, 0); font-weight: bold;"&gt;        public var myHello:Hello = new Hello;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 204, 0); font-weight: bold;"&gt;       &lt;/span&gt;&lt;span style="color: rgb(51, 204, 0);"&gt;//instantiated through mxml&lt;/span&gt;&lt;span style="color: rgb(51, 204, 0); font-weight: bold;"&gt;&lt;br /&gt;      xmlns:swc="swc.*"&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(51, 204, 0); font-weight: bold;"&gt;      &lt;swc:hello&gt;&lt;/swc:hello&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;&lt;/span&gt; &lt;span style="color: rgb(102, 102, 204);"&gt;&lt;mx:application mx="http://www.adobe.com/2006/mxml" layout="absolute" swc="swc.*"&gt;&lt;/mx:application&gt;&lt;/span&gt; &lt;span style="color: rgb(102, 102, 204);"&gt;    &lt;mx:script&gt;&lt;/mx:script&gt;&lt;/span&gt; &lt;span style="color: rgb(102, 102, 204);"&gt;        &lt;!--[CDATA[&lt;/span&gt; &lt;span style="color: rgb(102, 102, 204);"&gt;            &lt;/span&gt; &lt;span style="color: rgb(102, 102, 204);"&gt;        //import swc class&lt;/span&gt; &lt;span style="color: rgb(102, 102, 204);"&gt;        import swc.Hello;&lt;/span&gt; &lt;span style="color: rgb(102, 102, 204);"&gt;        &lt;/span&gt; &lt;span style="color: rgb(102, 102, 204);"&gt;        //instantiated through actionscript&lt;/span&gt; &lt;span style="color: rgb(102, 102, 204);"&gt;        public var myHello:Hello = new Hello;&lt;/span&gt; &lt;span style="color: rgb(102, 102, 204);"&gt;            &lt;/span&gt; &lt;span style="color: rgb(102, 102, 204);"&gt;        ]]--&gt;&lt;/span&gt; &lt;span style="color: rgb(102, 102, 204);"&gt;    &lt;/span&gt; &lt;span style="color: rgb(102, 102, 204);"&gt;    &lt;/span&gt; &lt;span style="color: rgb(102, 102, 204);"&gt;    &lt;!-- instantiated through mxml --&gt;&lt;/span&gt; &lt;span style="color: rgb(102, 102, 204);"&gt;    &lt;swc:hello&gt;&lt;/swc:hello&gt;&lt;/span&gt; &lt;span style="color: rgb(102, 102, 204);"&gt;    &lt;/span&gt; &lt;span style="color: rgb(102, 102, 204);"&gt;&lt;/span&gt;&lt;/mx:application&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3120990982483200327-5874938785718497584?l=red-light-runner.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://red-light-runner.blogspot.com/feeds/5874938785718497584/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=3120990982483200327&amp;postID=5874938785718497584' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3120990982483200327/posts/default/5874938785718497584'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3120990982483200327/posts/default/5874938785718497584'/><link rel='alternate' type='text/html' href='http://red-light-runner.blogspot.com/2008/04/create-swc-from-actionscript-3-code.html' title='Create an SWC from an AS3 Class in Flex'/><author><name>John DeIorio</name><uri>http://www.blogger.com/profile/00559451564901445340</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='03897086043006365830'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry></feed>