This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#476 2010-10-17 06:43:04

TheSuccessor
Scratcher
Registered: 2010-04-23
Posts: 1000+

Re: Lets make a new Scratch viewer!

See post #471 for sound.


/* No comment */

Offline

 

#477 2010-10-17 07:17:03

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: Lets make a new Scratch viewer!

TheSuccessor wrote:

See post #471 for sound.

Mobile devices can't run applets.  sad


http://block.site90.net/scratch.mit/text.php?size=30&text=%20A%20signature!&color=333333

Offline

 

#478 2010-10-17 08:09:06

ScratchReallyROCKS
Scratcher
Registered: 2009-04-22
Posts: 1000+

Re: Lets make a new Scratch viewer!

MathWizz wrote:

TheSuccessor wrote:

See post #471 for sound.

Mobile devices can't run applets.  sad

Wow, we were both thinking the same thing!


http://imageshack.us/a/img694/3806/sigmad.png

Offline

 

#479 2010-10-17 08:20:48

pwiter
Scratcher
Registered: 2010-06-02
Posts: 100+

Re: Lets make a new Scratch viewer!

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!


http://i.imgur.com/YBeXc.png

Offline

 

#480 2010-10-17 08:25:21

Daffy22
Scratcher
Registered: 2008-12-15
Posts: 500+

Re: Lets make a new Scratch viewer!

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!  mad
You the host your using!!!  big_smile


http://img201.imageshack.us/img201/1784/logosmalle.png
"Spectacular - 5 Star" -  CNET.com Editor.

Offline

 

#481 2010-10-17 08:28:04

pwiter
Scratcher
Registered: 2010-06-02
Posts: 100+

Re: Lets make a new Scratch viewer!

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!  mad
You the host your using!!!  big_smile

No I know that! But Mathwizz's site isn't on weebly!
p.s your site is down again!


http://i.imgur.com/YBeXc.png

Offline

 

#482 2010-10-17 08:44:33

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: Lets make a new Scratch viewer!

pwiter wrote:

Daffy22 wrote:

pwiter wrote:


I'll work on it!

No chance of getting weebly to do this!!!! Please listen to me!  mad
You the host your using!!!  big_smile

No I know that! But Mathwizz's site isn't on weebly!
p.s your site is down again!

scrathhtmlviewer.net23.com or weebly?


http://block.site90.net/scratch.mit/text.php?size=30&text=%20A%20signature!&color=333333

Offline

 

#483 2010-10-17 08:46:32

pwiter
Scratcher
Registered: 2010-06-02
Posts: 100+

Re: Lets make a new Scratch viewer!

MathWizz wrote:

pwiter wrote:

Daffy22 wrote:

No chance of getting weebly to do this!!!! Please listen to me!  mad
You the host your using!!!  big_smile

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


http://i.imgur.com/YBeXc.png

Offline

 

#484 2010-10-17 08:49:25

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: Lets make a new Scratch viewer!

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


http://block.site90.net/scratch.mit/text.php?size=30&text=%20A%20signature!&color=333333

Offline

 

#485 2010-10-17 09:03:42

Daffy22
Scratcher
Registered: 2008-12-15
Posts: 500+

Re: Lets make a new Scratch viewer!

pwiter wrote:

Daffy22 wrote:

pwiter wrote:


I'll work on it!

No chance of getting weebly to do this!!!! Please listen to me!  mad
You the host your using!!!  big_smile

No I know that! But Mathwizz's site isn't on weebly!
p.s your site is down again!

It's up again now.  smile


http://img201.imageshack.us/img201/1784/logosmalle.png
"Spectacular - 5 Star" -  CNET.com Editor.

Offline

 

#486 2010-10-17 10:54:00

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: Lets make a new Scratch viewer!

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)


http://block.site90.net/scratch.mit/text.php?size=30&amp;text=%20A%20signature!&amp;color=333333

Offline

 

#487 2010-10-17 11:35:19

johnnydean1
Scratcher
Registered: 2010-02-12
Posts: 1000+

Re: Lets make a new Scratch viewer!

What is left to do?


You can now reach me on Twitter @johnnydean1_

Offline

 

#488 2010-10-17 11:53:31

Daffy22
Scratcher
Registered: 2008-12-15
Posts: 500+

Re: Lets make a new Scratch viewer!

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!  big_smile

