我创建了一个动态的画布使用以下功能:与变量处理中单击事件
var animating=false;
function create_canvas(Container,Id,Width,Height)
{
...//set width,height
//added a click event listener
document.getElementById(Id).addEventListener("click", function()
{
if(animating==true)
{
alert("Running the animation"); //can't reach this part
return;
}
else
{
animating=true;
run_canvas();
animating=false;
}
});
...//append to Container
}
function run_canvas()
{
...//some code here
}
现在,每当我点击画布上的动画开始,不管是什么。我的意思是,全局变量动画没有得到它的价值改变。因此我的问题是:我做错了什么,我该如何处理这种情况。
你可以发布你的动画代码吗? – 2013-04-25 11:19:47
在我的动画代码中,我不改变变量动画,它是一个很长的代码:)实现k-means聚类。 – ssBarBee 2013-04-25 11:20:55