Share on Google+Share on Google+

Creating SWC in Flexbuilder

Advertisement
SWC is a collection of flex components like MXML or ActionScript files, images and other resource files in archived file. SWC provides security layer as the components inside the swc are not directly accessible but you need archiving tool like WinZip, JAR etc.

Creating SWC in Flexbuilder

SWC is a collection of flex components like MXML or ActionScript files, images and other resource files in archived file. SWC provides security layer as the components inside the swc are not directly accessible but you need archiving tool like WinZip, JAR etc. In addition to security, it also make easy to transfer a group of files and assets as a single file rather than each file and resources.

To create swc file, you need to create a library project. We will see how to create library project in flex builder.

Step 1: Select File->New->Flex Library Project

Step 2: Enter Project Name (MyComponents) and click finish.

Step 3: Create Component under src directory.

Step 4: Right Click the application file and select "Include Class in Library"

Step 5: This will create swc file in bin directory. You can see the figure below:

Now you can use this swc file in your application by putting it in lib directory. You can see the example below.

You can use the component in swc file as below (No any extra code to access components in swc)

<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
     
layout="
vertical"
     
width="
400"
     
height="
200"
     
xmlns:MyComp="
mycomp.*">    

      <MyComp:MyMXMLCustomComponent/>     

</mx:Application>

Advertisements

Posted on: April 12, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.