Skip to content
This repository has been archived by the owner on Sep 3, 2019. It is now read-only.

AIR dependency's offline editor is a pity #760

Closed
q2dg opened this issue May 12, 2015 · 21 comments
Closed

AIR dependency's offline editor is a pity #760

q2dg opened this issue May 12, 2015 · 21 comments
Milestone

Comments

@q2dg
Copy link

q2dg commented May 12, 2015

It's not open-source and it doesn't work in Linux 64 bits.
Why not refactoring offline editor to be written in Javascript, like Snap is???

@qubodup
Copy link

qubodup commented May 19, 2015

Why not refactoring

It's probably way too much work and the demand is probably not high enough.

Windows and mac users that work in unstable internet environments would probably benefit from official runtimes, which are possible according to http://stackoverflow.com/questions/9674694/

like for example a kids' programming workshop I coached at last week, where we didn't have stable internet and used 1.4 instead. Although our computers mostly were running Linux, so 1.4 is the only offline option anyway.

Linux unfortunately appears to be out of the picture of Air http://www.adobe.com/products/air/faq.html#linux and the last available Linux version 2.6 but the runtime feature exists since 3.0 according to the stackoverflow answer.

Using 1.4 is probably the only solution to the problem of wanting to run Scratch without prprietary software on 64 bit Linux. https://scratch.mit.edu/scratch_1.4/

@q2dg
Copy link
Author

q2dg commented May 19, 2015

Well, it's a shame.

