/ / Load json Kinetics 4.3.3 - kineticjs

Načítať json Kinetics 4.3.3 - kineticjs

Snažím sa načítať fázu.etapa zaťaženia s funkciou () 4.3.3 kineticjs, ale žiadna takáto funkcia sa nepoužíva Kinetic.Node.create. Neviem, ako používať túto funkciu, niekto by mohol vysvetliť, ako sa používa. Ďakujem mnohokrát

odpovede:

0 pre odpoveď č. 1

Vytvorenie fázy z JSON nie je zložité:

  1. Stiahnite si serializovanú fázu json.
  2. Hydratujte pódium pomocou var stage = Kinetic.Node.create(myJSON, "container");

Tu je niektorý príklad kód:

// Use jQuery to call to your server and retrieve
// the JSON representation of your KineticJS stage
// jQuery make calling JSON easy, but...
// Alternatively, you can use straight javascript--google ;)
$.ajax({
type: "GET",
dataType: "json",
url: "http://www.yourSite.com/yourStageInJSON.json",
success: successHandler,
error: errorHandler
});

// this is called when your json-stage has been downloaded
function successHandler(myJSON){
// use the downloaded json to create the stage
// "container" is just the normal KineticJS container div
var stage = Kinetic.Node.create(myJSON, "container");
}

// this is called if there was a problem with the download
function errorHandler(){
alert("Something has gone horribly wrong--call somebody!");
}

Ak chcete vidieť, ako vyzerá fáza serializovaná na json, môžete serializovať existujúcu fázu takto:

var json = stage.toJSON();