PDA

View Full Version : trying to convert this function


stargatesg1
05-23-2008, 01:13 AM
Trying to convert this function so i can put it in a class

//To change views need to call this function//
public function goToViews(view:String):void
{
if(view == "dash")
{
this.myViewStack.selectedChild=this.dashboard;

}
}

Here is what i was trying to convert it to


//To change views need to call this function//
public function goToViews(view:String,vstk:ViewStack,viewComponent :Comp):void
{
if(view == "dash")
{
//this.myViewStack.selectedChild=this.dashboard;
vstk.selectedChild=viewComponent.toString();

}
} // End goTOViews

But i am not sure what object type viewComponent should be that is all..

drkstr
05-23-2008, 03:41 PM
ViewStack.selectedChild is a Container type, so that would probably be your best bet.

Why do you have a toString() at the end?

Best Regards,
~Aaron

stargatesg1
05-23-2008, 04:38 PM
Basically viewComponent:Comp i am not sure what object type to make it. This will basically be the object of the different screens you want to change in the view stack.

so in your project you can have the following components

components
----------->home.mxml
------------>about.mxml
------------>contact.mxml

drkstr
05-23-2008, 06:04 PM
The children of a ViewStack should all inherit the Container class, so this is what type you should make it. If you want to get real specific you can make a subclass that extends Container (or some other Container based class) then make all your components an instance of that class. However, most likely you will be fine with just setting it as Container and not worrying about it.

You should not set it using the .toString() method since this would be assigning a String value to a property expecting a Container.


Best Regards,
~Aaron