-
Unwanted References
When I have this code...
Code:
var point1:Point = new Point();
var point2:Point = new Point();
I have two separate Point instances, but if I then do this...
point1 becomes a reference to point2. Is there any way to avoid this, such that a copy of point2 is made, or just so that only the values are copied, but they remain two separate instances.
-
I'm not sure what kind of asset point is... but I would assume you would have to copy of the properties one at a time.
Code:
point2.x = point1.x
-
I believe in a language like C++ you would need to overload the = operator, but since you cannot do that the best thing you can do is create a method like:
point1.equals (point2);
Which will copy all the properties one by one.
The greatest pleasure in life is doing what people say you cannot do.
- Walter Bagehot
The height of cleverness is to be able to conceal it.
- Francois de La Rochefoucauld
-
I wanted to avoid copying each parameter by hand, but that does seem to make the most sense
thank you both
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|