我是 Flash ActionScript 3.0 的新手。我需要 setInterval 上的回调函数,我确实喜欢
有一个篮子叫ownmouse。并附有鼠标。
ownmouse.addEventListener(Event.ENTER_FRAME,fun);
function fun(Eve:Event) {
ownmouse.startDrag(true);
Mouse.hide();
}
球从带有 setInterval 的 Flash 文档顶部落下。
var myInterval = setInterval(fallBall,1);
ownmouse.addEventListener(Event.ENTER_FRAME,controlCursor);
function controlCursor(MouseMove:Event) {
var xaxis:int = mouseX;
var yaxis:int = mouseY;
var ballXaxis = ball.x;
var ballYaxis = ball.y;
if((ballXaxis+10)>=xaxis && (ballXaxis-10)<=xaxis && (ballYaxis)>=yaxis && (ballYaxis-10)<=yaxis) {
clearInterval(myInterval, function() {
myBall.gotoAndPlay(10)
});
}
if(yaxis>620) {
ownmouse.stopDrag();
ownmouse.y = 620;
Mouse.show();
} else if(yaxis<420) {
ownmouse.stopDrag();
ownmouse.y = 430;
Mouse.show();
}
}
除以下代码外,一切正常:
clearInterval(myInterval, function() {
myBall.gotoAndPlay(10)
});
AS3 中是否可以使用回调函数?如果没有,如何解决这样的问题?
我将非常感谢您的帮助:)