AS3 Version of ByRef or ByVal? (And readonly)

It seems like AS3 is pretty much all about instances. No matter what you make, it seems you make it, and then just keep passing around those instances.

One thing that frustrates me is if you make an instance read-only (only a getter, but no setter message, or if you make it a constant) you can’t make a new instance out of that new

const lockedArray:Array = new Array("hi", "ho", "hi", "ho");

//This will still work despite it being a constant!
lockedArray.push("It's home to work we go!");

This does the same thing, and still will not keep the user from adding stuff:

private var _lockedArray:Array = new Array("hi", "ho", "hi", "ho");
public function get lockedArray():Array
{ return _lockedArray; }

//This will still work despite it being a constant!
lockedArray.push("It's home to work we go!");

So really all you are doing is preventing the user from making the lockedArray null or a new Array.

That doesn’t seem very read only to me!

For my second complaint (which was my original complaint) when you pass in variables in a function in VB.Net, you have the option of using either ByVal or ByRef. The first passes in variables as read only. The second passes in references to variables, similar to what AS3 **always **does.

This is “pseudo-vb-to-AS3-converted” code:

var num1:int = -20;
var num2:int = 35;

trace(num1, num2, num1 + num2); //OUTPUT: -20 35 15
addNumbers(num1, num2); //ByRef version
trace(num1, num2, num1 + num2); //OUTPUT: 20 35 15

function addNumbers(ByRef in1:int, ByRef in2:int)
{
   if (in1 < 0)
      { in1 = in1 * -1; }
   if (in2 < 0)
      { in2 = in2 * -2; }
   
   trace(num1, num2, num1 + num2); //OUTPUT: 20 35 15
}

And here is what happens if you use ByVal:

var num1:int = -20;
var num2:int = 35;

trace(num1, num2, num1 + num2); //OUTPUT: -20 35 15
addNumbers(num1, num2); //ByVal version
trace(num1, num2, num1 + num2); //OUTPUT: -20 35 15

function addNumbers(ByVal in1:int, ByVal in2:int)
{
   if (in1 < 0)
      { in1 = in1 * -1; }
   if (in2 < 0)
       { in2 = in2 * -2; }
   
   trace(num1, num2, num1 + num2); //OUTPUT: 20 35 15
}

What does Flash do in these cases? Is there anything similar?

Does it pass in values when using TopLevel classes and references when using other classes?