From Test-Scratch-Wiki

SandCastleIcon.png This page has links to outside of the Scratch website or Wikipedia. Remember to stay safe when using the internet as we can't guarantee the safety of other sites.


The Scratch project format (.sb or .sb2) can only be read by the Scratch editor. Compiling a scratch project can convert it to another format that can be opened without scratch. Compiling was a popular suggestion for Scratch 2.0,[1] However, it wasn't added in the normal online or offline editors. To get around this, several Scratchers have made ways to turn them into more widely known formats such as exe and app.

This tutorial will cover how to turn a Scratch project into various executable file formats for Windows, Macintosh and Linux.

SB2 (Scratch 2.0) to SB (Scratch 1.4)

It is possible for one to convert an SB2 file from Scratch 2 to a Scratch 1.4 SB file using blob8108's Retro Converter. Then, if desired, other tools can be used to port it to various formats.


Note Note: The converter can only convert 1.4 blocks. It cannot convert 2.0 This means you cannot use clones, cloud, custom blocks, or other new Scratch 2.0 features.


SB2 to SB

  1. Download your 2.0 project from the Scratch Website or the 2.0 Offline Editor.
  2. Go to the Retro Converter and follow the instructions there to convert to SB.
  3. Once converted, a pop-up should appear and you will be able to download a 1.4 version (SB) of your 2.0 (SB2) Scratch project.

SB to Other Formats

  1. Now, follow the other Scratch 1.4 tutorials on this page to convert to various other formats.

SB to EXE/APP

Note Note: This converts to an EXE on Windows, and an APP on Mac OS X.
  1. Install BYOB (see resources and links for a link to the website).
  2. Open your SB file.
  3. Click "Compile this project" under the Share menu.

Compile.png

SB to JAR (Java executable)

Works on all operating systems with a Java runtime installed. (Mac, Windows, and Linux)

  1. Download ToJAR (see [[Eng:#Resources and Links|resources and links]])[2]
  2. Unpack/extract the .zip file by right clicking and choosing extract all... on Windows and by double clicking on Mac
  3. In the ToJAR folder, double click on the program folder, then on the dist folder and then double click on the ToJAR.jar file.
  4. This will launch the ToJAR application which looks like this

Tojar.png

  1. Click the first select button and choose your input (SB) file.
  2. Choose your output name, and be sure to append the .jar file extension, for example Example.jar
  3. Choose your output location, being sure to put the name of your JAR file at the end. For example, C:/Documents and Settings/Documents/Example.jar
  4. Click compile

SB to APP via Java

Note Note: This only works on Mac OS X.
  1. Follow the steps above to make a JAR file.
  2. Find the Jarbundler application.
  3. Launch it, it should look something like this

Jarb.png

  1. From the tabs at the top, the first tab says build information. You can set a custom icon. The icon must be in .icns format. Use Icon Composer (comes with Mac) to convert a PNG file into .icns format. An icon is optional.
  2. Then choose your JAR file you created as the Main Class.
  3. Click the button at the bottom that says Create Application...
  4. Choose output folder

SB to APP via online player

Using the native Xcode development suite, a Scratch Project can be converted into an application by referencing the online player. To do this, one must open the project and get the Embed URL. Then the embed URL must be used to create an HTML page using the UIWebView Cocoa class.

Creating a project

First, create an Xcode project, and name it iScratchProj. Replace the contents of iScratchProjAppDelegate.h with:

// Import Cocoa framework
#import <Cocoa/Cocoa.h>
// Import WebKit framework
#import <WebKit/WebKit.h>

@interface iBlobAppDelegate : NSObject <NSApplicationDelegate> {
    // Create the window
    NSWindow *window;
    
    // Get the applet
    IBOutlet id webView;
}
// Get the window
@property (assign) IBOutlet NSWindow *window;

@end

Next, replace to contents of iScratchProjAppDelegate.m with:

#import "iBlobAppDelegate.h"

@implementation iBlobAppDelegate

@synthesize window;

// When the application loaded...
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
    // Add the applet to the screen
    [webView stringByEvaluatingJavaScriptFromString:@"document.write(\"<applet id='ProjectApplet' style='style='position:absolute;left:0;top:-25;' code='ScratchApplet' codebase='http://scratch.mit.edu/static/misc' archive='ScratchApplet.jar' height='387' width='482'><param name='project' value='../../static/projects/<#Username#>/<#id#>.sb'></applet>\")"];
}

@end

Click on the yellow bubbles, and fill in your username and the ID of your project (the number at the end of its URL, e.g. http://scratch.mit.edu/projects/Hardmath123/2433673).

SB2 to SWF

You can download a SB2 to SWF converter or use an online converter on this site. This is very easy to use and you can change the following settings:

  • Does the bar with the green flag show?
  • Does the project automatically run when it loads?
  • Is turbo mode enabled by default?
  • Will the SWF go fullscreen if you open it with the standalone player?
  • Default width and height of the SWF

Examples

This is what a chatbot looks like, running as a bundled JAR. Juliajar.png

An application icon can be added as well. File:Dockicon.png

Resources and Links

References

Cookies help us deliver our services. By using our services, you agree to our use of cookies.