Robert,
I come across this problem all to often, no other alternatives.
Basically one or multiple of;
Use Interfaces
Use events
Remove function to a helper class
Loose type as either Object or no type at all.
Hit check syntax button twice(this does fix it in some cases)
Ignore it(in some cases it will compile even with the warning)
Switch to one of the classes check syntax in that class, then go to other
class and recheck the syntax(prblem goes away in some cases) 
Use MTASC (cos they dont have that problem)

Fundementally this is a compiler bug not a coder's problem. 

I havent tried but I am hoping its fixed in AS3 (was really dissapointed
they didn't bother to fix it in F8)

In your case use events to communicate between child/parent or loose type
the parent ref in the children.
Rob

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Robert Tweed
Sent: Friday, October 21, 2005 5:41 PM
To: Flashcoders mailing list
Subject: Re: [Flashcoders] Cyclic dependencies and strong typing - bug?


OK, to some extent I have managed to answer my own question - but only 
for the simplified example I gave, not for my actual code.

I can solve the example problem by using subclasses or interfaces. By 
keeping some of the functions out of the base class, I can remove all 
cyclic dependencies. This may or may not be good design, but I'd rather 
not be forced to do this - it's an imperfect solution at best. 
Unfortunately there is a different case where this solution cannot be 
applied anyway.

In my real-world case I have a single global manager, for which I am 
using a static object. Having more than one instance of this object 
would be bad, so it has to be static. This class spawns sub-objects, 
which must occasionally perform a callback to the static class - this 
happens because the sub-objects are listening to timed events not 
initiated by the static class.

Because the static class has to spawn these objects itself (they are 
private members) and the objects have to call back to the static class, 
the cyclic dependency cannot be removed. I can't use interfaces here, 
because you can't pass a reference to a static object (it has no "this" 
- even though it does exist in RAM, so maybe it _should_ have one).

The only solution I can think of for this is to make the container class 
nonstatic, but wrap it inside a static interface (then maybe try to find 
some way to make the object a singleton without making it static). In 
theory, this is a pretty good solution, because it removes the 
dependency on a static (global = bad) class, making the objects more 
general purpose, but they _aren't_ general purpose objects, so in 
reality its just adding bloat for no good reason.

Surely I'm not the first person to run into this problem? If anyone has 
come up with some different ideas I'd really like to know.

- Robert
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders



_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to