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

#5926 2012-08-31 20:15:13

shadow_7283
Scratcher
Registered: 2007-11-07
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Scratch Forums down for maintenance this morning just about broke my heart.

Offline

 

#5927 2012-08-31 22:01:29

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Agreed.  sad


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#5928 2012-08-31 22:38:10

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

Re: BYOB 3 - Discussion Thread

I was up till 2 am the night before so I only got on at 9 am. xD


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

Offline

 

#5929 2012-09-01 11:07:24

bharvey
Scratcher
Registered: 2008-08-10
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Did something change recently that's making me have to log in all the time?  Used to be I could stay logged in forever.


http://cs.berkeley.edu/~bh/sig5.png

Offline

 

#5930 2012-09-01 11:32:56

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: BYOB 3 - Discussion Thread

bharvey wrote:

Did something change recently that's making me have to log in all the time?  Used to be I could stay logged in forever.

Yeah, I'm finding that. I'm sure the forums usually let you stay logged in for longer than the main Scratch site, too... or is that just me?  tongue


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#5931 2012-09-01 16:11:29

joefarebrother
Scratcher
Registered: 2011-04-08
Posts: 1000+

Re: BYOB 3 - Discussion Thread

bharvey wrote:

Did something change recently that's making me have to log in all the time?  Used to be I could stay logged in forever.

Same. I have to log in whenever i use scratch from a computer, but i am auto logged in whenever i use my phone. [/offtopic]

Anyways: Snap suggestion: Thread variables! They would be variables that every thread defined in the lexical scope of the variable has a unique copy to. Would be useful for my nondeterminism project, as each thread can have it's own fail continuation and another thread with another fail continuation could not interfere. Would also be useful for servers once we get some form of networking (such as mesh) in snap. If i think of any more examples, i will say.


My latest project is called http://tinyurl.com/d2m8hne! It has http://tinyurl.com/d395ygk views, http://tinyurl.com/cnasmt7 love-its, and http://tinyurl.com/bwjy8xs comments.
http://tinyurl.com/756anbk   http://tinyurl.com/iplaychess

Offline

 

#5932 2012-09-02 09:01:17

Jens
Scratcher
Registered: 2007-06-04
Posts: 1000+

Re: BYOB 3 - Discussion Thread

joefarebrother wrote:

Snap suggestion: Thread variables

interesting suggestion. How aren't Script Variables what you need?


Jens Mönig

Offline

 

#5933 2012-09-02 09:11:09

joefarebrother
Scratcher
Registered: 2011-04-08
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Jens wrote:

joefarebrother wrote:

Snap suggestion: Thread variables

interesting suggestion. How aren't Script Variables what you need?

Because if a custom block referenced a variable that every thread should have a unique copy to, it won't know which binding to use as to not mess up the program. It's basically a subset of dynamic scope.


My latest project is called http://tinyurl.com/d2m8hne! It has http://tinyurl.com/d395ygk views, http://tinyurl.com/cnasmt7 love-its, and http://tinyurl.com/bwjy8xs comments.
http://tinyurl.com/756anbk   http://tinyurl.com/iplaychess

Offline

 

#5934 2012-09-02 09:24:56

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: BYOB 3 - Discussion Thread

bharvey wrote:

Did something change recently that's making me have to log in all the time?  Used to be I could stay logged in forever.

Random logout bug. It used to happen to me every five minutes when I used FireFox. Then I migrated to Safari and it fixed itself.  smile


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#5935 2012-09-03 11:03:34

bharvey
Scratcher
Registered: 2008-08-10
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Hardmath123 wrote:

It used to happen to me every five minutes

Wait, it's not a new thing?  This only just started happening to me a week ago.  Did it happen to you anywhere other than Scratch?


http://cs.berkeley.edu/~bh/sig5.png

Offline

 

#5936 2012-09-03 22:13:56

shadow_7283
Scratcher
Registered: 2007-11-07
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Hey guys! Remember way, way back when I promised a script to assist in embedding Snap! in web pages without using iframes? I finally finished a testing version!

To create an instance of snapembed, all you need is snapembed.js and the snap directory which contains a minified version of Snap! as well as a couple of images. Reference them in the header:

Code:

<head>
    <script type="text/javascript" src="snapembed.js"></script>
    <script type="text/javascript" src="snap/snap.js"></script>
</head>

Then include the snapembed code at the end of the body tag:

Code:

