Frame

出自OpenFace

跳转到: 导航, 搜索

<frame>

A frame of a multi-frame resource. The <frame> tag is used to define a single frame of a multi-frame <resource>. A multi-frame resource contains several images which can be toggled among by script commands. For example:

Example 1. A resource with two frames

<resource name="mfr">
 <frame src="f1.jpg"/>
 <frame src="f2.jpg"/>
</resource>

Multiple frame tags can be declared consecutively to produce a single resource constructed of an unlimited number of frames. Such composed resources are often used to conveniently implement mouse rollovers, button states, or other UI elements where alternate views of a resource are required. Once a multi-frame resource has been defined and presented within a LzView, the developer can designate which frame is actively visible through the use of the view's setResourceNumber method.

Multi-frame resources can be used in conjunction with components such as basebutton and multistatebutton, which pre-define complex button behavior using frames designated by the user.

The following example manually implements a simple button with mouse rollover and down state behavior:

<canvas > 
    <resource name="myrsrc"> 
        <frame src="app.gif"/> 
        <frame src="cg.gif"/> 
        <frame src="error.gif"/>
     </resource>
     <view id="v" resource="myrsrc"> 
        <handler name="onkeydown" reference="LzKeys"> 
           v.setResourceNumber(2);
        </handler>
     </view>  
</canvas>

Attributes

Name     Usage     Type(Tag)     Type(JS)      Default     Category

name     Tag only    token                        final

      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.



src      Tag only URL                            final

       The path of a file that contains the source for this object.