0
我已經創建了一個菜單,但是當它在菜單上單擊以顯示時,由於行「myMenu.show(null,null)」,我得到一個錯誤。請參見下面的功能:Flex 4菜單錯誤
private function createAndShowmyMenu():void {
myMenu = Menu.createMenu(null, myMenuDataProvider, false);
myMenu.labelField="@label"
myMenu.setStyle("fontSize","10");
//Event Listeners Here
myMenu.show(null,null);
}
的錯誤是這樣:
TypeError: Error #1007: Instantiation attempted on a non-constructor.
at mx.controls.menuClasses::MenuItemRenderer/commitProperties()[E:\dev\4.x\frameworks\projects\framework\src\mx\controls\menuClasses\MenuItemRenderer.as:469]
at mx.core::UIComponent/validateProperties()[E:\dev\4.x\frameworks\projects\framework\src\mx\core\UIComponent.as:7933]
at mx.managers::LayoutManager/validateClient()[E:\dev\4.x\frameworks\projects\framework\src\mx\managers\LayoutManager.as:863]
at mx.controls::List/http://www.adobe.com/2006/flex/mx/internal::setupRendererFromData()[E:\dev\4.x\frameworks\projects\framework\src\mx\controls\List.as:1706]
at mx.controls::Menu/measureWidthOfItems()[E:\dev\4.x\frameworks\projects\framework\src\mx\controls\Menu.as:1322]
at mx.controls::List/commitProperties()[E:\dev\4.x\frameworks\projects\framework\src\mx\controls\List.as:906]
at mx.controls::Menu/commitProperties()[E:\dev\4.x\frameworks\projects\framework\src\mx\controls\Menu.as:1244]
at mx.core::UIComponent/validateProperties()[E:\dev\4.x\frameworks\projects\framework\src\mx\core\UIComponent.as:7933]
at mx.managers::LayoutManager/validateClient()[E:\dev\4.x\frameworks\projects\framework\src\mx\managers\LayoutManager.as:863]
at mx.managers::PopUpManagerImpl/addPopUp()[E:\dev\4.x\frameworks\projects\framework\src\mx\managers\PopUpManagerImpl.as:384]
at mx.managers::PopUpManager$/addPopUp()[E:\dev\4.x\frameworks\projects\framework\src\mx\managers\PopUpManager.as:193]
at mx.controls::Menu/show()[E:\dev\4.x\frameworks\projects\framework\src\mx\controls\Menu.as:1648]
任何人有這樣的想法?
我確實通過了文檔,但是您知道我的代碼在FLEX 3中創建菜單時沒有指定displayObject,但它沒有在Flex 4中出現,並且文檔沒有在任何地方說出區別所在。 但是,感謝您的糾正,它像一個魅力。 – FlexyBoz
該文檔說明參數是非可選的(即非空)。我不確定爲什麼它在Flex 3中不起作用,但如果不應該的話。 –