<body>
    <!--Some Code-->
    <script type="text/javascript">
        var snapembed = new snapembed(false);
        snapembed.create('example_contain',{width:800,height:600});
        snapembed.create('example_contain2',{width:1024,height:768});
    </script>

Starting snapembed is simple. Make a variable by any name that you will use to reference the script (var example = new snapembed(true)). The paramater inside snapembed is required. It specifies whether each instance of Snap! can be run simultaneously. False means they will be run one at a time, as in the demo.

To create a new instance of Snap! use the line of code:

Code:

snapembed.create(id of container,options);

This takes two paramaters: the id of a div that will contain the instance of Snap! and the options. Currently there are two options, width and height, specified like so: {width: 100, height:100}.

To edit one of these options, use:

Code:

snapembed.edit(id of container, option, value);

Editing of width and height is under construction, as you can see from the demo.
Also, don't use unit when specifying lengths.

MORE FEATURES COMING SOON!  big_smile

Last edited by shadow_7283 (2012-09-03 22:17:26)

Offline

 

#5937 2012-09-03 22:16:43

shadow_7283
Scratcher
Registered: 2007-11-07
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Jens, (or anyone else familiar with Snap! / morphic), my snapembed script can update the width of the world morph, but I'm unsure how to update Snap!'s width. Can anyone help me out?

Offline

 

#5938 2012-09-03 23:07:58

fullmoon
Retired Community Moderator
Registered: 2007-06-04
Posts: 1000+

Re: BYOB 3 - Discussion Thread

shadow_7283 wrote:

Jens, (or anyone else familiar with Snap! / morphic), my snapembed script can update the width of the world morph, but I'm unsure how to update Snap!'s width. Can anyone help me out?

The whole Snap interface is an instance of IDE_Morph. Try this:

Code:

world.children.filter(function(m){ return m instanceof IDE_Morph; })[0].setExtent(new Point(width,height))

Careful, I am having trouble getting it to shrink past a certain size.


http://i302.photobucket.com/albums/nn100/fullmoon32/wow.jpg

Offline

 

#5939 2012-09-03 23:17:17

bharvey
Scratcher
Registered: 2008-08-10
Posts: 1000+

Re: BYOB 3 - Discussion Thread

shadow_7283 wrote:

a script to assist in embedding Snap! in web pages

Cool!

contains a minified version of Snap!

Does this mean that you have to have your own local Snap!, rather than running the latest one in the embedded window?

Also, did you have to modify Snap! to make it work?