You can notice Snap (https://github.com/jmoenig/Snap--Build-Your-Own-Blocks), for instance. It doesn't seem so dificult.

@TheLogFather
Copy link

I do sometimes use Scratch offline, but I've not bothered to download the offline version.

It seems fine just opening up a compiled/downloaded Scratch.swf using Flash Player, or even in the browser directly - no need for Air.

Here's an archive of swf files for Scratch versions going right back: https://37d5d120c282af065cc07aa80787bbf94abf48ab.googledrive.com/host/0Bwg2KFU5SrIodjNSSjByeEh5dkk/2.0%20Online/

I'm on Mac, so I guess YMMV - but it works for me on both Safari and Firefox, so it's worth checking to see if you can open an swf directly from within various browsers on Linux.

@q2dg
Copy link
Author

q2dg commented May 20, 2015

I'm talking about the Scratch editor

But it's true it would be nice we could generate final files in another format different from .swf (because Flash is also propietary, and will be obsolete soon). But that's another question

@TheLogFather
Copy link

Yes, so am I... ??

@qubodup
Copy link

qubodup commented May 20, 2015

Here's an archive of swf files for Scratch versions going right back: https://37d5d120c282af065cc07aa80787bbf94abf48ab.googledrive.com/host/0Bwg2KFU5SrIodjNSSjByeEh5dkk/2.0%20Online/

Wonderful! Hopefully, all the Linux machines I encounter in the future have flash or chromium with pepper (the ones at the last event didn't have flash in Firefox and I didn't see any chromium icon in the app bar).

Current instructions

  1. Right-click https://37d5d120c282af065cc07aa80787bbf94abf48ab.googledrive.com/host/0Bwg2KFU5SrIodjNSSjByeEh5dkk/2.0%20Online/Scratch%20v435.1.swf and "save link as..."
  2. Open that file using a web browser that has flash support (chromium) directly or by dragging and dropping it into the browser window, while offline.
  3. You can now use scratch.

UPDATE: I spoke too soon. You don't have access to the sprite/sound libraries, you can save your project but you can't load a project. If you do, it will not import the content (only the file name) and the green flag above the game window will stop working. Also, that downloadable is English only.

@CreativeComputerLab
Copy link

I've run the local 435.1 swf in the browser as suggested above. It won't load any local .sb2 files. It just hangs when I try. Can anyone else load local .sb2 files while this "offline" mode?

@qubodup
Copy link

qubodup commented May 21, 2015

@CreativeComputerLab for me it doesn't freeze but it just imports the name and leaves everything as is. The green flag doesn't work any more afterwards though. Quite strange. There is also no access to the sprite/sound libraries. But it seems like saving files at least works.

@q2dg
Copy link
Author

q2dg commented May 21, 2015

Well...jmoenig/Snap#575

@TheLogFather
Copy link

Ah, yes - forgot the part where you can't open anything...

You also have to tell your Flash Player that you trust files from the directory containing them.
EDIT: IIRC, you have to include both the directory that contains the sb2 file, and the one containing the Scratch swf you want to run.

On the Mac you go to the Flash Player settings in System Preferences, and set the "Trusted Location Settings..." in the Advanced tab.

Presumably there will be something similar available in the Linux flash prefs (or in Chrome's pepper flash settings)...

@CreativeComputerLab
Copy link

Yes, I get the same exact behavior.Perhaps its a cross domain policy issue as we're uploading from local instead of via http?

-------- Original Message --------
Subject: Re: [scratch-flash] AIR dependency's offline editor is a pity
(#760)
From: Iwan Gabovitch notifications@github.com
Date: Thu, May 21, 2015 2:46 pm
To: LLK/scratch-flash scratch-flash@noreply.github.com
Cc: Steve Holmes steve@creativecomputerlab.com

@CreativeComputerLab for me it doesn't freeze but it just imports the name and leaves everything as is. The green flag doesn't work any more afterwards though. Quite strange. There is also no access to the sprite/sound libraries. But it seems like saving files at least works. —Reply to this email directly or view it on GitHub.

@TheLogFather
Copy link

Does the info above, about setting "Trusted Locations", allow you to open files with it now...?

@CreativeComputerLab
Copy link

Yes, it works for me. Now I'm on to a new issue where projects containing extensions won't load load them even when the extension.js code is placed in the trusted dir and the .sb2 file has been modified to point to that path.

@q2dg
Copy link
Author

q2dg commented May 22, 2015

This topic is very interesting, but it is not about what I wrote in first post... I wanted to know if there is some plans to rewrite Scratch editor to be dependent-less of Adobe's AIR.

@TheLogFather
Copy link

@q2dg:
I guess I'm kinda saying that I don't quite understand the dependency on Air. It doesn't really need it for the basic editor, as demonstrated by the fact that you can (mostly) use it via the raw swf alone. What part, then, does Air play in the offline editor download? Maybe that part can be reproduced without Air...?

@CreativeComputerLab:
I've not done any messing around with extensions so far, so I don't know about that.
Maybe it's worth looking at the directory structure that Air builds for offline Scratch on Mac/Win if you can, and trying to reproduce it in some way? (That may at least sort out the sprite/sound libraries if the relevant files are in the right places?) Having never used it via Air, I wouldn't know offhand.
Looking at the repo, the only paths that are obvious to me are in ScratchExtension.as, and only appear to be relevant for PicoBoard and WeDo...

@q2dg
Copy link
Author

q2dg commented May 22, 2015

@TheLogFather Good question. I only know what it's said here: https://scratch.mit.edu/scratch2download

@q2dg
Copy link
Author

q2dg commented Jun 7, 2015

I just wanna this: https://github.com/nathan/pixie

@CreativeComputerLab
Copy link

!! Will give this a try !! I'll be looking to add my own websocket based data streaming blocks.
Thanks @q2dg

@fizban99
Copy link

What I have found is that using a project converted using junebeetle23 converter seems to work better than opening the default Scratch file directly. What I did was
1.- Go to the official Scratch page.
2.- Click on Create. You will get to the editor (you can also go directly to https://scratch.mit.edu/projects/editor/?tip_bar=home)
3.- Select File-Download to your computer. I just called it Default.sb2
4.- Go to https://sites.google.com/site/junebeetle23/ and use the converter online or the offline one. Make sure you select "Show Scripts"
5.- Download the converted swf file.
6.- Run the swf file from a browser or a player. I was able to load and save any local files

I also found a way to access the libraries, or sort of:
Create two subfolders hanging from the folder where the resulting swf is placed:
.\NaNasset
.\NaNmedialibraries

in the NaNmedialibraries place the following files from the Scratch standalone installation (Scratch 2\media\libs), although I believe only the json files are really required:
.git
backdropLibrary.json
costumeLibrary.json
generate-costume-library.py
README.md
soundLibrary.json
spriteLibrary.json

in the NaNasset place the files from Scratch 2\media

Now, go to each of the json files within the NaNmedialibraries and add the code \u0000 at the end of all the asset names (several search and replace actions might be needed from a text editor to cover the different extensions) . So the first lines of the file costumeLibrary.json would look like:
[
{
"info": [
70,
278,
2
],
"md5": "c013c7ae0cdb245e7cbcd1f0ef803d5c.png\u0000",
"type": "costume",

Now, if you run the swf and click on the libraries, you can see the names, play the sounds and insert the objects, but you will not see the preview of the images in the list, so you will have to select them based on the name, without seeing what you are selecting. Besides, I was not able to select sprites. Only customes, sounds and backdrops...

@thisandagain
Copy link
Contributor

Hi folks, we will take this into account with the next version of Scratch. Thank you for your suggestion.

@LePew
Copy link

LePew commented Dec 15, 2016

A bit late, but here's an addon to fizban99's post for linux:

  1. Download Scratch 2 offilne editor https://scratch.mit.edu/scratchr2/static/sa/Scratch-451.air to your home directory
  2. Create a Scratch directory
  3. cd Scratch
  4. unzip [path_to]/Scratch-451.air
  5. Use junebeetle online converter (as explained) ans save a Scratch.swf over the one coming with Scratch-451.air
  6. Create NaNmedialibraries: mkdir NaNmedialibraries
  7. create NaNasset dir: ln -s NaNmedialibraries NaNasset
  8. Now we need to add \u0000 to .json files, as described by fizban99. Here's a litlle script you can use (copy the following line into media/u0000.sh, you may need to change the paths according to your installation)
#! /bin/sh
for i in *.json do
sed -e 's/.svg/.svg\\u0000/' -e 's/.jpg/.jpg\\u0000/' -e 's/.gif/.gif\\u0000/' -e 's/.png/.png\\u0000/' -e 's/.wav/.wav\\u0000/' < $i > ../NaNasset/$i
done
cs libs
for i *.json do
sed -e 's/.svg/.svg\\u0000/' -e 's/.jpg/.jpg\\u0000/' -e 's/.gif/.gif\\u0000/' -e 's/.png/.png\\u0000/' -e 's/.wav/.wav\\u0000/' < $i > ../../NaNasset/$i
done
  1. you can create a small scratch.html to load the editor (put it in the root of your Scratch directory - beware, this is not a valid HTML code but you can use it as a base):
<object type="application/x-shockwave-flash" data="Scratch.swf" width="100%" height="100%" id="scratch" style="visibility: visible;">
<param name="allowscriptaccess" value="always">
<param name="allowfullscreen" value="true">
<param name="wmode" value="direct">
<param name="menu" value="false">
</object>
  1. Open this scratch.html page in your browser and you should be OK to go (you can even change the locale by clicking on the "globe" icon within scratch editor).

Bugs still remaining:

  1. As fizban99 said, sprites can't be loaded (I can't find where's the problem). On top of this, costumes and backgrounds can be loaded from the library, but you won't see the little icons... I really don't understand what's wrong (a missing path somewhere?)
  2. To avoid a crash on "download project to my computer" after hours of hard coding, you have to save a project as soon as the editor is loaded (ie: myproject001). You can then import an old project but every save you'll do later will be made to myproject001.sb2... If you wish to work on a new project, you have to restart the editor (reload the page). This bug (and workaround) isn't specific to this hacked offline version: it exists with the online flash version for linux...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants