The Extension class provides information about and access to extension packages. Many times bitmap or text resources need to be loaded from the extension package to be displayed in the user interface of the extension. This class facilitates this functionality.
// assuming an extension file with a picture called "mountains.jpg"
// and a script file called "main.js", the following should demonstrate
// loading bitmap and text resources
class MyForm extends Form
{
function MyForm()
{
var bmp = Extension.getBitmapResource("mountains.jpg");
var width = bmp.getWidth();
var height = bmp.getHeight();
super("Startup Picture", 1, 1, width-20, height);
this.center();
var picture = new PictureBox(0, 0, width, height-70);
picture.setImage(bmp);
this.add(picture);
var button = new Button("Show Source", 5, height-65, 80, 24);
button.click.connect(this, onShowSource);
this.add(button);
}
function onShowSource()
{
var source = Extension.getTextResource("main.js");
alert(source);
}
}
var f = new MyForm;
f.show();
f = null;
Application.run();
A valid string upon success, null otherwise
Loads a binary resource from an extension package. If the extension is packaged up into a kxt/zip file, the resource is loaded from that archive. If the extension is not packaged up, but is rather one or more non-packaged files in a directory, the resource is loaded from that directory.
A valid bitmap object upon success, null otherwise
Loads a bitmap resource from an extension package. If the extension is packaged up into a kxt/zip file, the resource is loaded from that archive. If the extension is not packaged up, but is rather one or more non-packaged files in a directory, the resource is loaded from that directory.
A valid string upon success, null otherwise
Loads a text resource from an extension package. If the extension is packaged up into a kxt/zip file, the resource is loaded from that archive. If the extension is not packaged up, but is rather one or more non-packaged files in a directory, the resource is loaded from that directory.
True if the program is running from an extension package, false otherwise
Calling this method allows the caller to determine if the program running is running in from a context of an extension package.