tags:

views:

27

answers:

2

hi,

I've just imported a Flex component into my project. I have a theory question about importing.

all the imports statements in the component source files started with "com.subFolder.etc", but I have preferred to move the component folders into "componentName" and to replace all import statements as "componentName.com.subFolder.etc"

Is this ok ? Everything works perfectly, but I was wondering if the method is correct.

thanks

A: 

It's totally correct, yes.

Note that Flex Builder (if you're using it) can automatically replace your import statements/class name when you rename a directory or a .mxml/.as file.

I never tried moving a complete structure, though, but I would't be surprised if it worked too.

Zed-K
A: 

You can put the components anywhere you like, however you want to organize them. People will site best practices and theory but if you know where everything is and you tell the compiler where they are:

import componentName.com.subFolder.componentToBeUsed;

Everything will compile and run just fine.

Usually you will see code and components broken up in a domain model.

So you'll have:

com.yoursite.views com.yoursite.events com.someothersite.renderers

Which correspond to:

/com/yoursite/views
/com/yoursite/events

Basically all of your code living in folders within /com/yoursite/

and:

/com/someothersite/renderers

being a custom renderer you imported from someothersite.com to use in your application.

In the end, for the compiler and the flash player I don't think it matters where you put things as long as your happy and understand it all...and of course 6 months from now when you come back to look at this code!

ethyreal