ガジェット定義ファイルの作り方
GIZMOはガジェット定義ファイルによってガジェットを認識します。 ガジェット定義ファイルの内容に不備があると、ガジェットとして認識されなかったり意図しない動作をしたりする場合があります。
ガジェット定義ファイルには、構造の異なる2つのバージョンがあります。 ActionScript 2.0での制作にはバージョン1.0を、ActionScript 3.0での制作にはバージョン 2.0を使用してください。
バージョン2.0の場合は、Flash CS3の[コマンド]メニューから[GIZMO - ガジェット定義ファイルの書き出し]を選択し、基本的なガジェット定義ファイルを作成することができます。 このコマンドは、ActionScript 3.0用GIZMOコンポーネント(ver 2.1.1以降)をインストールすることで追加されます。
参照:XMLの要素の詳細については、「ガジェット定義ファイル 1.0」と「ガジェット定義ファイル 2.0」を参照してください。
gadget.xml作成時の注意事項
文字コード
文字コードはUTF-8を使用します。そのためXML宣言の部分は次のようにしておきます。
<?xml version="1.0" encoding="UTF-8"?>
保存場所
gadget.xmlはガジェット用SWFファイルとともに必ずガジェット フォルダ内に保存してください。
スタンドアローン ガジェット用サンプル
最小構成(コンテキスト メニューに「閉じる」のみ表示)
▼バージョン1.0
<?xml version="1.0" encoding="UTF-8" ?> <gadget type="standalone" version="1.0"> <swf type="main">sample.swf</swf> <title>サンプルガジェット</title> <author>GIZMO Project</author> </gadget>
▼バージョン2.0
<?xml version="1.0" encoding="UTF-8" ?>
<gadget xmlns="http://gizmo.anthill.jp/gadget/2.0" version="1.0">
<content src="sample.swf" />
<title>サンプルガジェット</title>
<author>GIZMO Project</author>
<description>ガジェットのサンプルです。</description>
<menu>
<close label="閉じる" />
</menu>
</gadget>
コンテキスト メニューに「閉じる」「前面固定」「設定」「ヘルプ」を表示
▼バージョン1.0
<?xml version="1.0" encoding="UTF-8" ?>
<gadget type="standalone" version="1.0">
<swf type="main">sample.swf</swf>
<title>サンプルガジェット</title>
<author>GIZMO Project</author>
<menu>
<fix>true</fix>
<config filename="config.html">true</config>
<help url="http://gizmo.anthill.jp/tutorial/">true</help>
</menu>
</gadget>
▼バージョン2.0
<?xml version="1.0" encoding="UTF-8" ?>
<gadget xmlns="http://gizmo.anthill.jp/gadget/2.0" version="1.0">
<content src="sample.swf" />
<title>サンプルガジェット</title>
<author>GIZMO Project</author>
<description>ガジェットのサンプルです。</description>
<menu>
<close label="閉じる" />
<alwaysInFront label="前面固定" />
<config label="設定" fileName="config.html" />
<link label="ヘルプ" url="http://gizmo.anthill.jp/tutorial/" />
</menu>
</gadget>
レイヤード ガジェット用サンプル
最小構成(1つの子レイヤーを使用)
▼バージョン1.0
<?xml version="1.0" encoding="UTF-8"?> <gadget type="layered" version="1.0"> <swf type="main">sample.swf</swf> <swf type="layered_child" offsetX="10" offsetY="79" name="layer">layer.swf</swf> <title>サンプルガジェット</title> <author>GIZMO Project</author> </gadget>
▼バージョン2.0
<?xml version="1.0" encoding="UTF-8" ?>
<gadget xmlns="http://gizmo.anthill.jp/gadget/2.0" version="1.0">
<content src="sample.swf">
<layer offsetX="10" offsetY="79" name="layer" src="layer.swf" />
</content>
<title>サンプルガジェット</title>
<author>GIZMO Project</author>
<description>ガジェットのサンプルです。</description>
</gadget>
子レイヤーでの注意点
上記XMLのように、バージョン1.0の場合はgadget要素のtype属性に"layered"を指定します。 その上で親レイヤー用のswf要素のtype属性には"main"を、子レイヤー用のswf要素のtype属性には"layered_child"を指定してください。 指定が間違っていると正しく表示されません。 バージョン2.0の場合、gadget要素にtype属性はありません。 content要素の子としてlayer要素を追加てください。
子レイヤーのオフセット位置は、親レイヤーのステージ左上を基準とします。 指定した座標に子レイヤーのステージ左上が来るよう配置されます。 負の値等を設定して親レイヤーのエリア外に配置することも可能ですが、子レイヤーのステージは透過されない点に注意してください。 子レイヤーを複数使用したい場合は、要素をその分だけ記述します。 ただし、1つのガジェットで子レイヤーを複数使うと表示負荷が高くなります。
▼バージョン1.0
<?xml version="1.0" encoding="UTF-8" ?> <gadget type="layered" version="1.0"> <swf type="main">sample.swf</swf> <swf type="layered_child" offsetX="10" offsetY="79" name="layer0">layer0.swf</swf> <swf type="layered_child" offsetX="20" offsetY="79" name="layer1">layer1.swf</swf> <swf type="layered_child" offsetX="30" offsetY="79" name="layer2">layer2.swf</swf> <title>サンプルガジェット</title> <author>GIZMO Project</author> </gadget>
▼バージョン2.0
<?xml version="1.0" encoding="UTF-8" ?>
<gadget xmlns="http://gizmo.anthill.jp/gadget/2.0" version="1.0">
<content src="sample.swf">
<layer offsetX="10" offsetY="79" name="layer0" src="layer0.swf" />
<layer offsetX="20" offsetY="79" name="layer1" src="layer1.swf" />
<layer offsetX="30" offsetY="79" name="layer2" src="layer2.swf" />
</content>
<title>サンプルガジェット</title>
<author>GIZMO Project</author>
<description>ガジェットのサンプルです。</description>
</gadget>
その他の設定はスタンドアローン ガジェットの場合と同じです。
