Remember / save()

An applet for this method is omitted. This method is only useful when running Processing locally (not on the internet).

// Saves a composition that consists of a single color
import compose.*;

// The only thing we're saving:
@EditableColor color bgColor = 0xFFFFFFFF; 

Commands commands;
Remember remember;

GripDispatcher dispatch;
Tinker tinker;

void setup() {
   size(720, 360);
   dispatch = new GripDispatcher(this);
   tinker = new Tinker(this);

   remember = new Remember(this);
   commands = new Commands(this);
   commands.add("save", remember, CONTROL, 's');
}

void draw() {
   background(bgColor);
   dispatch.update();
   dispatch.draw();
}

XMLElement getXML() {

   XMLElement compositionNode = new XMLElement();
   compositionNode.setName("color");

   // Here's a quick way to change an number to a String:
   String bgColorAsString = bgColor + "";

   compositionNode.setAttribute("value", bgColorAsString); 

   return compositionNode;

}

void loadXML(XMLElement xml) {
   bgColor = xml.getIntAttribute("value");
}
Description

Writes the data from the getXML() method to an xml file in the output directory.

If the composition has not been saved before, this method mimics the behavior of saveAs(), prompting the user to choose a save location with a dialogue box. If the file has been saved before, calling this method updates the file at the last chosen save location.

Syntax
rememberObject.save()
Parameters
None
Returns
None
Usage
Web & Applications
Related
Last Modified: April 18, 2010

No Comments

You must be logged in to post a comment.