我試圖用這種方式設置背景圖像,但它不起作用。任何想法如何儘可能容易地設置富文本控件的背景圖像?由於如何在Flex 4中設置RichTextEditor的背景圖像
.rte{
...
backgroundImage: "assets/globe.jpg";
}
和
<mx:RichTextEditor id="rt"
...
styleName="rte"
/>
我試圖用這種方式設置背景圖像,但它不起作用。任何想法如何儘可能容易地設置富文本控件的背景圖像?由於如何在Flex 4中設置RichTextEditor的背景圖像
.rte{
...
backgroundImage: "assets/globe.jpg";
}
和
<mx:RichTextEditor id="rt"
...
styleName="rte"
/>
不幸的是,你不能。
The docs for RichTextEditor表明它不支持backgroundImage屬性,並且該組件不可換膚。
因此,我建議創建自己的包裝組件,它接受的圖像,像這樣:
<!-- Note: Using Canvas becuase your post indicates Flex 3, if using Flex 4, please use Group -->
<Canvas>
<mx:Image width="100%" height="100%" />
<RichTextEditor />
</Canvas>
的RichTextEditor
組件不支持背景圖片上次我檢查。你想要做的是創建一個自定義RTE皮膚,你在實際文本後面添加一個圖像,然後在皮膚內部,執行getStyle('backgroundImage')
並將其設置爲可綁定的私有變量,然後綁定到圖像。
就是這樣。它可以使用這種皮膚,也可以將RTE包裝在BitmapImage
或其他支持背景圖像的組件中。
編輯:對不起,沒有看到這是Flex3。在這種情況下,您需要擴展RTE組件並手動添加Image組件,方法是重寫createChildren
函數,然後通過使用上述函數使用相同的getStyle
函數覆蓋updateDisplayList
函數來更改圖像的值。
它可以通過設置RTE 文本區域的backgroundAlpha需做
<mx:RichTextEditor id="richTextEditor"
backgroundImage="@Embed('<imagepath>')" width="100%" height="100%"
initialize="{richTextEditor.textArea.setStyle('backgroundAlpha', '0') }"
/>
注:請修改圖片的路徑,你也可以通過CSS/Style標籤設置樣式
希望這將有助於