PDA

View Full Version : structure, packages, dizzyness



str3ber
August 9th, 2007, 10:44 AM
Hi!

I am trying to build a set of components. All of the components will implement the same interface and I guess that some of the components will contain several class files.

I am trying to figure out how to structure this project, and it gives me headache and a lot of compile errors...

My structure is now:

The MyComponents.fla (which contains all of the components) and my interface IMyComponents.as reside in the following directory: MyComponents.

Ok... So two files there... For the first component that I am currently developing I have made a sub directory within the MyComponents folder called "Component1".

There I have the following files:

Component1.as (the class for the component) + Component1Shim.fla and Component1LivePrev (These two are not really relevant for the structure though).

Ok, to clarify, I have

MyComponents\MyComponent.fla
MyComponents\IMyComponent.as
MyComponents\Component1\Component1.as

Since I want all of the (future) components (within this component package) to implement the same interface, to me it makes sense to place the interface "one level up" in the structure, but I have no idea how to access it from Component1.as. I just get an error from Flash that says it cannot find IMyComponent.as. Well duh, of course you can not! You need to look one level up you bastard! But since it is an .as file I cannot set a classpath and the ..\ for going up one level do not seem to work I am totally out of luck!

How do I solve this issue? Copying the interface to all of the components root directories makes no sense, or does it?

tecknoize
August 9th, 2007, 10:59 AM
You just need to provide the full path to your interface. In fact, forget "path" and think "package". What you want the compiler to do is to import your IMyComponent Interface.

Since you are compiling from the FLA, the compiler start at your FLA level to search for class definitions. In this case, whenever you need IMyComponent, from anywhere down your FLA, you type :

import IMyComponent;

Hope this help!

str3ber
August 9th, 2007, 11:46 AM
Thanks for your reply!

I added my project directory to the global path and tried it out and it worked! Sort of.. I have a strange problem now. In the Component1.as I import the MyComponents.IMyComponent at the top and then implements IMyComponent and get a 5001 error (The name of package MyComponents.IMyComponent does not reflect the location blah blah). But if I change the "implements IMyComponent" to "implements MyComponents.IMyComponent" it works fine. But it makes no sense that I need to provide the full path since I have already imported it in the package body. I thought that was what import was for?



You just need to provide the full path to your interface. In fact, forget "path" and think "package". What you want the compiler to do is to import your IMyComponent Interface.

Since you are compiling from the FLA, the compiler start at your FLA level to search for class definitions. In this case, whenever you need IMyComponent, from anywhere down your FLA, you type :

import IMyComponent;

Hope this help!

tecknoize
August 9th, 2007, 02:12 PM
Maybe check your package for IMyComponent... if you import MyComponent.IMyComponent, your package for IMyComponent should be MyComponent.