1 Reply Latest reply on Aug 4, 2007 9:17 AM by T Rollins

    How to "reset" a component

    T Rollins Level 1
      (re-posted from flexcoders)

      I have an interactive presentation (first time I've attempted this sort of thing with Flex), which is based on layers of canvases, holding viewstacks, holding canvases. Sort of [Main app][Sections][Subsections]

      I'm using showEffect= on various stages of the display, and writing sets of effects to manage various animated transitions.

      The problem seems to be that once Flex displays something, it maintains the state of that thing, even if the item is no longer visible on the stage... so of course, when I return to a subsection's viewstack, it is left on the previous selectedChild, etc. I can deal with that OK, but so far, I've been unable to come up with an elegant way to get the child objects back to their originally defined state. I'd like to make it so that each and every time a "slide" is displayed, it runs the showEffect(), and builds out the animation like it does the first time.

      I've tried removing the viewstack and re-adding it, but that only removes it from the display list, and does not re-initialize the entire object the way I'd like.

      Do I really need to manually put everything back via AS or a convoluted "reverse effect"? (It is a lot of stuff.) I'm really hoping there is some way to just say "act like you've never been displayed" - you know, like it would be if you left and then returned to a section of the Flash timeline.

      Suggestions? Will this only work if I instantiate my components through AS, so that they can be more fully removed by removing them from the displaylist and nulling the var... only to be recreated the next time the user visits that section of the presentation? Is there a more flex-like way to reset my component's state and get showEffects to work a second time, etc.?


        • 1. Re: How to "reset" a component
          T Rollins Level 1
          Well, in my experiments so far, the technique of adding and removing the "slide" components dynamically through AS have been the most effective way to get a clean "replay" of the component's animated effects, but I'm wondering if anyone can suggest a more flex-like way of doing this. Is it not possible to have a component reset to a default state without actually destroying it and recreating it via AS?