You're right, "pnt = new (...)" cancels it out. However, if, *somewhere*
before the loop, you assign a point from pathB to pnt...
pnt = pathB[n][n];
...then the values of that same specific point instance will be changed
(pnt is already assigned to a point), and as such, when you assign a new
point to pnt, but using values from a point of pathB, the values would
have changed.
Remember that in actionscript, your objects are references:
var p1:Point = new Point(10, 20);
var p2:Point = p1; // not a copy, but a reference
p2.x = 0;
trave (p1.x); // traces 0, not 10
That's the only thing I can imagine. I guess it will depends on what's
on the [snip] part of your code. Is anything (that's also part of the
pathB array) assigned to pnt?
Zeh
Bill Kotsias wrote:
Hello. I am a newbie to this list, so I am sorry if this message is
off-topic. If it is, I would be obliged if anyone could direct me to the
correct place.
I am a veteran programmer but I am new to actionscript. I have come across
some strange behaviour which is driving me mad. Following is a part of my
code :
...[snip]...
private var pnt:Point = new Point();
private var dirp:int;
private var fastp:int;
private var i:int;
private var pathB:Array;
...[snip]...
for (dirp=fastp; dirp<=i; dirp++) {
// BUG!!! If I UNCOMMENT 1 of the 2 following lines, code gets mixed up.
// pnt.x=pathB[dirp][0].x+pathB[dirp][2].x;
// pnt.y=pathB[dirp][0].y+pathB[dirp][2].y;
pnt=new
Point(pathB[dirp][0].x+pathB[dirp][2].x,pathB[dirp][0].y+pathB[dirp][2].y);
if (addElement(pnt, dirp, pathB[dirp][2], pathB[dirp][3]+1))
return pathF;
}
As I mention above, if I uncomment //pnt.x=... or //pnt.y=... or if I even
replace them with something like pnt.x=pnt.x+1;
then my code gets mixed up and returns wrong results.
This is driving me nuts because these two lines shouldn't have any effect
since right below them there is
pnt=new Point(...);
which supposedly "cancels" the 2 previous instructions. Right?
Could anyone, please, show me the obvious that I can't see?
Many thanks in advance,
Bill Kotsias
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders