Time for action - install files on a web server

  1. Download these two files from the Scratch web site and save them to your computer:
  2. http://scratch.mit.edu/static/misc/ScratchApplet.jar
  3. http://scratch.mit.edu/static/misc/soundbank.gm

    Tip

    If your web browser displays the contents of the soundbank.gm file in the browser, use the browser's File | Save Page As… feature to save it to a file on your computer.

  4. Create a directory on the web server. I'm going to create a directory named scratch in the web server's root directory.
  5. Upload the ScratchApplet.jar and soundbank.gm files to the directory you just created on the web server.
  6. Upload a Scratch project to the scratch directory you created on the web server.
  7. Now, we need to build an HTML page to display the project. Save the following code as 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>
    
  8. In the scratch.html code, find the value attribute and change project-name.sb to the filename of the project you uploaded to the web server.
  9. Upload 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:
    Time for action - install files on a web server
  10. Open a web browser and view the URL of the page you created. In my example, that page is http://badgerfiles.com/scratch/scratch.html.
Time for action - install files on a web server

We're now hosting our own Scratch projects.

What just happened?

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.

Limitations of self-hosting

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.

Pop quiz

  1. Why should you want to compress images and sounds before sharing a project?
    • To combine multiple files into one file
    • To decrease the quality of the images and sounds
    • To make the images and sounds smaller
    • You never want to compress images or sounds
  2. If you want to update a Scratch project that you previously shared, what do you do?
    • Click the Update! button in the Scratch interface
    • Delete the project from your account on the Scratch web site and share the revised project
    • You are not able to update the project
    • Share the project using the Share! button in the Scratch interface and use the same name as the original project
  3. What are the ways in which you can share your projects with the world?
    • Post your project to social networks, such as Facebook, MySpace, and Twitter using the AddThis.com bookmarks on the Scratch web site
    • Embed the project link in a web site
    • Self-host your Scratch projects on your own web server
    • All of the above
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.224.44.100