scratch
in the web server's root directory. ScratchApplet.jar
and soundbank.gm
files to the directory you just created on the web server. scratch.html:
<html> <title>Mike's Scratch Project</title> <body> <applet id="ProjectApplet" style="display:block" code="ScratchApplet" codebase="./" archive="ScratchApplet.jar" height="387" width="482"> <param name="project" value="project-name.sb"> </applet> </body> </html>
scratch.html
code, find the value attribute and change project-name.sb
to the filename of the project you uploaded to the web server. scratch.html
to the scratch directory on your web server. The following screenshot shows my FTP server on the right and the contents of the scratch directory:We're now hosting our own Scratch projects.
With just a bit of knowledge about how the Web works, we were able to host our own Scratch projects. The files we downloaded from the Scratch web site enabled our projects to run as a Java applet, just like they do on the Scratch web site. We mixed in a bit of HTML in order to display the project in a browser.
If you compared the HTML code we created with the HTML snippet we embedded into the blog post earlier in the chapter, then you realized they were the same code with a few accommodations. The paths to the projects varied and our exercise created a full HTML page, whereas the snippet was only the project code.
Beyond the obvious limitations like needing a web server, self-hosting your Scratch projects means you don't have the same tools that the Scratch web site provides, such as built-in social network promotion.
Also, no project notes display by default. This means that if a visitor comes to our Scratch page, they may not know how to play our game unless we manually add the notes as part of the HTML page.