read more on the Scratch Wiki...
When a Scratch project is running online, it is actually running in an application called the Java Player which interprets the Scratch project and makes it run. The Java Player is a totally different application from the Scratch program (where you make the projects). So, while it does a pretty good job of running Scratch projects, it has it's own set of "quirks". Sometimes you have to make some small changes to your projects to make them run on the web.
I'm going to start a thread here to show some of the most common problems you may run into when you try and run your project on the web. Feel free to add on your own experiences!
Timing and Initialization
======================
Often, the reason that projects act differently on the web has to do with the timing of things. You may have several scripts all starting on a given Broadcast event (for instance) that really need to act in a certain order. They work fine in Scratch but, because some events happen a little faster or slower online, they don't work right online. You can usually cure these kind of problems by adding short Wait blocks ahead of the events that should happen later.
Also, make sure that when the Green Flag is clicked, the project is initializing properly. That means that all the variables are set to the right starting values, all the sprites are put in the right starting place and so on. Any Forever loops that are checking for a certain variable value should have a short Wait ahead of them to make sure that the variable has time to get set to the right starting value before the Forever loop starts checking it.
Large Sprites
============
Sprites can get much larger than the Stage in the Scratch Program. But, in the Java Player, sprites can not be larger than the screen. The only work-around I know of here is to break your very large sprites into smaller values.
Color Effect
===========
The Set Color effect works differently online...the color numbers are different. You shouldn't use Set Color with the expectation that it is going to end up with the same colors you get in the Scratch Program. *** Update - this problem was reportedly fixed in version 34 of the player ***
Lists
====
if you try accessing a list item that doesn't exist, the project fails online, but doesn't offline - which can be a pretty common problem in a number of projects. Thanks to AddZero and Coolstuff for that tip!
Division by Zero
===============
Also, although this isn't directly related because it's sort of inverse to this topic, errors you get when trying to do things that are impossible such as dividing by zero doesn't stop the script online. Again, thanks to AddZero and Coolstuff.
Last edited by JSO (2011-01-03 18:05:42)
Offline
wow. how did you figure all that out?
Offline
tmaaan wrote:
wow. how did you figure all that out?
Some I learned from other people, some by trial and error
I really like my projects to work online just as well as they do when they are downloaded so I've spent a lot of time learning what I can to make my projects work in both places. If anybody else has any helpful hints, feel free to post them here.
Offline
Paddle2See wrote:
When a Scratch project is running online, it is actually running in an application called the Java Player which interprets the Scratch project and makes it run. The Java Player is a totally different application from the Scratch program (where you make the projects). So, while it does a pretty good job of running Scratch projects, it has it's own set of "quirks". Sometimes you have to make some small changes to your projects to make them run on the web.
I'm going to start a thread here to show some of the most common problems you may run into when you try and run your project on the web. Feel free to add on your own experiences!
Timing and Initialization
======================
Often, the reason that projects act differently on the web has to do with the timing of things. You may have several scripts all starting on a given Broadcast event (for instance) that really need to act in a certain order. They work fine in Scratch but, because some events happen a little faster or slower online, they don't work right online. You can usually cure these kind of problems by adding short Wait blocks ahead of the events that should happen later.
Also, make sure that when the Green Flag is clicked, the project is initializing properly. That means that all the variables are set to the right starting values, all the sprites are put in the right starting place and so on. Any Forever loops that are checking for a certain variable value should have a short Wait ahead of them to make sure that the variable has time to get set to the right starting value before the Forever loop starts checking it.
Large Sprites
============
Sprites can get much larger than the Stage in the Scratch Program. But, in the Java Player, sprites can not be larger than the screen. The only work-around I know of here is to break your very large sprites into smaller values.
Color Effect
===========
The Set Color effect works differently online...the color numbers are different. You shouldn't use Set Color with the expectation that it is going to end up with the same colors you get in the Scratch Program.
Thats pretty helpful if you need some help like that. I like it!
Offline
Here are two things I have discovered about what happens to projects when uploaded: the online java player does not change a variable by a certain number if the variable already equals a non-number. Also it utterly doesn't recognize the arcsign and puts it's version of the error symbol in your variable if you try to use it. Hope that helps.
Offline
kgordon wrote:
Here are two things I have discovered about what happens to projects when uploaded: the online java player does not change a variable by a certain number if the variable already equals a non-number. Also it utterly doesn't recognize the arcsign and puts it's version of the error symbol in your variable if you try to use it. Hope that helps.
Yes, it does! I knew about the problem with variables but I hadn't heard about the problem with Arcsine. Thanks!
Offline
Here's a confusing one:
If you are using the "Touching [color]" blocks, be very careful NOT to compress your images. Compressing images sometimes slightly changes the colors used. Your project will look like it should work, but it won't.
To see an example of this error, load the demo project Games > 1. Pacman
Once you finish the first screen (which works fine) it will switch to the second screen which has been compressed. It doesn't work as designed.
This is somewhat tricky to avoid because when you are sharing a project the "Compress images and sounds" is checked by default. You must remember to uncheck that box for your project to work.
Last edited by BoltBait (2009-04-07 15:34:59)
Offline
I think I heard the set volume to and the hide/show variable doesn't work online.
Offline
Here is an example that I made up:
http://scratch.mit.edu/projects/BoltBait/480964
The online player has trouble with the [Insert into list at position] function.
So, you can use this bug to detect if you are running online (on the web site player) or offline (in the development environment).
Last edited by BoltBait (2009-04-09 15:19:09)
Offline
Yeah the volume doesn't work but I didn't know about the hide variable/show variable (thanks to bosox397 for correcting me). Also timing can be a bit off sometimes and sometimes big projects slow down online. If I think of anything else I will add it.
Last edited by kgordon (2009-04-11 07:54:39)
Offline
No not those hide show blocks. The hide variable/show variable blocks. also loudness doesn't work onliine
Offline
bosox397 wrote:
I think I heard the set volume to and the hide/show variable doesn't work online.
I hate when that happens, I say please download to get better quality in project notes and they ignore that. Then they say something like this: "the sound is all jumbled up" or "what are you saying"
Offline
bosox397 wrote:
No not those hide show blocks. The hide variable/show variable blocks. also loudness doesn't work onliine
true.
Offline
it really annoys me because then u have to make sprites to cover the variables and they have to be exactly lined up, espicially with words
Offline
bosox397 wrote:
it really annoys me because then u have to make sprites to cover the variables and they have to be exactly lined up, espicially with words
yeah... your right...
Offline
I found a couple more.
Besides Color, some of the other graphic effects (e.g. Pixelate and Mosaic) don't look quite the same.
Rotated sprites may be positioned differently by one pixel. Normally you wouldn't notice, but in a Tetris type game for instance, it could be important.
Offline
True.
Offline
If only we were in a world in which scratch projects react the same way online and offline!
Offline
I think the hide variable/show variable blocks work online now, one of my projects with those blocks actually does it now, it wasn't really a problem anyway as it was just a graphic (flashing variable) and it only appeared at the end of the game, which only I ever got to as it was a platformer called cliff climber and they can be fairly hard to beat. The graphic was the score flashing before turning into your rating at the end.
Offline
when i get on some computers and i go to a project it shows a grey screen where the project should be.
Offline
Here's one that came up again recently...if you use the Pick Random block to choose a sound for the Play Sound block...it will stop the Java Player dead in it's tracks!
*** Update - This is reportedly fixed in version 34 ***
Last edited by Paddle2See (2009-07-29 05:39:00)
Offline
Paddle2See wrote:
Here's one that came up again recently...if you use the Pick Random block to choose a sound for the Play Sound block...it will stop the Java Player dead in it's tracks!
Wow, I think my projects had that error.
Offline
keroro645 wrote:
Paddle2See wrote:
Here's one that came up again recently...if you use the Pick Random block to choose a sound for the Play Sound block...it will stop the Java Player dead in it's tracks!
Wow, I think my projects had that error.
In a game I was doing earlier, I did that but later got rid of it. Good for me...
_____________________________________________
Even if the internet dies, Scratch shall live on.
Offline
Paddle2See wrote:
Timing and Initialization
======================
Often, the reason that projects act differently on the web has to do with the timing of things. You may have several scripts all starting on a given Broadcast event (for instance) that really need to act in a certain order. They work fine in Scratch but, because some events happen a little faster or slower online, they don't work right online. You can usually cure these kind of problems by adding short Wait blocks ahead of the events that should happen later.
Thanks for the information Paddle2See! I tried to upload a new project (finally, it's been a while), except that it never gets past a certain point! In the main screen, there's the Star Wars Logo going away, but after that it gets stuck. I'll try and twerk the different 'wait [ ] seconds' blocks in the project, and see how it goes.
Last edited by Jonathanpb (2009-06-23 01:51:27)
Offline