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);开发者_C百科
}
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
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 the Class
of an instance of an object, you can do it like this:
var viewClass = Class(getDefinitionByName(getQualifiedClassName(IM)));
Then, you can pass viewClass
into pushView()
where it will create a NEW view for you.
精彩评论