Application Plugin

Matt Karl edited this page Aug 5, 2015 · 3 revisions

SpringRoll support a simple plugin architecture to add properties, events, components and options to the Application. The application consists of three optional methods setup, preload and teardown. For more information, visit the API docs for ApplicationPlugin.


	// Create a new plugin, automatically is added
	// to the list of application plugins
	var plugin = new springroll.ApplicationPlugin();

	// Setup function is called before anything else is created
	// good place to setup properties on Application or
	// create event listeners. Bound to application
	plugin.setup = function()
		// Add an application constructor option
		this.options.add('something', 'defaultValue'); 

	// Preload is an optional asynchronous call for doing any loading
	// before the application is init. Make sure that done() is called
	// when this is complete. The display and options are available here.
	plugin.preload = function(done)
		// Application options are available

		// Main display, if setup, is available

		done(); // required!

	// Clean-up when the application is destroyed
	plugin.teardown = function()
		// remove any objects here


Plugin Examples