It won't throw any errors at compile time if you mess up but you could do something like this:
public function awesomefunction(input:Object):void {
if (input.foo) trace("got foo");
if (input.bar) trace("got bar");
}
And then when calling it doing like this:
awesomefunction( { foo : 23, bar : 99 } );
The {} brackets create an inline object.
A long winded version of the above code can be written like this:
var obj:Object = new Object();
obj.foo = 23;
obj.bar = 99;
awesomefunction( obj );
If you give it an array instead:
awesomefunction( [23, 99 ] );
( [] is shorthand for an array btw )
The indices will be accesible like this:
public function awesomefunction(input:Object):void {
if (input[0]) trace("got foo");
if (input[1]) trace("got bar");
}
So to bring it all toghether you can use the fact that the || operator returns the value of the object that first evaluates to true, not just true to do:
public function awesomefunction(input:Object):void {
var foo:int = input.foo || input[0];
var bar:int = input.bar || input[1];
if (foo) trace("got foo:", foo);
if (bar) trace("got bar:", bar);
}
So, the above function will give the same output for all these three calls:
awesomefunction( { foo : 23, bar :55 } );
awesomefunction( { bar : 55, foo : 23 } );
awesomefunction( [ 23, 55 ] );
This will however not allow you to mix named and numbered, but you can do like this:
awesomefunction( { foo : 23, 1 : 55 } );
It's not very pretty, but it works!