问题描述
|
我试图将使用MXML来描述视图的Flex移动应用程序更改为使用AS3创建视图的应用程序。我变了:
之前:Assessments.mxml
<?xml version=\"1.0\" encoding=\"utf-8\"?>
<s:MobileApplication xmlns:fx=\"http://ns.adobe.com/mxml/2009\"
xmlns:s=\"library://ns.adobe.com/flex/spark\" firstView=\"view.LoginView\">
<fx:Declarations>
<!-- Place non-visual elements (e.g.,services,value objects) here -->
</fx:Declarations>
</s:MobileApplication>`
之后:评估
package {
import spark.components.MobileApplication;
import view.LoginView;
[SWF(height=\"600\",width=\"1024\",frameRate=\"30\",backgroundColor=\"#FFFFFF\")]
public class Assessments extends MobileApplication{
public function Assessments(){
super();
super.firstView = view.LoginView;
}
}
}
但是,现在我得到了错误:
TypeError: Error #1007: Instantiation attempted on a non-constructor.
at mx.preloaders::Preloader/initialize()[E:\\dev\\hero_private_beta\\frameworks\\projects\\framework\\src\\mx\\preloaders\\Preloader.as:258]
at mx.managers::SystemManager/http://www.adobe.com/2006/flex/mx/internal::initialize()[E:\\dev\\hero_private_beta\\frameworks\\projects\\framework\\src\\mx\\managers\\SystemManager.as:1977]
at mx.managers::SystemManager/initHandler()[E:\\dev\\hero_private_beta\\frameworks\\projects\\framework\\src\\mx\\managers\\SystemManager.as:2479]
我相信这可能与.as版本中未设置的命名空间有关吗?有任何想法吗?
更新
package view
{
import flash.display.Sprite;
import flash.events.MouseEvent;
import net.airpoint.northgate.ui.components.AirpointNumericTextField;
import qnx.events.QNXApplicationEvent;
import qnx.system.QNXApplication;
import spark.components.Button;
import spark.components.Form;
import spark.components.Formheading;
import spark.components.FormItem;
import spark.components.Label;
import spark.components.TextInput;
import spark.components.View;
public class LoginView extends View
{
private var form:Form;
private var usernameLabel:Label;
private var usernameField:AirpointNumericTextField;
private var passwordLabel:Label;
private var passwordField:TextInput;
private var submit:Button;
// public var menu:AirpointAppMenu;
public function LoginView()
{
// menu = new AirpointAppMenu();
// QNXApplication.qnxApplication.addEventListener(QNXApplicationEvent.SWIPE_DOWN,showAppMenu);
initializeUI();
}
public function showAppMenu(event:QNXApplicationEvent):void{
// menu.show();
}
public function initializeUI():void{
form = new Form();
this.submit = new Button();
this.submit.label = \"Login...\";
form.defaultButton = this.submit;
// heading
var fh:Formheading = new Formheading();
fh.label = \"Login\";
form.addElement(fh);
// Username
this.usernameField = new AirpointNumericTextField();
var f1:FormItem = new FormItem();
f1.label = \"Username\";
f1.addElement(this.usernameField);
// Password
this.passwordField = new Textinput();
this.passwordField.displayAsPassword =true;
var f2:FormItem = new FormItem();
f2.label = \"Password\";
f2.addElement(this.passwordField);
form.addElement(f1);
form.addElement(f2);
form.addElement(this.submit);
this.addElement(form);
}
}
}
更新3
评估应用
package {
import mx.events.FlexEvent;
import mx.styles.CSsstyleDeclaration;
import spark.components.Group;
import spark.components.MobileApplication;
import views.AssessmentsAppHome;
[SWF(height=\"600\",backgroundColor=\"#000\")]
public class AssessmentsApp extends MobileApplication{
public function AssessmentsApp(){
super();
this.addEventListener(FlexEvent.APPLICATION_COMPLETE,onAppComplete);
}
private function onAppComplete(e:FlexEvent):void
{
this.removeEventListener(FlexEvent.APPLICATION_COMPLETE,onAppComplete);
firstView = views.AssessmentsAppHome;
}
}
}
评估AppHome.mxml
<?xml version=\"1.0\" encoding=\"utf-8\"?>
<s:View xmlns:fx=\"http://ns.adobe.com/mxml/2009\"
xmlns:s=\"library://ns.adobe.com/flex/spark\" title=\"Home\">
<fx:Declarations>
<!-- Place non-visual elements (e.g.,value objects) here -->
</fx:Declarations>
<s:VGroup>
<s:TextInput text=\"awdwdawd\"/>
</s:VGroup>
</s:View>
错误
Preloader.as(displayClass = new ...上失败)
// Create a new instance of the display class and attach it to the stage
if (showdisplay)
{
displayClass = new displayClassName();
// Listen for when the displayClass no longer needs to be on the stage
displayClass.addEventListener(Event.COMPLETE,displayClassCompleteHandler);
解决方法
您应该扩展
Sprite
(而不是MobileApplication
)。请参阅以下链接。
,尝试以下方法:
package {
import spark.components.MobileApplication;
import view.LoginView;
[SWF(height=\"600\",width=\"1024\",frameRate=\"30\",backgroundColor=\"#FFFFFF\")]
public class Assessments extends MobileApplication{
public function Assessments(){
super();
this.addEventListener(FlexEvent.APPLICATION_COMPLETE,onAppComplete);
}
private function onAppComplete(e:FlexEvent):void
{
this.removeEventListener(FlexEvent.APPLICATION_COMPLETE,onAppComplete);
firstView = LoginView;
}
}
尝试在构造函数中访问ViewNavigator时可能尚未实例化。