views:

265

answers:

1

Hi,

I am a beginner developer in Flex, and I have been using viewstates lately. I had a couple of custom popup titlewindow components that are initialized using:

PopUpManager.createPopUp(this, ContentCreate, true);

They both contain view states already, and are very similar so I wanted to combione them into one popup titlewindow and change view state on initialisation of the popup to either the Create version of the popup or the Update.

I thought I was being smart haha, but I realized soon after refactoring my code that, I as far as I know I can't pass parameters to the popup to indicate which state I want, if it is created using the PopUpManager.

Does anyone know how to pass parameters to the PopupManager, or create the ContentCreate component(TitleWindow) in mxml or code so I can specify the view state?

A: 

When you create a pop up window using the createPopUp method a reference to the created window is returned. Example:

pop = mx.managers.PopUpManager.createPopUp(this, TitleWindow, false);

You can create a public setState function to tell the new popup window which state to display.

pop = mx.managers.PopUpManager.createPopUp(this, TitleWindow, false);
pop.setDisplay('Update');

Your example would be more like:

var pop:ContentCreate;
pop = PopUpManager.createPopUp(this, ContentCreate, true) as ContentCreate;
pop.setState('Update');

This should work.

More information can be found here.

Hope this helps.

JustFoo