I'm using Flash Builder 4 (the version after Flex Builder 3, so very similar to Flex Builder 3) and have a bunch of actionscript classes that I frequently need to reference. I have them in a separate folder/package to keep things clean.
I know that it's possible to create a SWC from these actionscript files. My question is how do I do it in Flash Builder 4 or Flex Builder 3. Do I need other tools? My objective is just to use the SWC in the project and keep things clean instead of dragging around all these files.
Create a Flex Library project and put the code in the /src folder. Click on
project properties-> Flex Library Build Path -> Classes
to make sure all your classes are included.
You can set the 'Output folder' here to point to your main project /libs folder to have it automatically build into your project or just drag the .swc manually when it's created from your 'Output folder' to the 'libs' folder of your project. Hit the [OK] button and your .swc will be created. The code is now available in your main project.
In Flex Builder 3 you can right click the projects panel and choose New -> Flex Library Project. The steps to creating a project are very similar to creating a regular project. You just link the classes you want compiled into your SWC and tell Flex Builder where to put the compiled code.
other way is:
suppose you have a class Name MyCls which you want to compile into swc file.
create a Fla, and ctrl+shift+f12, check the publish item to SWC.
go to the action panel, type :
var v:MyCls;
finally, just compile this fla. it generate a swc which contains your MyCls;
Related
I'm looking at Flash Builder for my next project. I'm following some tutorials, yet I keep getting stuck at the same part. The tutorials I am following tell me to add a SWC files (containing my art) and should be in a library project.
I can create the library project and use it as a reference in my application. However, when I try to add the SWC file to the "Flex Library Build Path" the OK button does nothing. The same happens if I try to add a SWC or SWC Folder.
I' m using Flash Builder 4.6 (trial version) if that makes any difference. Below is a screenshot of the window that I am talking about in case I'm not very clear.
It has also happened to me.
There is workaround - just place SWC into /libs directory of your project and perform clean. SWCs there will be loaded automatically.
Make sure you have added the folder to the Workspace's linked resources. In Flash Builder, go to menu Windows > Preferences > General > Workspace > Linked Resources, and add a new path variable to the component directory. After this, the component can be added to the project's Flex Library path.
I think this is a bug of flash builder. It has also happened to me. And I can not choose the output path in fb....
I found a way, first, delete this project, delete evrey thing fb created itself except the source code, then u can swith ur fb to a new workspace, add creat a new project, u will see that u can add the swc file now.finally,switch back to the workspace u worked with before......
If I create a new flex project with flashbuilder, these are the libraries that get included by default through the Flex SDK:
http://neo.cycovery.com/flex_problem4.gif
If I create a ActionScript project, then the Flex SDK framework with the exact same path includes much less swc files:
http://neo.cycovery.com/flex_problem5.gif
how do I get the full flex framework into an ActionScript project?
If I try to add for example aircore.swc manually, i get a
Description Resource Path Location Type
An internal build error has occurred. Right-click for more information. mvp Unknown Flex Problem
error
Erm, you can't. Flex is a framework that brings more functionality to the table, which Actionscript cannot comprehend (and if I remember correctly, you AS project will be sprite based while Flex's is UIComponent based). You can only load a Flex application in Actionscript using the Loader.
Can I ask why are you creating an Actionscript project if you want the capabilities of Flex? Why not just create a Flex project?
In Flash Builder's new Project wizard, you need to create a new "Flex Project" and then select "Desktop" as the application type. In next screen, it asks for default main class, just specify your main .as (ActionScript) class file here.
If I create a new ActionScript project with Flash Builder and want to add some library (for example Tweenlite) where do I have to put the gs folder of Tweenlite relative to my project folder? and what do I need to setup in the project settings in order to be able to use it?
Doesn't matter, where to put your library folder. Just set the path to this folder at Project -> Properties -> Flex Build Path -> Library Path -> Add SWC Folder...(or Add SWC)
I would recommend that you create a new Library project named something like 'TweenLite' and dump the files in there. Then in Flash Builder go to:
Project -> Properties -> Flex Build Path -> Library path tab -> Add Project -> select the tweenlite project.
In this manner the project's source only gets compiled when it needs to be and the resulting swc is used by your application. You still get the benefits of the go-to source hotkey and can set breakpoints in the tweenlite project as well.
Cleaner, reusable, faster, it's how I do things.
*Ah also, multiple projects can reference the tweenlite library project now instead of having to copy & paste the code everywhere.
hi i hav tried to covert .mxlml to .swc file using flex builder
it's not working when i integrate with other application...can any one say how to get .swc using SDK...pls i need very clearly
In Flex Builder (Or Flash Builder) you need to create a Flex Library project. Put that mxml file in the library project, right click and select "include in library" from the context menu.
The Flex Library project should generate a SWC with that class which you can then use in other proejcts by adding that SWC to the library path.
Flextras is right, but a little more clearly (since you haven't accepted it yet):
Within Flex Builder (I'm assuming Flex Builder 3, but it's probably the same in Flash Builder), go to File -> New -> Flex Library Project. Enter a name an click Finish. This creates your project.
Create (or copy) the files you wish to compile into the src folder in your new project. The trick is that when you copy a file to the src, it is NOT automatically included in the library's build, and hence it will NOT end up compiled in the resulting SWC.
To include these files in the library build, right click on the project in the Navigator panel and select Properties. Click on "Flex Library Build Path" on the left, and under the "Classes" tab on the right, click "Select All" (or check the boxes you wish to include manually).
Once your files are included in the library project's build path, simply build the project. The build should happen automatically, but you can go to the Project menu and select "Clean" to be sure. Ensure that your project compiles correctly (no compile errors), and a SWC file should be generated in the bin folder. Note that pretty much whenever you change anything within the project's file structure, you will probably need to repeat the step of clicking "Select All" in the library build path.
i have several flash projects and i have common classes. is there a way to share these classes between the project so i won't need to copy it to all the project when ever i modify something?
In Flex Builder, right click on the project and choose properties. In the Flex Build Path section choose Add Folder... and pick the project you want to reference then the /src folder (so ${DOCUMENTS}//src). This will allow one project to use the classes in another project. However be careful as this will slow down compile times. Probably a better idea to build a library where you have dependencies.
in adobe flex/flash builder when i add a new folder, i can click on advanced and then i can choose to which folder, this folder will be linked. by doing so i can share directories between several projects.