Even the most simple task seems to take me forever in Flex, since I have to troll through reams of documentation to make sure I understand the concepts involved. This morning I came across something in one of my references that went something like this:
I went through reams of documentation looking for something to verify this, but couldn't. Finally, someone on a Google Group I belong to posted this quote from Colin Moock's Essential Actionscript 3.0."Because this class is in the same package as the other class you want to use, you don't need to add an import statement in order to use it."
"Code in a given package can refer to the classes in that package by their unqualified names... To gain access to a class in another package, we use the import directive..."
So yes, it's true. You don't have to import classes in the same package as the one where you are working.
1 comments:
Flex packages work like namespaces. The whole point of having them is to allow 2 classes with the same name (but usually different authors) to exist in a single project without messing with each other. So it's safe to call a class in the same package without the fully qualified name since it's guarantied to be uniquely named.
Having said that, I never understood why the package directive is there since flex won't allow you to rename it to anything other than the parent directory's name ("A file found in a source-path must have the same package structure as the definition's package"). So why doesn't flex use directory names for packages at the first place?
Post a Comment