petruza
06-02-2008, 11:47 PM
Hi! I've been reading some mentions to package functions and package variables in AS.
Do they exist in AS 3 ?
if I try to define a function directly inside a package and not in a class, I get this error:
A file found in a source-path can't have more than one externally visible definition. [function name];[filename]
I'm trying to define this function to count the elements of an associative array implemented as an Object:
function length( object :Object ) :uint
{
var length :uint = 0;
for( var i :uint in object )
++length;
return length;
}
I use the unnamed package, and want this function to be accesible from within that package.
One solution would be to make it a static member of any class of the package and access it that way, but the function would be totally unrelated to the class, insulting the whole OOP idea.
While I write this, I figure out that 'the whole OOP idea' would rule out the use of standalone functions in favor of class methods :o
Anyway, are there such things? thanks!
Do they exist in AS 3 ?
if I try to define a function directly inside a package and not in a class, I get this error:
A file found in a source-path can't have more than one externally visible definition. [function name];[filename]
I'm trying to define this function to count the elements of an associative array implemented as an Object:
function length( object :Object ) :uint
{
var length :uint = 0;
for( var i :uint in object )
++length;
return length;
}
I use the unnamed package, and want this function to be accesible from within that package.
One solution would be to make it a static member of any class of the package and access it that way, but the function would be totally unrelated to the class, insulting the whole OOP idea.
While I write this, I figure out that 'the whole OOP idea' would rule out the use of standalone functions in favor of class methods :o
Anyway, are there such things? thanks!