3 Replies Latest reply on Jun 19, 2007 8:52 PM by arieljake@yahoo.com

    Mysterious Metadata error

      I have been using Flex 2 only a short few months, but I am familiar with how using custom events works. However, I am getting a compile error on a component for which I am trying to add a custom event. Here is the code:

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Canvas xmlns:mx="h t t p://www.adobe.com/2006/mxml">

      [Event(name="userSelected", type="events.UserEvent")]

      import mx.collections.XMLListCollection;
      import mx.collections.ArrayCollection;
      import events.UserEvent;
      import vo.UserVO;

      private var userList:ArrayCollection = new ArrayCollection();

      private var selectedUser:UserVO;
      private function editUser():void {
      selectedUser = userDataGrid.selectedItem as UserVO;
      var userEvent:UserEvent = new UserEvent(selectedUser, "userSelected");

      <mx:DataGrid id="userDataGrid" dataProvider="{userList}" top="0" left="0" right="0" bottom="30" />

      <mx:HBox id="userEditBox" left="0" right="0" verticalAlign="right" bottom="0">
      <mx:Button id="cancelButton" click="cancelEditUser()" />
      <mx:Spacer width="100%" />
      <mx:Button id="addUserButton" click="addUser()" />
      <mx:Button id="editUserButton" click="editUser()" />


      This code produces an "Only metadata is allowed" error in an arbitrary line inside the Script tag. I know this because I added, removed and commented ActionScript in the Script tag and the error stayed on the same line - even if it was just a comment line!

      Here's the kicker: When I remove the Spacer element I do not get the error!

      Has anyone else encountered this unusual error? Does anyone have an idea on how to resolve this problem? I need an answer soon.