Reputation: 39456
I've been taking a look at the use of namespaces in ActionScript 3, and honestly I can't see why they're needed. Does anyone have a convincing example of their use?
I'm also finding them strangely hard to implement.
Upvotes: 0
Views: 1625
Reputation:
These are compile time uses of namespace:
Aliasing packages is possible with Flex SDK compiler and ShockScript. Normally, conflicting or confusing package-qualified names would be deambiguated like this:
com.qux.fn()
com.baz.fn()
But with aliasing:
namespace q = 'com.qux'
namespace b = 'com.baz'
q::fn()
b::fn()
Upvotes: 0
Reputation: 5004
I was researching on usage of this namespace feature.
I stumbled upon another link with more comprehensive explanations with some example usage in the maashaack project: https://code.google.com/p/maashaack/wiki/Namespace
One example given is overriding access modifiers. Reproduced below:
package test
{
public class ClassA
{
public function ClassA()
{
}
public function test( msg:String ):void
{
trace( msg );
}
protected function trace( msg:String ):void
{
public::trace( "[ " + msg + " ]" );
}
}
}
Upvotes: 0
Reputation: 48137
This is a good write-up on namespaces: http://gskinner.com/blog/archives/2010/01/a_complete_guid.html
I avoid using them in my own code... but sometimes I need to use them when working with framework classes employ them. For instance, ObjectProxy
uses them.
They seem like a quirk of the language to me... and they seem like they are used to get around limitations of the language. (see comment below)
Upvotes: 3