-1

我试图了解如何将 setInterval 与 Paper.js 一起使用。我做了一个简单的测试,在 setInterval 函数内部和外部使用相同的代码。它适用于后一种情况,但不适用于 setInterval 内。任何想法?

// interval (not working)//

var id = setInterval(function() {   
    var path = new Path.Circle(new Point(20, 20), 30);
    path.fillColor = 'red';
    var pointX = 80;
    var pointY = 50;
    var symbol = new Symbol(path);
    symbol.place(new Point(pointX, pointY));
    pointX = pointX+50;
    pointY = pointY+50;
    }
}, 1000);


//no interval//

var path = new Path.Circle(new Point(20, 20), 30);
    path.fillColor = 'red';
    var pointX = 80;
    var pointY = 50;
    var symbol = new Symbol(path);
    symbol.place(new Point(pointX, pointY));
    pointX = pointX+50;
    pointY = pointY+50;
    symbol.place(new Point(pointX, pointY));

http://jsfiddle.net/miguelrivero/2BzUL/10/

谢谢!

4

1 回答 1

1

第一个原因是}你有额外的语法错误。第二个原因是存在错误:

Refused to execute script from 'https://raw.github.com/paperjs/paper.js/master/dist/paper.js' because its MIME type ('text/plain') is not executable, and strict MIME type checking is enabled. fiddle.jshell.net/miguelrivero/2BzUL/10/show/:1
Uncaught SyntaxError: Unexpected token } fiddle.jshell.net/miguelrivero/2BzUL/10/show/:40
Refused to execute script from 'https://raw.github.com/paperjs/paper.js/master/dist/paper.js' because its MIME type ('text/plain') is not executable, and strict MIME type checking is enabled. fiddle.jshell.net/_display/:1
Uncaught SyntaxError: Unexpected token } fiddle.jshell.net/_display/:40
Refused to execute script from 'https://raw.github.com/paperjs/paper.js/master/dist/paper.js' because its MIME type ('text/plain') is not executable, and strict MIME type checking is enabled. fiddle.jshell.net/_display/:1
Uncaught ReferenceError: Path is not defined fiddle.jshell.net/_display/:29
Uncaught ReferenceError: Path is not defined 
于 2013-08-28T13:15:18.173 回答