diff --git a/src/content/examples/en/14_Loading_And_Saving_Data/01_JSON/code.js b/src/content/examples/en/14_Loading_And_Saving_Data/01_JSON/code.js index a9ecb95963..c9740ce01e 100644 --- a/src/content/examples/en/14_Loading_And_Saving_Data/01_JSON/code.js +++ b/src/content/examples/en/14_Loading_And_Saving_Data/01_JSON/code.js @@ -8,12 +8,6 @@ let mousePressY = 0; // Remember whether bubble is currently being created let creatingBubble = false; -// Put any asynchronous data loading in preload to complete before "setup" is run -function preload() { - // Load the JSON file and then call the loadData() function below - loadJSON('/assets/bubbles.json', loadData); -} - // Convert saved bubble data into Bubble Objects function loadData(bubblesData) { bubbles = []; @@ -31,9 +25,11 @@ function loadData(bubblesData) { } } -function setup() { +async function setup() { let p5Canvas = createCanvas(640, 360); + await loadJSON('/assets/bubbles.json', loadData); + // When canvas is clicked, call saveMousePress() p5Canvas.mousePressed(saveMousePress); diff --git a/src/content/examples/en/14_Loading_And_Saving_Data/02_Table/code.js b/src/content/examples/en/14_Loading_And_Saving_Data/02_Table/code.js index 017ebac599..c64d6131d1 100644 --- a/src/content/examples/en/14_Loading_And_Saving_Data/02_Table/code.js +++ b/src/content/examples/en/14_Loading_And_Saving_Data/02_Table/code.js @@ -25,6 +25,7 @@ function loadData(table) { // Put object in array bubbles.push(new Bubble(x, y, radius, name)); } + return table; } async function setup() {