Open access to the private member of the class(protected class method fom SWC, for example). Create two members of the class with the same name, one public and the second - private.
For a public member of the class instead of the keyword "public" use a custom namespace with an empty URI.
May be
you already know that ActionScript 3 allows you to create
instance and static methods with the same name. I will show now
to create public and private methods with the same name inside
one class.
For
example, you have a class with defined private method
"test":
package
{
public
class
ExampleObject
extends
Object{
public
function
ExampleObject():
void
{
super
();
test();
}
protected
function
test():
void
{
trace
(
'ExampleObject.test()
- protected method'
);
}
}
}
To create
another, public method "test" in the same class you need to
define it in specific namespace. So, define it:
package
{
public
namespace
simple_ns =
''
;
}
After
that you can define method "test" in that namespace:
package
{
public
class
ExampleObject
extends
Object{
public
function
ExampleObject():
void
{
super
();
test();
}
simple_ns
function
test():
void
{
trace
(
'ExampleObject.simple_ns::test()
- public method'
);
test();
}
protected
function
test():
void
{
trace
(
'ExampleObject.test()
- private method'
);
}
}
}
Namespace
with empty URI value used, because this is default namespace and
you can access members in that namespace without specifying
its.
trace
(
' --- creating instance --- '
);
var
object:ExampleObject =
new
ExampleObject();
trace
(
' --- calling public method --- '
);
object.test();
/* trace output
--- creating instance ---
ExampleObject.test() - private method
--- calling public method ---
ExampleObject.simple_ns::test() - public
method
ExampleObject
.
test
()
-
private
method
*/
In output
you can see, that first called private test method, because it was
called inside constructor, after that called public method
simple_ns::test() with call of private method inside.