Postcards From My Life

Lint I find in my mind's belly-button.
  • EPK
  • Consulting
  • Resume
  • Nerd Herding
  • Talks
  • How to Plan a Website
  • Zend Framework
« An entirely unscientific look at why people attend conferences.
Flyte World Dining and Wine »

Migrating Flex components to Flex Libraries

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=

Buffer

Tags: adobe, flex, libraries

This entry was posted on Wednesday, July 21st, 2010 at 12:00 pm and is filed under Flex, Programming. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

Logging In...

Comments are closed.

  • 2 Replies
  • 2 Comments
  • 0 Tweets
  • 0 Facebook
  • 0 Pingbacks
Last reply was October 29, 2010
  1. Gerard
    View October 29, 2010

    Buenas!

    Podrias comentar como solucionaste el “Problema desconocido”?

    Verás, tengo una aplicacion web en Flex 4 que carga de una libreria una serie de componentes.
    En la aplicacion tengo un mxml que carga las vistas, que estan en la libreria, en una tabBar.
    En la libreria tengo varias vistas, clases, asi como demas componentes que uso dentro de estas vistas.
    Resulta que llevo unos días que me sale un “Unknown Error” en la libreria y no se de que puede ser.
    Grácias por la ayuda de antemano.

    Saludos

  2. Gerard
    View October 29, 2010

    Sorry for the first comment, it’s in spanish, and sorry in advanced for my english.

    Could you explain how you solved the “unknown error”?
    I have an aplicattion that loads from a library a several components. Many days ago, Flex show me that error and I don’t know where is the problem and what to do to solve it.

    Any help would be apreciated,
    thanks!

  • Friends of mine

  • My Latest Book


    Avoiding a Goat Rodeo

  • Follow me on twitter!

  • RSS PHP Podcasts

    • PHP 5.5 Release Date Imminent – Lately in PHP podcast episode 36
    • Episode 33: Pol Pot-level Sucks
    • Episode 32: tek13
    • Episode 110: Azure hits 1 billion, RubyFlux compiler, Laracasts and more
    • Episode 7: Web Sockets Are Fast
    • Better Documentation for PHP internals – Lately in PHP podcast episode 35
    • Episode 32: tek13
    • Episode 31: Feline Tooth Extraction
    • Episode #2 – Adam Culp
    • Episode 6: PSR-X and the Mexican Standoff

  • Me, elsewhere on the Web

    • Best web design company
    • Cal Evans Dot Com
    • Cyrano’s Apprentice
    • Evans Internet Construction Company
    • My Life as a Child
    • PHP Podcasts

  • Categories

    • Apache
    • BlogBling
    • Blogging
    • Book Review
    • codeworks
    • Entertainment
    • Entrepreneurship
    • Flex
    • Humor
    • JavaScript
    • Long Form
    • Management
    • Marketing
    • Me, elsewhere on the Web
    • PHP
    • podcasting
    • Programming
    • SQL
    • Technology
    • Web 2.0
    • wordpress
    • WordPress Plugins
    • writing
    • zend framework


Postcards From My Life is proudly powered by WordPress
Entries (RSS) and Comments (RSS).