目次

<include>

OpenLaszloのソースコードは1ファイルで完結できますが、複数のファイルに分割することもできます。<include>タグを使うと、他のファイルの内容をインクルードできます。

<include>には3種類の使い方があります:

  1. <library>ファイルのインクルード
  2. XMLファイルのインクルード
  3. テキストファイルのインクルード

href属性でインクルードするファイル名を指定します。ファイル名やディレクトリなどに特に制約はありません。

<library>ファイルのインクルード

この内容を表示するためには Adobe Flash Plugin が必要です。

myWindow.lzxという別ファイルをインクルードしています。

<?xml version="1.0" encoding="UTF-8"?>
<canvas proxied="false" bgcolor="0xeeeeee"> 
  <include href="myWindow.lzx"/>
  <myWindow/>
  <myWindow x="160"/>
</canvas>

myWindow.lzx:

<?xml version="1.0" encoding="UTF-8"?>
<library> 
  <class name="myWindow" extends="window"
   title="ウインドウ" width="150" height="100">
    <button>ボタン</button>
  </class>
</library>

XMLタグのインクルード

ファイルの中身が単に置換されているイメージですね。

この内容を表示するためには Adobe Flash Plugin が必要です。

<?xml version="1.0" encoding="UTF-8"?>
<canvas proxied="false" bgcolor="0xeeeeee"> 
  <window width="150" height="200" layout="axis:y">
     <include href="myButton.lzx"/>
     <include href="myButton.lzx"/>
     <include href="myButton.lzx"/>
     <include href="myButton.lzx"/>
     <include href="myButton.lzx"/>
  </window>
</canvas>

myButton.lzx:

<button>ボタン!</button>

テキストファイルのインクルード

<include>タグのtype属性でtextを指定すると、テキストファイル(XMLファイルではなく単なる文字列のファイル)をインクルードできます。

ファイルの中身が置換されているイメージです。

この内容を表示するためには Adobe Flash Plugin が必要です。

<?xml version="1.0" encoding="UTF-8"?>
<canvas proxied="false" bgcolor="0xeeeeee"> 
  <window width="200" height="100" layout="axis:y">
     <text>
        <include href="myText.txt" type="text"/>
     </text>
     <button>
        <include href="myText.txt" type="text"/>
     </button>
  </window>
</canvas>

myText.txt:

こんにちは。コンニチハ。