2 Replies Latest reply on Nov 2, 2006 3:54 PM by schjlatah

    Passing argument by reference

      Is it possible to pass an argument to function by reference ?
      If yes, how to do it ?
        • 1. Re: Passing argument by reference
          JeffreyGong Level 1
          In ActionScript 3.0, all arguments are passed by reference because all values are stored as objects. However, objects that belong to the primitive data types, which includes Boolean, Number, int, uint, and String, have special operators that make them behave as if they were passed by value.

          All other objects--that is, objects that do not belong to the primitive data types--are always passed by reference, which gives you ability to change the value of the original variable. Therefore, if your argument is not a primitive type, it is passed reference; if your argument is a privitive type such as theFunc(x:String="a sample string"), wrap x inside a object such as var obj:Object = new Object(); obj.x="a sample string"; redefine the function like theFunc(obj:Object) and call it like theFunc(obj).

          • 2. Re: Passing argument by reference
            This is the exact opposite of my problem.
            I need to pass a composite data type by value not reference.
            Is there a way to pass an Object by value?