5 Replies Latest reply on Jul 1, 2013 11:13 AM by Haravikk

    How to Ensure Symbol State Persists?

    Haravikk Level 1

      Okay, so I have a symbol that I want to show/hide; it's a named MovieClip with two labelled frames ("show" and "hide" in that order), the default is to be shown, and both frames have a stop() command.

      This seems fine however at one point in my animation I trigger the symbol to hide via foo.gotoAndStop("hide"), but when the animation loops the symbol reappears (or rather, returns to the "show" frame).

       

      Now, obviously this is annoying, but other symbols that function in the exact same way appear to be working as expected, so I'm at a complete loss as to why this one symbol in particular seems to be resetting? Is there some characteristic of the animation that might be causing Flash to see the symbol as if it were a new instance? I've checked that the symbol's name is constant throughout the animation, and I'm really only using classic tweens; certainly nothing that stands out as different in way compared to the other, working symbols.

       

      Aside from completely re-creating the animation for that symbol I'm not sure what else I can try, so any suggestions are welcomed!

        • 1. Re: How to Ensure Symbol State Persists?
          Ned Murphy Adobe Community Professional & MVP

          If the object exists in multiple keyframes then it can reset when you move to a new one.  If that's the case you should have this object in its own layer and have only one keyframe for it in that layer.

          • 2. Re: How to Ensure Symbol State Persists?
            Haravikk Level 1

            I'm afraid that's not really an option as the object needs to move as part of the animation, but I also need to be able to show and hide it as required. It also wouldn't explain why other symbols work fine, as they are also part of keyframed animations and show/hide exactly as expected.

            • 3. Re: How to Ensure Symbol State Persists?
              prodigalmaster Level 2

              Just put the animation to move the movieclip around within another movieclip. To set the visibility of a movieclip through code, give it an identifier name and type:

               

              movieclipNameHere._visible = false; (or true).

              • 4. Re: How to Ensure Symbol State Persists?
                Haravikk Level 1

                While that seems like it would work, it involves syncing everything in the main timeline with the separated piece, which I'm not sure is much of an option either as if I want to add frames or tweak anything then I need to move any changes into the separate symbol, I'd also need to sync up script actions in the main timeline that affect the symbol (e.g - looping, skipping forward/back etc.).

                 

                It's something at least, but it still doesn't explain why this particular symbol isn't staying hidden when other symbols, hidden in the same way and also animated, are working perfectly.

                 

                Also for clarity, I'm not using ._visible because I'm not actually hiding the symbol in its entirety, it folds away. It probably doesn't matter though; like I say other symbols are working fine.

                 

                Actually though, the only difference I can think of is between the symbols is that the one I'm having trouble with has a mask, but is that likely to affect anything?

                • 5. Re: How to Ensure Symbol State Persists?
                  Haravikk Level 1

                  Okay, I'm going to try to highlight what I'm seeing by taking a snapshot of the timeline where the problem occurs:

                   

                  https://dl.dropboxusercontent.com/u/7999266/Temporary/FlashSymbolIssue.png

                   

                  The selected layer has the problem symbol, the layer immediately above is the mask layer. The blue circle indicates the frame at which the symbol is hidden (or shown) by a script further up in the timeline. The symbol displays as expected for the duration of the blue tween. At the green circle, a new tween begins but the symbol remains unchanged, continuing to be shown or hidden as expected for the during of that tween. The red circle however is where the symbol apparently resets to the default (showing) frame, and loses any other state assigned to it (e.g - if I were to set a variable upon it such as foo.bar = "foobar").

                   

                  Why would the symbol retain state through the green circle, but not the red one? It seems that at the green circle the symbol is still the same instance, but at the red circle it is not, even though nothing seems to be happening any differently.