the whole thing with setInterval is scope.
the way your code looks, p2 is in the main timeline and it belongs to this/_level0/_root right ?
clearInterval() is a global function as well, so you can call it from any other function nested in any movie clip, as long as you can get access to the interval's id (p2 in your case)
so if you have some like:
p2 = setInterval(function () { trace('p2 running'); }, waitTime);
you can have a separate function like
function clearP2(){
clearInterval(p2);
}
if that function is nested in some clip you can always use the dirty all _root ( as in absolute path )
e.g.
//clearP2 lives in a nested clip far far away from _root
function clearP2(){
clearInterval(_root.p2);
}
of course you can use relative paths as well
function clearP2(){
clearInterval(_parent._parent._parent.p2);//depending on the clips hierarchy
}
the idea to keep in mind is to make sure you can access the interval's ID where you need it, clearInterval() is global
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…