Extension - Kirix Documentation

Developer Resources

Extension

Overview

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.

Methods

Extension.getBitmapResource
Loads a bitmap resource from an extension
Extension.getTextResource
Loads a text resource from an extension
Extension.isContextPackage
Determines if the program is running from a package

Example

// 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();

Extension.getBitmapResource

static function Extension.getBitmapResource(path : String) : Bitmap

Arguments

path
The path to the desired resource either in the extension file or extension directory

Returns

A valid bitmap object upon success, null otherwise

Description

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.

Extension.getTextResource

static function Extension.getTextResource(path : String) : String

Arguments

path
The path to the desired resource either in the extension file or extension directory

Returns

A valid string upon success, null otherwise

Description

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.

Extension.isContextPackage

static function Extension.isContextPackage() : Boolean

Returns

True if the program is running from an extension package, false otherwise

Description

Calling this method allows the caller to determine if the program running is running in from a context of an extension package.