我正在尝试创建一个添加用户新User()的简单表单。但是当我构建它时,我在同一行上得到两个错误。
调用可能未定义的方法User。和类型未找到或是 不是编译时常量。
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" width="1116" height="633" initialize="windowedapplication1_initializeHandler(event)">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import me.*;
var usercollection:Array = new Array();
var userOne:User = new User;
protected function button1_clickHandler(event:MouseEvent):void
{
userOne.fname = firstNameInput.text;
userOne.lname = lastNameInput.text;
userOne.dob = dateChooser.selectedDate;
usercollection.push();
}
]]>
</fx:Script>
<mx:DataGrid x="832" y="9">
<mx:columns>
<mx:DataGridColumn headerText="First Name" dataField="fname"/>
<mx:DataGridColumn headerText="LastName" dataField="lname"/>
</mx:columns>
</mx:DataGrid>
<mx:Form x="115" y="61" width="562" height="325">
<mx:FormItem label="First Name">
<s:TextInput id="firstNameInput"/>
</mx:FormItem>
<mx:FormItem label="Last Name">
<s:TextInput id="lastNameInput"/>
</mx:FormItem>
<mx:FormItem label="Date Of Birth">
<mx:DateChooser id="dateChooser"/>
</mx:FormItem>
<s:Button label="Submit" click="button1_clickHandler(event)"/>
</mx:Form>
</s:WindowedApplication>
实体包
package me.entities
{
public class Person
{
public var fname:String;
public var lname:String;
public var dob:Date;
}
public class User extends Person
{
public var crypted_password:String;
public var salt:String;
public var created_at:Date;
public var last_login:Date;
public var last_ip:String;
}
}
答案 0 :(得分:1)
您不能在同一.as文件中有两个公共类定义,并注意该文件必须与其中的公共类具有相同的名称。
在你的情况下,你将有2个文件,一个名为Person.as,另一个名为User.as.你必须
Person.as
package me.entities
{
public class Person
{
public var fname:String;
public var lname:String;
public var dob:Date;
}
}
User.as
package me.entities
{
public class User extends Person
{
public var crypted_password:String;
public var salt:String;
public var created_at:Date;
public var last_login:Date;
public var last_ip:String;
}
}