Quantcast
Channel: Forums - ArcGIS Viewer for Flex
Viewing all articles
Browse latest Browse all 2097

Controlling widgets from HeaderControllerWidget

$
0
0
Hello,

I have a very customized HeaderControllerWidget to provide a very specific type of interface. As part of this I have a few short cut links placed in the header itself that basically provide quick access/population to certain widgets.

My problem is that if the widget isn't already open, I don't seem to be able to get ahold of the correct event listener to wait for the widget to finish loading. Code example:

Code:

widgetID = ViewerContainer.getInstance().widgetManager.getWidgetId("widgetName");
iWidget = ViewerContainer.getInstance().widgetManager.getWidget(widgetID,true);
        if(!iWidget)
        {
                var timer:Timer = new Timer(1000,1);
                timer.start();
                timer.addEventListener(TimerEvent.TIMER_COMPLETE, completeHandler);
                function completeHandler(event:TimerEvent):void
                {
                        addSharedData("popUser", new ArrayCollection([userData.text]));
                        timer.stop();
                }
        }
        else
                addSharedData("popUser", new ArrayCollection([userData.text]));

So as you can see, as sort of a hack to get it working I have a timer delay inserted in the code if the widget is not already loaded. The problem is that without the timer delay, if the widget is not already loaded, the getWidget returns null. So I can't seem to get access to the widget object to add an event listener until it's loaded (at which point I no longer need an event listener).

The other option is I could have the widgets preload and just not have them visible. However, again that feels kind of hacky.

Any other suggestions?

Viewing all articles
Browse latest Browse all 2097