Gerard Brandon
Gerard Brandon

Reputation: 23

How to assign variable as class in Flash Builder 4 Hero 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

Upvotes: 1

Views: 961

Answers (1)

Brian Genisio
Brian Genisio

Reputation: 48137

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.

Upvotes: 2

Related Questions