Could you post me a link to the page that does that so I can try it out too!  big_smile


http://img201.imageshack.us/img201/1784/logosmalle.png
"Spectacular - 5 Star" -  CNET.com Editor.

Offline

 

#489 2010-10-18 14:50:03

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: Lets make a new Scratch viewer!

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!  big_smile

Could you post me a link to the page that does that so I can try it out too!  big_smile

I don't have another page. Just the one I showed you.


http://block.site90.net/scratch.mit/text.php?size=30&amp;text=%20A%20signature!&amp;color=333333

Offline

 

#490 2010-10-18 15:12:00

Daffy22
Scratcher
Registered: 2008-12-15
Posts: 500+

Re: Lets make a new Scratch viewer!

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!  big_smile

Could you post me a link to the page that does that so I can try it out too!  big_smile

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.  sad


http://img201.imageshack.us/img201/1784/logosmalle.png
"Spectacular - 5 Star" -  CNET.com Editor.

Offline

 

#491 2010-10-18 15:34:35

TheSuccessor
Scratcher
Registered: 2010-04-23
Posts: 1000+

Re: Lets make a new Scratch viewer!

Please don't use Weebly.


/* No comment */

Offline

 

#492 2010-10-18 15:45:35

Daffy22
Scratcher
Registered: 2008-12-15
Posts: 500+

Re: Lets make a new Scratch viewer!

TheSuccessor wrote:

Please don't use Weebly.

don't worry we're not!  roll


http://img201.imageshack.us/img201/1784/logosmalle.png
"Spectacular - 5 Star" -  CNET.com Editor.

Offline

 

#493 2010-10-18 15:50:23

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: Lets make a new Scratch viewer!

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!  big_smile

Could you post me a link to the page that does that so I can try it out too!  big_smile

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.  sad

http://scratchhtmlviewer.net23.net


http://block.site90.net/scratch.mit/text.php?size=30&amp;text=%20A%20signature!&amp;color=333333

Offline

 

#494 2010-10-18 18:43:16

midnightleopard
Scratcher
Registered: 2007-09-13
Posts: 1000+

Re: Lets make a new Scratch viewer!

Who cares about sound on mobile devices? It would cause lag.


http://pwp.wizards.com/5103673563/Scorecards/Landscape.png

Offline

 

#495 2010-10-18 20:13:16

ScratchReallyROCKS
Scratcher
Registered: 2009-04-22
Posts: 1000+

Re: Lets make a new Scratch viewer!

Okay, since we're not using it anymore, I'll delete the weebly site.


http://imageshack.us/a/img694/3806/sigmad.png

Offline

 

#496 2010-10-18 20:38:35

bbbeb
Scratcher
Registered: 2009-06-11
Posts: 1000+

Re: Lets make a new Scratch viewer!

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!  big_smile

(Just keep it in mind I am all-pro at HTML....unless it's 5.)


Back in my day.... there were no laws that censored the internet... now, there are.... nah.

Offline

 

#497 2010-10-18 20:44:01

rubiks_cube_guy238
Scratcher
Registered: 2009-07-02
Posts: 100+

Re: Lets make a new Scratch viewer!

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.


The glass is never half full nor half empty; it is twice as large as it needs to be.

Offline

 

#498 2010-10-19 02:59:20

Daffy22
Scratcher
Registered: 2008-12-15
Posts: 500+

Re: Lets make a new Scratch viewer!

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.  hmm


http://img201.imageshack.us/img201/1784/logosmalle.png
"Spectacular - 5 Star" -  CNET.com Editor.

Offline

 

#499 2010-10-19 03:03:50

Daffy22
Scratcher
Registered: 2008-12-15
Posts: 500+

Re: Lets make a new Scratch viewer!

Ok, I've tried uploading a big scratch project and it said I've exausted byte limit or something???
I think it's the host, maybe we could switch hosts?


http://img201.imageshack.us/img201/1784/logosmalle.png
"Spectacular - 5 Star" -  CNET.com Editor.

Offline

 

#500 2010-10-19 04:13:03

ssss
Scratcher
Registered: 2007-07-29
Posts: 1000+

Re: Lets make a new Scratch viewer!

Host with me!  Cyberkidscountry.com/Notarealink Email the html, css php and i upload them!


Hey.  It's me SSSS, back from the dead!  smile

Offline

 

Board footer