Reputation: 26169
I'm trying to create a simple form that adds a user new User(). But when I build it I get two errors on the same line.
Call the possibly undefined method User. and Type was not found or was not a compile time constant.
<?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>
Entities package
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;
}
}
Upvotes: 0
Views: 122
Reputation: 1075
You can't have two public class definitions in the same .as file and note that the file must have the same name as the public class inside.
In your case you'll have 2 files, one named Person.as and the Other named User.as. You'll have to
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;
}
}
Upvotes: 1