Hi,
you cannot reassign the objects like you do in your method body.
Reassign parameter values is a bad idea anyway i think, but assume you have:
var a = myObj1;
var b = myObj2;
Utilities.swap (a,b);
the swap function receives a copy of the reference to a and b.
You reassign the copy, and exit the method.
(not entirely sure about this explanation though :-p).
Compare it with:
var a= null;
fill(a);
trace(a);
where fill is function fill (o1:object) { o1 = new Array(); }
the trace will show null.
You need to wrap the objects in another object in order to accomplish what
you want.
For example:
util.swap ({a:myObj1, b:myObj2});
with
public static function swap(ab:Object) {
var tmp:Object=ab.a;
ab.a=ab.b;
ab.b=tmp;
}
greetz
Hans
On 7/24/06, Alberto Florentin <[EMAIL PROTECTED]> wrote:
<code>
class Utilities {
public static function swap(o1:Object, o2:Object) {
var tmp:Object=o1;
o1=o2;
o2=tmp;
}
// etc
}
</code>
Somewhere in my code:
<code>
function aFunction(A:aType, B:aType) {
// ...
if (/*some condition*/)
Utilities.swap(A, B);
// ...
}
</code>
But nothing happens. A and B are still the same objects.
Must be missing something...
Alberto
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com