May 28

When I started learning Flex, everytime I’ve researched for something in the oficial docs or in blogs and my eyes came across the word PACKAGES I used to be scared and thought that word was there just to confuse me.

After losing my fear about the unknown, I’ve understood that the packages were there just to make my app more organized and easier to manage.

Let’s take a look: the Object Oriented programming allows us to extend native or custom classes. If you don’t know what it is to extend a class, I recomend a quick research on Google. For a semanthics concern and for your customized classes, inherited from other class or not, do not conflict with native classes’ name, the concept of packages was created, wich work the same way as folders, in a file system.

So, it is so commom to find, in Flex programming or in Java programming, the following structure:

br/com/vedovelli/classes
br/com/vedovelli/assets
br/com/vedovelli/scripts

And when importing into you app, you should do something like this:

import br.com.vedovelli.classes.* that means import everything from folder classes, that is inside vedovelli, that is inside com that is inside br.

On class creation, the right way is do the following:

1
2
3
4
     package br.com.vedovelli.classes{
           public class Example{
           }
     }

Seems unnecessary, isn’t it? But, without that, there’s a risk of use reserved names when creating our classes and custom components. You don’t need to use the convention of reverse DNS structure (br.com.vedovelli) but the developers community recomends it as a good practice.

Regards from Brazil.

Ved