<resource>
A tag that defines a media object that can be associated with a view.

This tag defines a media object, that can be presented within a view. A media object is an image, movie, animation, or sound clip. This tag imports the object into the application, and binds it to a string which can be used within a view. For example:

<canvas height="70">
  <resource name="logo" src="../images/logo.png"/>
  <view resource="logo"/>
</canvas>

The src attribute refers to the filename of any valid resource type, including an optional directory path relative to the directory of the declaration. Valid resource types for images and animations include: .SWF, .PNG, .JPG, and .GIF; valid audio types include: .MP3.

The offsetx and offsety attributes (SWF10 only) allow you to specify an offset of a bitmap resource used for a custom cursor, so that the mouse will align with the proper 'hotspot' in the cursor image.

Example: set a custom crosshair cursor from a bitmap resource, with an offset of (-8,-8)

  <resource name="crosshair" src="cursor_crosshair.png" offsetx="-8" offsety="-8" />
  <view height="40" bgcolor="#cccccc" width="100" cursor="crosshair" />

Audio resources must be MP3 files at one of the following sample rates: 11.025 khz, 22.5 khz, and 44.1 khz, and encoded at no more than 160kbps.

The dataimage example further demonstrates the use of the resource tag.

For details on multi-frame resources, see frame.

Attributes

Name (CSS property) Type (tag) Type (js) Default Category
name token     initialize-only
  The name of a variable that will be set to this object when the application is started. If this element is directly within a canvas or library element, the global variable and the canvas property with this name will be set to this object. If this element is within another object, that object's property with this name will be set to this object.
offsetx Number     initialize-only
  The x offset of a bitmap resource used for a custom cursor.
offsety Number     initialize-only
  The y offset of a bitmap resource used for a custom cursor.
src URL     initialize-only
  The path of a file that contains the source for this object.