如何在 Flash Builder 4 Hero SDK 中将变量分配为类
我试图将一个变量分配给视图导航,如下所示:
protected function list_clickHandler(event:MouseEvent):void
{
var name1:String = list.selectedItem.vPage;
var name2:Object = list.selectedItem.vPage.valueOf();
navigator.pushView(list.selectedItem.vPage.valueOf(), list.selectedItem);
}
该变量应该是视图,例如它可以正常工作,如下所示:
navigator.pushView(IM, list.selectedItem);
由于视图显示为静态而不是变量。当您尝试将其作为任何格式(字符串、对象)的变量提交时,会发生错误。
Error #1034: Type Coercion failed: cannot convert "IM" to Class.
因此,如果有人对如何将 (View)Class 作为变量发送有任何想法,或者这是 SDK 中的错误
I am trying to assign a variable to a view navigation as follows:
protected function list_clickHandler(event:MouseEvent):void
{
var name1:String = list.selectedItem.vPage;
var name2:Object = list.selectedItem.vPage.valueOf();
navigator.pushView(list.selectedItem.vPage.valueOf(), list.selectedItem);
}
The variable is supposed to be the view for instance it works fine as follows:
navigator.pushView(IM, list.selectedItem);
As the View is presented as a static and not a variable. When you try to submit it as a variable in any format (String, Object) an error occurs.
Error #1034: Type Coercion failed: cannot convert "IM" to Class.
So if anyone has any ideas on how I can send the (View)Class as a variable or if this is a bug in the SDK
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不,这不是 SDK 中的错误。您传入一个类,
viewNavigator
将为您构建它。如果你想获取一个对象实例的Class
,你可以这样做:然后,你可以将
viewClass
传递给pushView()< /code> 它将在其中为您创建一个新视图。
No, this is not a bug in the SDK. You pass in a class, and the
viewNavigator
will construct it for you. If you want to get the theClass
of an instance of an object, you can do it like this:Then, you can pass
viewClass
intopushView()
where it will create a NEW view for you.