Select to view content in your preferred language

Widget State Reset

836
2
02-14-2011 10:38 PM
PeterDay
Emerging Contributor
Hi

I have written a widget which has a number of view states. It is designed to be a "wizard" to step you through a process. All works fine.

My problem is that if the wizard has been run once (either to its natural end or cancelled part way) and then closed, the next time it is opened it is still on the last used step (ie state page). I have not found a way to force the state back to the first.

A good simple example of my problem is shown by the Bookmarks example which has the 2 states: the "List of Bookmarks" and the "Add a New Bookmark". Change to the latter of these states, close the widget then re-open to see it is still on the Add page.

Essentially the close only minimizes the widget. Reopening it does not rerun the Init function.

Can anyone provide a bit of code that will be run whenever the widget is re-shown to get the state back to the first page?

Thank you in advance
Tags (2)
0 Kudos
2 Replies
IvanBespalov
Frequent Contributor
Each widget has 3 states and 3 events by default
package com.esri.viewer
{
        // imports here

        [Event(name="open", type="flash.events.Event")]
 [Event(name="minimized", type="flash.events.Event")]
 [Event(name="closed", type="flash.events.Event")]
 
 [SkinState("open")]
 [SkinState("minimized")]
 [SkinState("closed")]
 
 public class WidgetTemplate extends SkinnableContainer implements IWidgetTemplate
 {}
}


in your widget handle events
<fx:Script>
<![CDATA[
        /**
         * Listen widget template close handler
         */
        protected function closedHandler(event:Event):void
        {
                trace("closedHandler() start");
                // do somthing
                trace("closedHandler() stop");   
        }
   
        /**
         * Listen widget template open handler
         */
        protected function openHandler(event:Event):void
        {
                trace("openHandler() start");
                wTemplate.widgetTitle = "New Tilte";
                wTemplate.selectedTitlebarButtonIndex = -1;
                trace("openHandler() stop");
        }
   
        /**
         * Listen widget template minimize handler
         */
        protected function minimizeHandler(event:Event):void
        {
                trace("minimizeHandler() start");
                // do somthing
                trace("minimizeHandler() stop");
        }
]]>
</fx:Script>
<viewer:WidgetTemplate id="wTemplate"
          closed="closedHandler(event)" 
          open="openHandler(event)"
          minimized="minimizeHandler(event)">
0 Kudos
PeterDay
Emerging Contributor
Ivan, thankyou. The openHandler event turned out to be the best one for me
0 Kudos