Over a million developers have joined DZone.

Migrating Flex components to Flex Libraries

· Web Dev Zone

Make the transition to Node.js if you are a Java, PHP, Rails or .NET developer with these resources to help jumpstart your Node.js knowledge plus pick up some development tips.  Brought to you in partnership with IBM.

Dear Reader,

Recently I decided to consolidate all of the custom and reusable controls I had created in Flex into a single library. Even as good as Eclipse is at refactoring (one of the things it actually does well) it still wasn’t was clear cut of a procedure as I had hoped for.

Step 1: Create the library

As with everything in Flash Builder 4, creating a new library is just a matter of right-clicking somewhere and selecting New and then “Flex Library Project”.


Give the library a name and you are good to go. One caveat though. If you look closely, you will see a check box “Include Adobe AIR libraries” If your components will need access to things like flash.filesystem.* you will need to check this box. NOTE: I have yet to test a library with AIR libraries included inside a Flash application, most of my programming is AIR based. I do think it should work. However, if it does not, you will need to break your libraries into AIR and Flash respectively.

If you forget to check the AIR libraries box or if you change your mind later, you can right click on the project, select properties and then “Flex Library Compiler”.


Step 2:Migrating Components

For most of my components, this was as easy as dragging them from the project they were in into the new library. Since one of my components (My File Selector control) required access to the file system and I had NOT checked the AIR libraries check box, it did not come over without errors. It took me a while to realize the error because Flash Builder was giving me the very helpful “Unknown Flex Problem” error. By the time I realized what the problem was, I had re-created the entire class manually. (Not a terribly difficult process for this particular control) Re-creating it also gave me a chance to refactor it and split the code and MXML into separate classes.

Step 3: Use it!

The final step is to link the project to your new library. Just right click on your project, select properties and then “Flex Build Path”


Click on “Add Project” and Flash Builder 4 will give you a list of all the libraries it knows of that you have not yet included in the project. Select your new project and click on OK.

That was all there was. Other than the one snag, it was a very easy process. Now I just need to locate and migrate the other little controls that I have written into this library.

Until next time,
I <3 |<
=C=

Learn why developers are gravitating towards Node and its ability to retain and leverage the skills of JavaScript developers and the ability to deliver projects faster than other languages can.  Brought to you in partnership with IBM.

Topics:

Published at DZone with permission of Cal Evans, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}