See post #471 for sound.
Offline
MathWizz wrote:
TheSuccessor wrote:
See post #471 for sound.
Mobile devices can't run applets.
![]()
Wow, we were both thinking the same thing!
Offline
MathWizz wrote:
Ok! Anyone else wanna work on it a bit? Should we use my site for the viewer or figure out how to put it in weebly? I can read the project info perfectly but not the stage or sprites yet...
I'll work on it!
Offline
pwiter wrote:
MathWizz wrote:
Ok! Anyone else wanna work on it a bit? Should we use my site for the viewer or figure out how to put it in weebly? I can read the project info perfectly but not the stage or sprites yet...
I'll work on it!
No chance of getting weebly to do this!!!! Please listen to me!
You the host your using!!!
Offline
Daffy22 wrote:
pwiter wrote:
MathWizz wrote:
Ok! Anyone else wanna work on it a bit? Should we use my site for the viewer or figure out how to put it in weebly? I can read the project info perfectly but not the stage or sprites yet...
I'll work on it!
No chance of getting weebly to do this!!!! Please listen to me!
![]()
You the host your using!!!![]()
No I know that! But Mathwizz's site isn't on weebly!
p.s your site is down again!
Offline
pwiter wrote:
Daffy22 wrote:
pwiter wrote:
I'll work on it!No chance of getting weebly to do this!!!! Please listen to me!
![]()
You the host your using!!!![]()
No I know that! But Mathwizz's site isn't on weebly!
p.s your site is down again!
scrathhtmlviewer.net23.com or weebly?
Offline
MathWizz wrote:
pwiter wrote:
Daffy22 wrote:
No chance of getting weebly to do this!!!! Please listen to me!
![]()
You the host your using!!!![]()
No I know that! But Mathwizz's site isn't on weebly!
p.s your site is down again!scrathhtmlviewer.net23.com or weebly?
scrathhtmlviewer.net23.com is the one
Offline
pwiter wrote:
MathWizz wrote:
pwiter wrote:
No I know that! But Mathwizz's site isn't on weebly!
p.s your site is down again!scrathhtmlviewer.net23.com or weebly?
scrathhtmlviewer.net23.com is the one
Hmm... Try this
Offline
pwiter wrote:
Daffy22 wrote:
pwiter wrote:
I'll work on it!No chance of getting weebly to do this!!!! Please listen to me!
![]()
You the host your using!!!![]()
No I know that! But Mathwizz's site isn't on weebly!
p.s your site is down again!
It's up again now.
Offline
reader.php wrote:
<?php
$class_id = array(
1 => "UndefinedObject",
2 => "True",
3 => "False",
4 => "SmallInteger",
5 => "SmallInteger16",
6 => "LargePositiveInteger",
7 => "LargeNegativeInteger",
8 => "Float",
9 => "String",
10 => "Symbol",
11 => "ByteArray",
12 => "SoundBuffer",
13 => "Bitmap",
14 => "UTF8",
20 => "Array",
21 => "OrderedCollection",
22 => "Set",
23 => "IdentitySet",
24 => "Dictionary",
25 => "IdentityDictionary",
30 => "Color",
31 => "TranslucentColor",
32 => "Point",
33 => "Rectangle",
34 => "Form",
35 => "ColorForm",
99 => "ObjectRef",
100 => "Morph",
101 => "BorderedMorph",
102 => "RectangleMorph",
103 => "EllipseMorph",
104 => "AlignmentMorph",
105 => "StringMorph",
106 => "UpdatingStringMorph",
107 => "SimpleSliderMorph",
108 => "SimpleButtonMorph",
109 => "SampledSound",
110 => "ImageMorph",
111 => "SketchMorph",
123 => "SensorBoardMorph",
124 => "ScratchSpriteMorph",
125 => "ScratchStageMorph",
140 => "ChoiceArgMorph",
141 => "ColorArgMorph",
142 => "ExpressionArgMorph",
145 => "SpriteArgMorph",
147 => "BlockMorph",
148 => "CommandBlockMorph",
149 => "CBlockMorph",
151 => "HatBlockMorph",
153 => "ScratchScriptsMorph",
154 => "ScratchSliderMorph",
155 => "WatcherMorph",
157 => "SetterBlockMorph",
158 => "EventHatMorph",
160 => "VariableBlockMorph",
162 => "ImageMedia",
163 => "MovieMedia",
164 => "SoundMedia",
165 => "KeyEventHatMorph",
166 => "BooleanArgMorph",
167 => "EventTitleMorph",
168 => "MouseClickEventHatMorph",
169 => "ExpressionArgMorphWithMenu",
170 => "ReporterBlockMorph",
171 => "MultilineStringMorph",
172 => "ToggleButton",
173 => "WatcherReadoutFrameMorph",
174 => "WatcherSliderMorph");
$file = array();
$objects = array();
foreach (str_split(file_get_contents($_FILES["sbfile"]["tmp_name"])) as $byte)
{
array_push($file,ord($byte));
}
if (read_header())
{
if (next_string(2) == 0)
{
die("This project is too old!");
}
else
{
next_uint(4);
$object = read_object();
$object = fix_object($object,0);
echo "<pre>";
print_r($object);
echo "</pre>";
}
}
else
{
die("This file is not a Scratch file!");
}
function next_byte()
{
static $i = 0;
$n = $GLOBALS["file"][$i];
$i++;
return $n;
}
function next_length($length)
{
$array = array();
for ($i = 1; $i <= $length; $i++)
{
array_push($array,next_byte());
}
return $array;
}
function read_header()
{
return next_string(8) == "ScratchV";
}
function next_string($length)
{
$string = "";
foreach (next_length($length) as $byte)
{
$string = $string . chr($byte);
}
return $string;
}
function next_uint($length)
{
$int = 0;
$i = 1;
foreach (array_reverse(next_length($length)) as $byte)
{
$int += $byte * $i;
$i *= 256;
}
return $int;
}
function next_int($length)
{
$int = 0;
$i = 1;
foreach (next_length($length) as $byte)
{
$int += $byte * $i;
$i *= 256;
}
return $int;
}
function read_obj_header()
{
return next_string(4) == 'ObjS' && next_byte() == 1 && next_string(4) == 'Stch' && next_byte() == 1;
}
function read_object()
{
if (read_obj_header())
{
$size = next_uint(4);
$fields = array();
for ($i = 1; $i <= $size; $i++)
{
$field = read_field();
array_push($fields,$field);
}
return $fields;
}
else
{
die("Not an Object!");
}
}
function read_field()
{
$class_ID = next_byte();
$class_name = $GLOBALS["class_id"][$class_ID];
switch ($class_name)
{
case "ObjectRef":
$result = array("ObjectRef",array(next_uint(3)));
break;
case "UndefinedObject":
$result = array("UndefinedObject",array());
break;
case "True":
$result = array("True",array());
break;
case "False":
$result = array("False",array());
break;
case "SmallInteger":
$result = array("SmallInteger",array(next_uint(4)));
break;
case "SmallInteger16":
$result = array("SmallInteger16",array(next_uint(2)));
break;
case "String":
$result = array("String",array(next_string(next_uint(4))));
break;
case "ByteArray":
$result = array("ByteArray",array(next_length(next_uint(4))));
break;
case "UTF8":
$result = array("UTF8",array(next_string(next_uint(4))));
break;
case "Array":
$size = next_uint(4);
$result = array();
for ($i = 1; $i <= $size; $i++)
{
array_push($result,read_field());
}
$result = array("Array",$result);
break;
case "Dictionary":
$size = next_uint(4);
$result = array();
for ($i = 1; $i <= $size; $i++)
{
$key = read_field();
$value = read_field();
array_push($result,$key,$value);
}
$result = array("Dictionary",$result);
break;
case "Color":
$result = array("Color",array(next_uint(4)));
break;
case "TranslucentColor":
$result = array("TranslucentColor",array(next_uint(4),next_byte()));
break;
case "Form":
$width = read_field();
$height = read_field();
$depth = read_field();
$offset = read_field();
$bits = read_field();
$result = array("Form",array($width,$height,$depth,$offset,$bits));
break;
case "ColorForm":
$width = read_field();
$height = read_field();
$depth = read_field();
$offset = read_field();
$bits = read_field();
$colors = read_field();
$result = array("ColorForm",array($width,$height,$depth,$offset,$bits,$colors));
break;
default:
die("Unknown classID: " . $class_ID . "<br/>");
}
return $result;
}
function fix_object($objects,$object)
{
$class_name = $objects[$object][0];
switch ($class_name)
{
case "Array":
$result = array();
for ($i = 0; $i < count($objects[$object][1]); $i++)
{
$value = object_from($objects,$objects[$object][1][$i]);
array_push($result,$value);
}
$result = array("Array",$result);
break;
case "Dictionary":
$result = array();
for ($i = 0; $i < count($objects[$object][1]); $i++)
{
$value = object_from($objects,$objects[$object][1][$i]);
array_push($result,$value);
}
$result = array("Dictionary",$result);
break;
case "ColorForm":
$width = object_from($objects,$objects[$object][1][0]);
$height = object_from($objects,$objects[$object][1][1]);
$depth = object_from($objects,$objects[$object][1][2]);
$offset = object_from($objects,$objects[$object][1][3]);
$bits = object_from($objects,$objects[$object][1][4]);
$colors = object_from($objects,$objects[$object][1][5]);
$result = array("ColorForm",array($width,$height,$depth,$offset,$bits,$colors));
break;
default:
$result = $objects[$object];
}
return $result;
}
function object_from($objects,$object_ref)
{
if ($object_ref[0] != "ObjectRef")
{
return $object_ref;
}
return fix_object($objects,$object_ref[1][0] - 1);
}
function print_objects($objects)
{
for ($i = 0; $i < count($objects); $i++)
{
echo("[" . $i . "] => " . $objects[$i][0] . "<br/>");
}
}
?>
FINESH ET!!! Lol...
Last edited by MathWizz (2010-10-17 10:54:49)
Offline
What is left to do?
Offline
so mathwiz, is this going to be passed on to JS and/or HTML5 to understand and preview. Also any ideas on how to get the sounds and images. I'll do some research anyway!
Could you post me a link to the page that does that so I can try it out too!
Offline
Daffy22 wrote:
so mathwiz, is this going to be passed on to JS and/or HTML5 to understand and preview. Also any ideas on how to get the sounds and images. I'll do some research anyway!
![]()
Could you post me a link to the page that does that so I can try it out too!![]()
I don't have another page. Just the one I showed you.
Offline
MathWizz wrote:
Daffy22 wrote:
so mathwiz, is this going to be passed on to JS and/or HTML5 to understand and preview. Also any ideas on how to get the sounds and images. I'll do some research anyway!
![]()
Could you post me a link to the page that does that so I can try it out too!![]()
I don't have another page. Just the one I showed you.
can I have that link, I can't seem to find that one.
Offline
Please don't use Weebly.
Offline
Daffy22 wrote:
MathWizz wrote:
Daffy22 wrote:
so mathwiz, is this going to be passed on to JS and/or HTML5 to understand and preview. Also any ideas on how to get the sounds and images. I'll do some research anyway!
![]()
Could you post me a link to the page that does that so I can try it out too!![]()
I don't have another page. Just the one I showed you.
can I have that link, I can't seem to find that one.
![]()
Offline
Okay, since we're not using it anymore, I'll delete the weebly site.
Offline
ScratchReallyROCKS wrote:
Okay, since we're not using it anymore, I'll delete the weebly site.
I can design a site for you guys if you want!
(Just keep it in mind I am all-pro at HTML....unless it's 5.)
Offline
Maybe, instead of trying to make a HTML5 viewer, we could just add a file menu option called 'Save as HTML5' ?
It would be a lot simpler than trying to extract all the sprites/costumes/scripts/etc. out of the .sb file.
Offline
rubiks_cube_guy238 wrote:
Maybe, instead of trying to make a HTML5 viewer, we could just add a file menu option called 'Save as HTML5' ?
It would be a lot simpler than trying to extract all the sprites/costumes/scripts/etc. out of the .sb file.
but it extracts and decodes it very quickly any way! I don't think we want to be storing large data on our web server.
Offline