px Frameworks

px.import

px.import is used to include modules, jars, and individual javascript files into a javascript page. It is similar to the Nodejs "require" function, with some available enhancements.

px.import can include one to many modules in a single call and returns a promise when all imported source is ready for use.

Limitations

Only the following Nodejs modules are allowed for import:

Prefix

The px: prefix has special meaning and references javascript built in to pxscene.

Usage

Import a single javascript file

  // import the scene object, version 1
  px.import("px:scene.1.js").then( function ready(scene) {
  var root = scene.root;
  .
  .
  .
  }).catch( function importFailed(err){
  console.error("Imports failed for myexample.js: " + err)
});
 
            

Import multiple items

  // import the scene object, version 1,
  // import the built-in keycode constants [need reference],
  // import the Nodejs url module
  px.import({ scene: 'px:scene.1.js',
              keys: 'px:tools.keys.js',
              url: 'url' }).then( function importsAreReady(imports) {
  var scene = imports.scene;
  var keys = imports.keys;
  var url = imports.url;
  var root = imports.scene.root;
  .
  .
  .
  }).catch( function importFailed(err){
  console.error("Imports failed for myexample.js: " + err)
});
 

px.configImport

px.configImport can be used to name a common frameworks location, then that name can be used within px.import.

Usage

px.configImport({"pxFramework:":"http://www.pxscene.org/someFrameworks/widgets/"});
  
px.import({ scene: 'px:scene.1.js',
             image: 'pxFramework:ImageAnimator.js'
}).then( function importsAreReady(imports)

  var root = scene.root;
  var image = image.ImageAnimator;
  .
  .
  .
  }).catch( function importFailed(err){
  console.error("Imports failed for myexample.js: " + err)
});
 
            

This project is maintained by pxscene

Hosted on GitHub Pages — Theme by orderedlist