Functions: Passing arguments by value or by reference
by Ruben
By chance I just stumbled upon this article from the Livedocs about the way functions interpret the values of their parameters in Actionscript3.
Since I found I couldn't put it any better than the LiveDocs did, here's a quote:
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.
Passing arguments by value or by reference (Adobe Flex LiveDocs)
Read the whole section on passing arguments for a better and more thorough description on the whole concept.
Comments (read older)
Alright, actually that was more or less what I meant, I merely put it the wrong way.. Thanks alot for going through the trouble of explaining all of it man..
Thank your for this explanation.
Is there a solution to pass Object by value ?
I think about String type.
hey, well there are some workarounds; first, if you know what properties your object has then you can just make a copy of it (loop through those properties their values, etc). Other than that you can try the ByteArray-copy method: http://lmgtfy.com/?q=copy+object+bytearray+actionscript ..hope that helps
It seems everything is passed by value, even though live docs says otherwise.
http://www.mischel.com/diary/2006/07/24.htm