我是Flash/Flex的新手。 我想使用我在Flash中創建的組件來擴展fl.core.UIComponent。我如何在Flex中使用它?我只是將它作爲swc導出,還是必須使用Flash Flex 3工具包將其轉換爲UIMovieClip。這聽起來不對。如何在Flex中使用UIComponent/Flash
我希望通過幾個簡單的步驟來描述這個過程。 謝謝 Sanoran
我是Flash/Flex的新手。 我想使用我在Flash中創建的組件來擴展fl.core.UIComponent。我如何在Flex中使用它?我只是將它作爲swc導出,還是必須使用Flash Flex 3工具包將其轉換爲UIMovieClip。這聽起來不對。如何在Flex中使用UIComponent/Flash
我希望通過幾個簡單的步驟來描述這個過程。 謝謝 Sanoran
只需將.as文件導入到您的flex應用程序中。使用rawChildren.addChild
而不是簡單的addChild
將其添加到顯示列表中,因爲flex會覆蓋默認的addChild
方法以僅接受mx.core.UIComponent
及其派生類。
更新:您不能在flex中使用FLA,因此如果您的組件不僅僅是一個擴展fl.core.UIComponent的AS類,您應該將其導出到SWC或在運行時將相應的SWF加載到flex應用程序。
您可以將文件發佈爲.swf並使用SWFLoader加載它,只需記住路徑與您的運行/調試目錄相關。
我的理解是,swc文件通常是庫文件,而不是可視化組件,因爲您希望庫在編譯時(swc)而不是在運行時(swf)包含。
var loader = new SWFLoader();
// set autoload to false just so we KNOW when it loads. Also prevents
// us from accidently loading it twice by calling load() later
loader.autoLoad = false;
loader.addEventListener(Event.INIT, function (nt:Event) {
// Remove event listener so can be garbage collected
event.currentTarget.removeEventListener(event.type, arguments.callee);
// note we can the loader, rather than
// loader.content
someIVisualElementContainer.addElement(loader);
});
// relative to bin-debug or bin-release
loader.source = "movie.swf";
loader.load();
但請注意,如果以這種方式執行此操作,則無法使用Flash IDE創作可視組件。 IE,沒有.fla文件。 – timoxley 2009-10-09 07:02:02
反正你不能在flex中使用fla,你能嗎? – Amarghosh 2009-10-09 07:08:53
我以爲OP在問使用AS類擴展核心組件。如果它包含FLA,則應該導出爲SWC或在運行時加載SWF。 – Amarghosh 2009-10-09 07:11:01