My top priority missing feature (unless I'm misreading your post) is the ability to specify a project with #open or (when Jens finishes it) #run.  I think people are less likely to want to embed raw Snap! on their pages than to embed a particular project.


http://cs.berkeley.edu/~bh/sig5.png

Offline

 

#5940 2012-09-04 09:29:43

shadow_7283
Scratcher
Registered: 2007-11-07
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Yeah, opening is coming soon, I just wanted to commit myself to the project by posting an early version here. Snap! was not modified. Although it's a local copy, you and Jens could easily host a remote copy for users to reference (similar to google and jQuery).
Thanks for the tip fullmoon. By the way, I'm sure my script semantics are awful, so if you have any tips for improvement let me know. I considered using jQuery, but decided it would probably be unnecessary.

Offline

 

#5941 2012-09-04 09:51:41

Jens
Scratcher
Registered: 2007-06-04
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Great idea, shadow! I've been playing with a Snap runtime myself recently - just a single condensed JS file within a single function which encapsulates its own namespace. That way we can create both stand-alone executables and also embed any project into any web page simply by linking to the hosted runtime. But your way is also very interesting!


Jens Mönig

Offline

 

#5942 2012-09-04 16:45:11

joefarebrother
Scratcher
Registered: 2011-04-08
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Is it possible to embed XML into a HTML <div> and access it via the innerHTML function?

If so, the following code should work, although I haven't tested it yet.

To embed a project, use
<div class="snap">
T<xml or the project, or the url it is saved at>
</div>
Put F instead of T if you want the user to be able to enter edit mode, and use the green flag and pause button and stop sign

The code:

Code:

var projects = document.getElementByTagName("div").filter(function(div){return div.className == "snap"}),
    worlds = [];

projects.forEach(function (project){
  var contents = project.innerHTML,
       appMode = contents.charAt(0) == "T",  //T or F
       savedProject = contents.slice(1), // URL or embedded XML
       canvas,
       world,
       ide,
       oldHash;
  project.innerHTML = ""; //clear the div

  canvas = project.appendChild(document.createElement("canvas"));
  canvas.width = project.clientWidth;
  canvas.height = project.clientHeight;

  world = new WorldMorph(canvas);
  worlds.push(world);

  ide = new IDE_Morph();
  ide.setExtent( new Point(project.clientWidth, project.clientHeight);
  
  //open the project
  oldHash = location.hash;
  location.hash = "#open:" + savedProject;
  ide.openIn(world);
  location.hash = oldHash;

  //Put in app mode if needed
  if (appMode){
    ide.isAppMode = true;
    ide.controlBar.hide(); //hide the edit mode button,the green flag,pause button and the stop button
  }
});

setInterval(loop, 1);

function loop(){
  worlds.forEach(function (world){
    world.doOneCycle();
  });
}

My latest project is called http://tinyurl.com/d2m8hne! It has http://tinyurl.com/d395ygk views, http://tinyurl.com/cnasmt7 love-its, and http://tinyurl.com/bwjy8xs comments.
http://tinyurl.com/756anbk   http://tinyurl.com/iplaychess

Offline

 

#5943 2012-09-04 18:17:49

bharvey
Scratcher
Registered: 2008-08-10
Posts: 1000+

Re: BYOB 3 - Discussion Thread

joefarebrother wrote:

Put F instead of T if you want the user to be able to enter edit mode, and use the green flag and pause button and stop sign

I should think a popular choice would be yes to green flag etc but no to edit -- or alternatively a way to superimpose a half-transparent play button over the whole project, a la youtube embedded videos.


http://cs.berkeley.edu/~bh/sig5.png

Offline

 

#5944 2012-09-04 19:34:35

fullmoon
Retired Community Moderator
Registered: 2007-06-04
Posts: 1000+

Re: BYOB 3 - Discussion Thread

joefarebrother wrote:

Is it possible to embed XML into a HTML <div> and access it via the innerHTML function?

Yes although that's definitely considered bad practice by most web developers. Most browsers will consider any XML inside a div to be HTML, which means that they may mess with the attributes and structure of the document — and parsing an XML tree the size of those that Snap produces is a lot of pointless work for the browser that will slow down rendering. Far better to just load it with XMLHttpRequest! If you really need to put a Snap file inside a webpage I would use a <script type='text/snap'> element. The browser (probably) won't consider it Javascript and you could tell Snap to grab the innerHTML of that and parse it.


http://i302.photobucket.com/albums/nn100/fullmoon32/wow.jpg

Offline

 

#5945 2012-09-04 21:09:28

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: BYOB 3 - Discussion Thread

bharvey wrote:

joefarebrother wrote:

Put F instead of T if you want the user to be able to enter edit mode, and use the green flag and pause button and stop sign

I should think a popular choice would be yes to green flag etc but no to edit -- or alternatively a way to superimpose a half-transparent play button over the whole project, a la youtube embedded videos.

That sounds good. And make the flag bar appear on hover, like the youtube play/pause/ff/rewind bar.


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#5946 2012-09-07 14:06:01

joefarebrother
Scratcher
Registered: 2011-04-08
Posts: 1000+

Re: BYOB 3 - Discussion Thread

'K, improved the code:

Code:

var projects = document.getElementsByTagName("script").filter(
                   function (script){ return script.getAttribute("type"); }),
      worlds=[] 

projects.forEach(function (project){
   var  canvas = document.createElement("canvas"),
        world = new WorldMorph(),
        ide = new IDE_Morph(),
        control = ide.controlBar,

        appModeButton = control.appModeButton,
        pauseButton = control.pauseButton
        flag = control.children.filter(
                  function (morph){ 
                                    return morph instanceof PushButtonMorph 
                                        && morph.action = 'runScripts';
                                  })[0],
        stop = control.children.filter(
                  function (morph){ 
                                    return morph instanceof PushButtonMorph 
                                        && morph.action = 'stopAllScripts';
                                  })[0],

        contents = project.innerHTML,
        start = contents.indexOf("!"),
        end = start ? contents.indexOf("!", start + 1) : 0,
        options = start ? contents.substring(start + 1, end).split(",") : [],
        projCode = start ? contents.substring(end + 1) : contents,

        hideEdit = options.contains("noEdit"),
        hideFlag = options.contains("noFlag"),
        hideStop = options.contains("noStop"),
        hidePause = options.contains("noPause"),
        controlBarHover = detect( options, 
                                  function (str){ return str.substring(0, 7) = "hover:" }
                                ).substring(7),

        oldHash = location.hash;
 
  project.parentNode.replaceNode(canvas, project);  

  //open project
  location.hash = "#open:" + projCode;
  ide.openIn(world);
  location.hash = oldHash;

  ide.isAppMode = true;

  //hide the buttons the user wants to hide
  if (hideEdit){
    appModeButton.hide();
  }
  if (hideFlag){
    flag.hide();
  }
  if (hideStop){
    stop.hide();
  }
  if (hidePause){
    pause.hide();
  }

  if (controlBarHover){
    var shownYPos = controlBar.topLeft().y, hiddenYPos;
    controlBar.setPosition(new Point( controlBar.topLeft().x,
                                      (shownYPos + 2) - controlBar.height()
                                    ));
    hiddenYPos = controlBar.topLeft().y;

    controlBar.fps = 12;

    controlBar.mouseEnter = function (){ 
      controlBar.step = function(){
        controlBar.setPosition(new Point( controlBar.topLeft().x, 
                                          controlBar.topLeft().y + controlBarHover
                                        ));
        if (controlBar.topLeft().y > shownYPos){
          controlBar.step = nop;
        } 
      };
    };
    
    controlBar.mouseLeave = function (){
      controlBar.step = function(){
        controlBar.setPosition(new Point( controlBar.topLeft().x, 
                                          controlBar.topLeft().y - controlBarHover
                                        ));
        if (controlBar.topLeft().y < hiddenYPos){
          controlBar.step = nop;
        } 
      };
    };
  }

  ide.runScripts

  worlds.push(world);
  
});

setInterval(loop, 1);

function loop(){
  worlds.forEach(function (world){
    world.doOneCycle();
  }
}

Syntax:

<script type = "text/snap">
!options!embedded XML or project URL
</script>

For the options, write a comma-separated list (without spaces) with 1 or more of the following options: (if there are no options, you can omit the options bit altogether: don't put in the !s)
noEdit - hides the edit button
noFlag - hides the green flag
noStop - hides the stop sign
noPause - hides the pause button
hover:### - makes the control bar slide on and off screen mouse hover, at a speed specified by ###
Don't put any whitespace between the closing ! of the options bit and the start of the URL/XML.

Untested.

Last edited by joefarebrother (2012-09-08 04:27:46)


My latest project is called http://tinyurl.com/d2m8hne! It has http://tinyurl.com/d395ygk views, http://tinyurl.com/cnasmt7 love-its, and http://tinyurl.com/bwjy8xs comments.
http://tinyurl.com/756anbk   http://tinyurl.com/iplaychess

Offline

 

#5947 2012-09-07 18:19:00

shadow_7283
Scratcher
Registered: 2007-11-07
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Awesome! You've definitely made a much more sophisticated (and semantically correct) product!  big_smile

Jens, I don't know if you have anything official planned as far as embedding is concerned, but we could start a Google Code project for Snap! Embed if you all think it's a good idea.

Last edited by shadow_7283 (2012-09-07 18:21:33)

Offline

 

#5948 2012-09-08 08:07:53

joefarebrother
Scratcher
Registered: 2011-04-08
Posts: 1000+

Re: BYOB 3 - Discussion Thread

I still don't understand why
http://i50.tinypic.com/14jbx9l.jpg
doesn't work  sad
(it doesn't save properly OR run properly)

Last edited by joefarebrother (2012-09-08 08:08:36)


My latest project is called http://tinyurl.com/d2m8hne! It has http://tinyurl.com/d395ygk views, http://tinyurl.com/cnasmt7 love-its, and http://tinyurl.com/bwjy8xs comments.
http://tinyurl.com/756anbk   http://tinyurl.com/iplaychess

Offline

 

#5949 2012-09-09 13:27:10

bharvey
Scratcher
Registered: 2008-08-10
Posts: 1000+

Re: BYOB 3 - Discussion Thread

joefarebrother wrote:

I still don't understand why
http://i50.tinypic.com/14jbx9l.jpg
doesn't work  sad
(it doesn't save properly OR run properly)

Jens (who's on vacation right now) said something about a bug regarding multiple unevaluated inputs, I think.  I'm not sure what the status of that is.  I'm sure he'll reply when he's back.


http://cs.berkeley.edu/~bh/sig5.png

Offline

 

#5950 2012-09-12 09:26:21

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Hey bharvey, I know you once wrote an article on pattern-matching like REgEx(p?) It went way over my head six months ago, but I think I can grok it now. Can you dig it out for me, please? Thanks!  smile


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

Board footer