开发者

Flex error: could not resolve to a component implementation

I am trying to create a menu bar with the following items: File, Database, Navigate, Window. However, I am getting an error which I do not understand: Could not resolve <mx:XMLList> to a component implementation. Can anyone explai开发者_JAVA技巧n the error to me? My code is as follows: `

<mx:XMLList id="topLevelMenu">
     <menuitem label="File" />
     <menuitem label="Database"/>
     <menuitem label="Navigate"/>
     <menuitem label="Window" />
 </mx:XMLList>

 <mx:MenuBar width="100%" height="20" labelField="@label" id="mainMenuBar" dataProvider="{topLevelMenu}" />`

I googled for it and found a lot problems which generate this error message. None of them seemed to fit my case. When is this error generated?


The error means, basically, that the compiler can't find a component.

In this case, XMLList is not in the mx namespace. You didn't show the code where you import namespaces, but I assume you're using the default.

I suggest creating your XMLList in ActionScript, not MXML. I believe something like this should work:

public var topLevelMenu : XML =  <menuItems>
<menuitem label="File" />
     <menuitem label="Database"/>
     <menuitem label="Navigate"/>
     <menuitem label="Window" />
</menuItems>; 

Then somewhere, perhaps in a creationComplete Handler you can change this into an XMLList

var myList : XMLList = topLevelMenu.menuitem 

This code is written in the browser and untested.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