processing.js loading external files

十年热恋 提交于 2019-12-01 08:05:56

问题


I want to split my processing.js code into several files but I'm not sure how. I tried doing

<script type="application/processing" src="main.pjs">

to load my processing.js file "main.pjs" but it didn't work.


回答1:


Try http://www.hyper-metrix.com/misc/Processing.AJAX.init.zip




回答2:


I know this has already been answered, but I thought I'd add some more explanation:

The problem with your initial approach is that the browser does not know what to do with a file of type "application/processing", so it is never even pulled from the server. The init() package that TML posted looks for these and pulls them by means of XHR.




回答3:


You can initialize Processing with a canvas and a string of source in JS.

Processing(canvas, sourceString)

That string could come from anywhere outside the current file.




回答4:


Processing.js can run code from an external file like so...

<script src="processing.js"></script>
<canvas datasrc="yourSketch.pjs" width="200" height="200"></canvas>


来源:https://stackoverflow.com/questions/881146/processing-js-loading-external-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!