app.res

Access to current stage's resources including style. Unlike NetworkInterface, the downloaded resources will be mapped accordingly.

Constants#

NameTypeDescription
urlstringURL of current stage's resource.
styleobjectProvides access to style.varl.

Methods#

NameReturn TypeDescription
loadIconPromise<ImageBitmapSource>Get app or stage specific icon, asynchronously.
loadPicturePromise<ImageBitmapSource>Get app or stage specific picture, asynchronously.
loadFontPromise<Font>Get app or stage specific font, asynchronously.

loadIcon#

app.res.loadIcon(name);

Get app or stage specific icon, asynchronously. Only accept SVG format, otherwise error occured. The reason of separating SVG as icon because we have to draw icon with vector instead of bitmap. Thus, better load time, performance, and scalibility. The icon should be simple as stated on Material Design specification.

Parameters:

  1. name: (string type) Icon name, without .svg suffix.

Return: Promise<ImageBitmapSource>. Use .then(icon => { your code here }) to get the icon.

Throw: NetworkException. Use .catch(error => { your code here }) to get the error code and message.


loadPicture#

app.res.loadPicture(name, extension?);

Get app or stage specific picture, asynchronously. Supported format: JPEG, PNG, GIF, TIFF, and BMP.

Parameters:

  1. name: (string type) Picture name, without extension suffix (e.g. .jpg, .png, ...).
  2. extension: (string type, optional) Extension suffix. Default value is .jpg.

Return: Promise<ImageBitmapSource>. Use .then(picture => { your code here }) to get the picture.

Throw: NetworkException. Use .catch(error => { your code here }) to get the error code and message.


loadFont#

app.res.loadFont(name, extension?);

Get app or stage specific font, asynchronously. Supported format: TTF, OTF, and WOFF.

Parameters:

  1. name: (string type) Font file name, without extension suffix (e.g. .ttf, .otf, ...).
  2. extension: (string type, optional) Extension suffix. Default value is .ttf.

Return: Promise<ImageBitmapSource>. Use .then(fontObject => { your code here }) to get the font.

Throw: NetworkException. Use .catch(error => { your code here }) to get the error code and message.