Search code examples
actionscript-3byrefargs

Can you have "ByRef" arguments in AS3 functions?


Any idea how to return multiple variables from a function in ActionScript 3?

Anything like VB.NET where you can have the input argument's variable modified (ByRef arguments)?

Sub do (ByRef inout As Integer)
 inout *= 5;
End Sub

Dim num As Integer = 10
Debug.WriteLine (num)        '10
do (num)
Debug.WriteLine (num)        '50

Anything apart from returning an associative array?

return {a:"string 1", b:"string 2"}

Solution

  • Everything in AS3 is a reference aside from [u]ints. To generalize, everything that inherits Object will be given to the function by a reference.

    That being said, the only way I believe you can do it is use a container class like an Array or a String ("5" and do the conversion+math).