How to create an SWC file - apache-flex

All I want is to take my AS3 source code files and compile them into a SWC file.
Upon inspection, the SWC files I generate end up with some kind of timeline or spite in them when I use the Flash IDE or that Flex SDK utility "compc", and it's irritating.

Flash is timeline based; so everything in Flash uses a timeline. They hide it very well in Flex, though, so it's not obvious under the hood.
To create a SWC file in Flex, you need to use the command line compiler, although it sounds like you've already done that, so I'm unclear what your issue is.

In fact, you can build a "flex library project" in Flash builder. place your AS3 source code files in this project, it would automatic generate a swc file in which your AS3 Class;

Related

Flash Builder compiling swc and no swf

I've got an old Flex project I have to bug fix - and Flash builder is now refusing to compile a swf. I'm getting a swc only in the output directory in run or debug.
Does anyone know why Flash Builder might do this? Any settings I'm not aware of?
Flash builder will create swcs for library projects. There is probably another "shell" project that depends on the project you're looking at;
However, if I assume that this was supposed to be a regular Flex project, and it got converted into a library by mistake, you can change it back by editing the .project file in the project root. Look for the following XML element in that file:
<natures>
<nature>com.adobe.flexbuilder.project.flexlibnature</nature>
<nature>com.adobe.flexbuilder.project.actionscriptnature</nature>
</natures>
Change that to:
<natures>
<nature>com.adobe.flexbuilder.project.flexnature</nature>
<nature>com.adobe.flexbuilder.project.actionscriptnature</nature>
</natures>

where is the flex library file exist swc

can any one help me that where is the SWC or run time library for the flex controls exist in the system?
Or can we provide our own library by using the controls in the dir
C:\Program Files\Adobe\flex_sdk_3.2\frameworks\projects\framework\src\mx
It is not very obvious what are you trying to ask but I'll try to guess :)
So the SWC with Flex controls is located here {Flex.SDK.root}/frameworks/libs/framework.swc and the corresponding RSLs are located here {Flex.SDK.root}/frameworks/rsls.
What about providing your own library to replace Flex controls I think it is not the right way. The best practice is not modify Flex SDK installation to have possibility to build your project on every computer with different environments (on a different developers computers or on client site).
And you should take in mind there are 4 standard ways to use code in Flash application:
Compile your code into SWF.
Use Runtime Shared Library aka RSL (which is SWF too).
Use SWZ which is signed and can be cached by Flash Player.
Use modules which are SWFs.
None of these ways doesn't suppose using Flex SDK in runtime. Flex SDK is being used only in process of building of your application.
So the best way to use some custom controls is to build them with your application using one of the ways I described above (excluding SWZ's which can be produced only by Adobe).
Just leave Flex SDK installation without changes and place classes/SWCs with custom controls in your project's classpath.
Hope this helps.

Upgrading Flash AS3 project to CS5 and using Flash Builder 4 as IDE

I have been working for quite some time with the Flex Builder (3) as the development IDE,
and used Flash CS3 to compile my flp file (all the actionscript I wrote in the Flex Builder).
I don't use any of the Flex components. Pure AS3 and FLA for symbols.
I want to upgrade to CS5, and I read that there is a new Flash builder IDE so I thought I'll give it a try. But In the Flash builder I see that they have tighten the Flex SDK relation (which is kinda stupid since they change the name from Flex to Flash?) so I am a bit stuck with how to migrate my project.
Furthermore, is there a way to download the Flash 10 compiler/SDK or whatever to make it compile from the Flash builder, and not use Flash CS5 for it?
Thanks a lot.
Chen
You can create pure AS3 projects with the FlashBuilder IDE without worrying about the Flex framework. Simply create a new Actionscript project. You can then compile your project in FlashBuilder and strictly use CS5 for your graphic assets.
In order to migrate your project , you only need to add your classes folder to your project source library.
With Flash CS5 , export a SWC and add it to the project's library path. All this is accessible via your project Properties.
From that point on, you should be able to access both your project classes and your symbols by declaring your variables with the relevant classes.
Edit
Start simply, first create a new Actionscript project in FlashBuilder.
http://help.adobe.com/en_US/flashbuilder/using/WS6f97d7caa66ef6eb1e63e3d11b6c4d0d21-7ff7.html
After you successfully created a project and tested it, you can then add the code from Login.swf.
If you've been using a Document Class, you could create an instance of that class and add it to the stage, you could also simply copy the code in your Main class.
If Login.swf doesn't use any graphical assets, you should be good to go, without the need to load any SWCs.
You could also refactor your code so that each concern is encapsulated within its own class. For instance, if Login.swf serves as user login and loads a bunch of SWFs, it may be a good idea to create a Login class and an AssetsLoader class.

Flash Components with Flex SDK

I am using the flex SDK to compile actionscript 3 classes into an swf. Some components are not included with the SDK like the fl.controls components.
What options do I have for getting access to the flash components? I've seen others mention that I can export them to a swc file within Flash Pro, but I would rather not have to purchase Flash Pro to just use some components. Is there any other manual way to perform this without purchasing or using Flash Pro?
Thanks
You don't need to use Flash Pro to do that.
here's what I do:
create an Fla and dump all the components on the timeline that you need.
you can then remove them from there (or leave them), it doesn't really matter, as long as you see them in the library. You can even move them directly into the library.
Then under publish options select flash only, and in the flash tab select the export to swc option.
now when you compile, even when using Ctrl-Enter the swc gets compiled.
The next step would be different for you, because I use flash develop (which is free) I copy the swc into my project's lib folder, and in the program I right-click on it and select add to library. done.
I don't know how you select the add to library in flex, but it is possible. Flash develop uses the flex compiler and it does it, and flash does it as-well. so czech the project setting for this option.
You can get Free Flash Components here:
http://www.flashcomponents.net/components/free_flash_files.html?1=1&f=cprice&fv=0,0
They are not from Adobe but independent developers.
Here are set of 32 Flash UI Components for $99: http://www.flashloaded.com/flashcomponents/bitcomponentset/
I am pretty sure you have to purchase an Adobe Flash product to get the Adobe components. I used the components I got with CS4 for SDK development.

Why does Adobe Flex strip ActionScript from Flash embed symbols when compiling?

I wanted an animation to dispatch custom events as it cycled. It became apparent that not even trace() was running. After some searching, I found the following at Adobe:
http://livedocs.adobe.com/flex/3/html/help.html?content=embed_4.html
"If the SWF file contains any ActionScript code, Flex prints a warning during compilation and then strips out the ActionScript from the embed symbol. This means that you can only embed the symbol itself."
I also found a work-around by Grant Skinner at:
http://gskinner.com/blog/archives/2007/03/using_flash_sym.html
So, I can proceed, but I'm still wondering. Why does mxmlc strip ActionScript from Flash compiled resources when embedding their symbols into Flex apps using metatags?
Sorry for the very late response, but since I wrote that code, I can answer. :-)
Basically, there are two answers.
For old SWF assets that contain AS2 bytecode, it was far too much work to try to convert the bytecode to AS3. I'm assuming this isn't theuse case you care about anyway.
For SWF assets linked to AS3 bytecode, the basic problem is that there is no dependency information any more, so when we clone the asset, we have no idea what else we would need to pull. Because Flash can export a SWC, I decided that this was a far more robust workflow for getting assets with code from Flash to Flex. (Take a peek inside a SWC file, and you'll see an XML file that describes the dependencies used by the linker.)
It's probably a performance issue. To load a swf resource without stripping it, load it dynamically using SWFLoader or Loader instead of embedding it.

Resources