Can you better explain the limitations regarding "Interface files cannot contain any variable declarations or assignments." What are you calling interface files?
I am talking about interfaces in action script. Help related to this can be found under Flash Help:
Learning ActionScript 2.0 in Adobe Flash -> > > Defining and implementing interfaces
Java Interfaces allows variables to be part of the interface. We can also have static constants. These are very helpful when the interface is implemented by classes. The class can refer to these variables. (Ex: for some predefined values.)
But actionscript does not allow any variables in interfaces; only methods are allowed. There must be a valid reason for this.. was just wondering why though.
I hope im not sounding gibberish
You know more about the topic than I do. You just introduced me to something else I never knew about with Flash (I am also class challenged). But in the documentation you pointed to it seems that an interface file has to be implemented using a class file, and "Classes that implement a particular interface almost always include additional methods, variables, and getter and setter methods." The interface file appears to be only a shell, a fairly empty shell, that a class file adds functionality to.
Right on! .. in other words its an empty class without any variables. just function prototypes. Any class that "implements" it fills up the function body.
Interfaces is a very powerful concept. We can bring out amazing designs usings them.
One more limitation in actionscript is Multiple Inheritance. The work around to achieve it is using Interfaces. And we can bring out a much better Multiple Inheritance if there were variables/static constants allowed in Interfaces.
Anyways back to my question:
Why variables/static constants are not allowed in actionscript interfaces?
This question is more towards the architecture of Flash/actionscript. What amuses me is actionscript is derived from ECMA standard same as java. So interface behaviour should be same.
it's to give maximum flexibility to oop. interface files merely list all the methods and properties that are going to be defined (implemented) in another class file.
if you were going to create one project in flash, it would make no sense to use interface and implementation classes. but if you create many flash projects you might start thinking about re-using some of your previous work when a new project is needed. that's when interface/implementation classes start making sense.
I totally agree... thats the usage of interfaces.
But then again.. (sorry im repeating it again..just to keep the chain alive)
My question is not to do with the benifits of interfaces or how to use them.. its more to do with why they are the way they are
"Why arent variable/static-constant declarations allowed in actionscript interfaces???"
i explained that in my first sentence.