creating a swc file with FDT

Create a new As 3 project in FDT, here is a simple example of displaying text

package {
	import flash.text.TextField;
	import flash.display.Sprite;

	 * @author johnbarrett
	public class Main extends Sprite {
		private var myText : TextField = new TextField();
		public function Main() {

			myText.border = true;
			myText.x = 10;
			myText.y = 10;
			myText.width = 220;
			myText.height = 20;
			myText.text = "Creating a swc using FDT";

Now if you just run this file in FDT, you will see “Creating a swc using FDT” in a text field, no surprise here, but actually you did not actually create the swc file yet, to do so go to Run – >Run Configurations

Choose  double click this and create a project name for it, I like to use the same name as the project, in this case my project is called Ant. then choose your settings

hit apply, and then run, and your swc will be created

Now I will show a much better way using an Ant script for this.

create a build.xml file this is the ant task file that will be used. Making this in FDT is really easy:

<?xml version="1.0" encoding="UTF-8"?>
<project name="Ant">

	<target name="create swc">
		<fdt.launch.library projectname="Ant" target="../bin/Main.swc" />

then drag this build file into the ant prospective

hit the green arrow to run, and Ant will create your swc.
Make sure you use the same Jre was workspace, otherwise you will get an error!

the file has a project name, same as the project name in FDT (Ant in my case), then in the build file I give it a target name “create_swc” as this is what this does. You can have many “tasks” in your build file. Then by using the fdt.launch.library projectname property, and using target to tell here you want the swc file to go, it is done.

you can you variables to in Ant as well, but this was just might as a simple tutorial, next one I will show that way.

Pretty easy, right?

Leave a Reply

Your email address will not be published. Required fields are marked *