Actionscript 2.0 Functions problem and somewhat "global" variable
- by Joshua
I have two problems.
The first problem is with the following functions; when I call the function in (enterFrame), it doesn't work:
onClipEvent (load) {
function failwhale(levelNum) {
_root.gotoAndStop("fail");
failFrom = levelNum;
}
function guardSightCollision(guardName, guardSightName) {
if (_root.guardName.guardSightName.hitTest(_x, _y+radius, true)) {
failwhale(1);
}
if (_root.guardName.guardSightName.hitTest(_x, _y-radius, true)) {
failwhale(1);
}
if (_root.guardName.guardSightName.hitTest(_x-radius, _y, true)) {
failwhale(1);
}
if (_root.guardName.guardSightName.hitTest(_x+radius, _y, true)) {
failwhale(1);
}
}
}
onClipEvent (enterFrame) {
guardSightCollision(guard1, guard1Sight);
}
Why doesn't it work?...
The second problem lies in the failFrom variable:
function failwhale(levelNum) {
_root.gotoAndStop("fail");
failFrom = levelNum;
}
How do I make failFrom a "global" variable in that it can be accessed anywhere (from actionscript in frames and even movieclips)...Right now, when I try to trace failFrom in a different frame, it is "undefined".