The frame Tag

The frame tag is used within the resource tag to define a single frame of a multiframe resource. The attributes of the frame tag are presented in Table 2.17.

Table 2.17. The frame tag’s attributes
NameUsageTypeDefaultAccessibility
nameTag onlystring final
 Description. An identifier for this frame.
srcTag onlystring final
 Description. The URL to an external file to be associated with this frame.

The LZX application in Listing 2.15 shows how to use the resource tag with two frames.

Listing 2.15. Using frames
<canvas>
    <resource name="arrow">
        <frame src="arrow1.gif"/>
        <frame src="arrow2.gif"/>
    </resource>

    <view resource="arrow"
        onmousedown="setResourceNumber(2)"
        onmouseup="setResourceNumber(1)"
    />
</canvas>

The view tag in Listing 2.15 is linked to the resource tag named arrow. The setResourceNumber method accepts an index number and assigns the frame at the specified index to the view. As a result, when you click the view, the second frame will be used. When you release the mouse, the first frame is used.

To test the application, direct your browser to this URL:

http://localhost:8080/lps-4.0.x/app02/frameTest1.lzx

The result is shown in Figure 2.20.

Figure 2.20. Using frames


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset