Tuesday, December 04, 2007

The class 'com.your.class' cannot be imported because its leaf name is already being resolved to imported class 'com.your.class'.

While I was refactoring some ActionScript2 code, I ended up with the above error message.
I searched the web and what I came up with was mostly the information that such a message actually exists.
so after figuring out why I got that error I decided to write about it here for your benefit. (Leave me a comment if it helped you).

well it turns out that this was cause by the following proccess:
I have an adbode flash source .FLA file which had inside its _root code two #include statements:

lets say
#include "fileA.as"
and
#include "fileB.as"

now each of those file in its turn had an import statement
import MyClass
where MyClass.as was a file that was on the same directory as the .FLA, fileA.as & fileB.as.

It worked fine.
But when I started refactoring and moved MyClass to become com.whatever.MyClass
(with all the required changes to MyClass, fileA and fileB) I suddenly got
"The class 'com.whatever.MyClass' cannot be imported because its leaf name is already being resolved to imported class 'com.whatever.MyClass'".

The solution was to remove the import statements from fileA.as and FileB.as
and just place one import directly in the .FLA.

(the #include files are on thair way out as well...)

My recomendation: Try to avoid #include, most likely you can get better results by using a static class.

 
Clicky Web Analytics