少し心配です。すでにFXG形式で作成されたカスタムアイコンを使用してMenuBarコントロールを作成しようとしました。
プロジェクトフォルダ内の「assets.graphics.icons」に3つのFXGファイルがあります。
- src / Assets / graphics / icons / MenuIcon.fxg
- src / Assets / graphics / icons / ItemAIcon.fxg
- src / Assets / graphics / icons / ItemBIcon.fxg
次の2つのリンクと一連のWebページを読んだ後。
- http://blog.flexexamples.com/2010/01/29/displaying-icons-in-an-mx-menu bar-control-in-flex /
- http://livedocs.adobe.com/flex/3/html/help.html?content=menucontrols_3 .html
私はこのコードで終わった:
<?xml version="1.0" encoding="utf-8"?>
<!-- src/myMenuBarApplication.mxml -->
<mx:Application name="myMenuBarApplication"
xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:components="assets.graphics.icons.*">
<mx:MenuBar id="myMenuBar" iconField="@icon" labelField="@label" showRoot="true">
<fx:XMLList>
<menuitem label="Menu" icon="">
<menuitem label="Item A" icon="">
<menuitem label="SubItem A1"/>
<menuitem label="SubItem A2"/>
</menuitem>
<menuitem label="Item B" icon="">
<menuitem label="SubItem B1"/>
<menuitem label="SubItem B2"/>
</menuitem>
</menuitem>
</fx:XMLList>
</mx:MenuBar>
</mx:Application>
次のコードでタグを追加する任意の画像ファイルでそれを行うことができることを学びました
<mx:Script>
<![CDATA[
[Embed("assets/graphics/images/MenuIcon.png")]
public const MenuIconConst:Class;
]]>
</mx:Script>
次のように、MenuBarコントロールのアイコン属性に定数名を追加します。
だから私は運がなくてこれをやろうとしました:
<mx:Script>
<![CDATA[
import assets.graphics.icons.*;
[Bindable]
public var MenuIconVar:Class = new MenuIcon() as Class;
// MenuIcon is one of my FXG files inside assets.graphics.icons
]]>
</mx:Script>
Fxgファイルを埋め込むためのライブラリを作成し、それらをクラス名などとして使用する必要がある別のWebページを見つけましたが、それはよくわかりませんでした。
現実には、私はfxgコンポーネントのいずれかをMenuBarのアイコン属性内にさまざまな方法で配置しようとしていましたが、運がありませんでした。誰かがすでにこのようなものを作っていることを本当に願っています。助けていただければ幸いです。