Remember / saveAs()

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');
   commands.add("saveAs", remember, CONTROL, SHIFT, '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

Prompts the user to choose a new save location for the current composition. You can think of this as creating a “branch” of the composition. All subsequent calls to save() will be written to the chosen location.

If you do not wish to prompt the user for a new save location, you can specify one in code with the filePath parameter.

Syntax
remember.saveAs()
remember.saveAs(filePath)
Parameters
filePath
String: new save location
Returns
None
Usage
Web & Applications
Related
Last Modified: April 18, 2010

No Comments

You must be logged in to post a comment.