If you read through the snap source code, you can learn how to use snap functions.
(click the snap logo, then click download source. You can then click on code in order to see the source code for snap (most of the js is in the src
folder))
A small tip, whenever you see a function like this
IDE_Morph.prototype.setDefaultDesign = function () {
MorphicPreferences.isFlat = false;
SpriteMorph.prototype.paletteColor = new Color(30, 30, 30);
SpriteMorph.prototype.paletteTextColor = new Color(230, 230, 230);
StageMorph.prototype.paletteTextColor
= SpriteMorph.prototype.paletteTextColor;
...
}
In order to access it, you use this function
this.parentThatIsA(IDE_Morph).setDefaultDesign();
Basically how it works is, take the object from the function definition, in this case IDE_Morph
(it can also be StageMorph
, and basically any morph), and put it in the function this.parentThatIsA()
, in this case it would be this.parentThatIsA(IDE_Morph)
. Now you can get any property that object has, or use any function that object has. In this case it would be this.parentThatIsA(IDE_Morph).setDefaultDesign();
.
Of course I like to get the IDE_Morph
this way
world.children[0]
because it looks nicer, and also doesn't rely on the function to be ran inside a javascript function block.
To get the StageMorph
this way, you need to do
world.children[0].stage
And to get a specific type of morph, like in the function defenitions, just do
world.children[0].childThatIsA(StageMorph)
(replace StageMorph
with the morph you want).