7 Replies Latest reply on Nov 11, 2013 5:47 AM by kglad

    Is there a way to find a stop(); function call in a frame?

    RP_Schmidt Level 1

      Hello all, and thank you in advance for any assistance you can provide.

       

      Background:

       

      I have two functions built into a root swf; one stops all nested movie clips loaded into the root swf and the other plays all nested movie clips loaded into the root swf.

       

      The stop function performs perfectly. Clips that are playing stop and clips that are not playing do nothing (as expected).

       

      The play function works very well except for one issue.

       

      I have modified the play function so that it checks each movie clip to see if the current frame is 1 or if the current frame is equal to the total number of frames in the movie clip.

       

      This keeps the play function from playing clips that may be on the stage but have not started playing yet, or re-playing clips that have already completed their animation but are still on the stage.

       

      Issue:

       

      The  issue I am having with the play function is when I am dealing with nested movie clips that have been created to be part of a sub-navigation.

       

      For example; I have a movie clip named BOB. BOB has ten frames.

       

      In staggered layers there is a movie clip in each frame of BOB that has its own animations and sub-navigation controls.

       

      When I use the stop function, it stops all animations as expected.

       

      BUT when I use the play function, it goes to the next frame of BOB, rather than simply playing the current frame's animation as it would normally do.

       

      Code:

       

      Unfortunately, I cannot copy the function here because of access limitations from the source.

       

      However, here is an example of the IF statement I am using to control the playing of all movie clips.

       

      if (typeOf(mc) == movieclip && mc._currentframe != mc._totalframes && mc._currentframe != 1){
      name_playAll(mc)
      

       

      I need to add one more delimiter to my play function to account for existing stop() function calls so that I can make the play function ignore movie clips if the current frame has a stop(); in it.

       

      Is there a method to account for existing stop() function calls?

       

      Again, thank you in advance for any suggestions you may have.

        • 1. Re: Is there a way to find a stop(); function call in a frame?
          kglad Adobe Community Professional & MVP

          no, there's no such thing.

           

          however, you could add your own boolean which would indicate a stop() has executed.

          1 person found this helpful
          • 2. Re: Is there a way to find a stop(); function call in a frame?
            RP_Schmidt Level 1

            Isn't the stop(); function itself a boolean?

             

            I mean, essentially, either a stop is true or false. Something is either stopped or it isn't.

             

            But to follow on your reasoning, how would I add a boolean to indicate a stop?

            • 3. Re: Is there a way to find a stop(); function call in a frame?
              kglad Adobe Community Professional & MVP

              no, stop() is a movieclip method, not a boolean variable and it returns void.

               

              when you apply a stop() to a timeline, use:

               

              var stopped:Boolean=true;

               

              if you latter apply a play(), you should update stopped to false.

              • 4. Re: Is there a way to find a stop(); function call in a frame?
                RP_Schmidt Level 1

                Thanks kglad... I appreciate the feedback.

                 

                I thought stop() was a global function? Per the Adobe reference ActionScript 2.0 Language Reference / ActionScript language elements / Global Functions

                 

                I'm not sure I understand how adding a boolean would help in this instance. There are hundreds of nested clips with coded stops in them. Wouldn't the boolean constantly be true if every nested clip registered true when it entered a frame with a stop?

                 

                I just need the playAll function to ignore specified movie clips. Essentially, I need the playAll function to play every clip except those I identify.

                 

                I had hoped that if there was a way to identify to flash that there was an actual coded stop in the frame. If so,  I could tell the playAll function not to play clips where the frame contained a coded stop.

                 

                I decided to take a difference approach that I thought might work much better.

                 

                I created arrays to store my movie clip instance name information (one for the clips I wanted to ignore and one for all clips in the content). My idea was to compare the arrays and only play those that were not part of the ignore array.

                 

                Here is the full code for the name_playAll function that I am using:

                 

                 

                /*Clips the play function should ignore*/
                _global.ignoreClipArray = new Array();
                
                /*All clips currently in the content*/
                _global.currentClipsArray = new Array();
                
                function name_playAll(place){
                var mc;
                
                /*Create strings for evaluation from arrays*/
                var ignoredClipsString = _global.ignoreClipArray.join(" || ");
                
                var curentClipsString = _global.currentClipsArray.join(" || ");
                
                /*Trace strings out to text boxes at the root level so that the values are visible in the root*/
                
                stopUsed_trace.text = "STRING OF ALL OF THE MOVIE CLIPS THAT ARE IGNORED \n\n"+ignoredClipsString;
                
                devstop_trace.text = STRING OF ALL OF THE MOVIE CLIPS IN THE CURRENT CONTENT \n\n"+currentClipsString;
                
                for(all in place){
                     mc=place[all];
                     currentClipsArray.push(mc._name);
                     if(typeof(mc) == "movieclip" && mc._currentframe != mc._totalframes && mc._currentframe != 1 && mc._name != (ignoredClipsString)){
                          mc.play();
                          name_playAll(mc);
                     }
                }
                

                 

                There is some additional code outside of the for loop that deals with handling audio and video objects, but that code works perfectly (it is directed to specific instance objects).

                 

                When I trace the arrays or strings, they are reporting accurately; they list all of the movie clips they should list (one reports the instance name of every movie clip in the content and the other only reports the instance names of the clips I have pushed to it to be ignored).

                 

                However, needless to say, it doesn't work; the first two portions of the if statement work as expected (comparing frames), but there is no comparison occurring in the last part of the if statement (comparing the mc._names with the ignore string).

                 

                I thought that since it was in a loop, it would go through each instance name and compare it to the ignoredClipsString (a list of the ignored clips separated by the ||).

                 

                But either it is not doing a comparison, or the method of comparison is incorrect.

                 

                I tried substituting the actual instance name of one of the clips for the ignoredClipsString, but there still doesn't appear to be an actual comparison occuring.

                 

                I have done a lot of searching and experimentation with different methods of comparing arrays (including a few I saw written by you) but I guess I didn't implement them properly.

                 

                Thank you again for any assistance you could provide.

                • 5. Re: Is there a way to find a stop(); function call in a frame?
                  kglad Adobe Community Professional & MVP

                   

                  I thought stop() was a global function? Per the Adobe reference ActionScript 2.0 Language Reference / ActionScript language elements / Global Functions

                  stop() is not a global function despite what the help docs say.  it is local to the movieclip/class that contains the stop().

                   

                  I'm not sure I understand how adding a boolean would help in this instance. There are hundreds of nested clips with coded stops in them. Wouldn't the boolean constantly be true if every nested clip registered true when it entered a frame with a stop?

                  no, just like the stop() is local to the movieclip that contains the stop, variables are local to the timeline/class that contains the variable.  so, the variable stopped on movieclip mc1's timeline and the variable stopped on movieclip mc2's timeline are independent of each other.

                   

                  I just need the playAll function to ignore specified movie clips. Essentially, I need the playAll function to play every clip except those I identify.

                  as long as you identify those movieclips, no problem.  this entire issue arises because it's difficult for you to identify those movieclips and you're looking for some way to automate the identification.  there's no way to do that during run-time other than something like my previous suggestion about using a boolean.

                   

                  I had hoped that if there was a way to identify to flash that there was an actual coded stop in the frame. If so,  I could tell the playAll function not to play clips where the frame contained a coded stop.

                  you can use jsfl to automate the search of a swf to list all movieclips/frames that contain a stop.  you could use that list in your swf to control what you play.

                   

                  I decided to take a difference approach that I thought might work much better.

                   

                  I created arrays to store my movie clip instance name information (one for the clips I wanted to ignore and one for all clips in the content). My idea was to compare the arrays and only play those that were not part of the ignore array.

                  here's code for that:

                   

                  function playAllButF(playA:Array,donotplayA:Array):Void{

                  for(var i:int=0;i<playA.length;i++){

                  if(!memberOf(playA[i],donotplayA)){

                  playA[i].play();

                  }

                  }

                  }

                   

                  function memberOf(e:*,a:Array):Boolean){

                  for(var i:int=0;i<a.length;i++){

                  if(e==a[i]){

                  return true;

                  }}

                  return false;

                  }

                  • 6. Re: Is there a way to find a stop(); function call in a frame?
                    RP_Schmidt Level 1

                    Again, I really appreciate the help, kglad.

                     

                    I still feel like I am not explaining something correctly or I have left something out.

                     

                    Right now I am effectively identifying every movie clip within the content when the PLAY button is pushed (the PLAY button calls the name_playAll function).

                     

                    The for loop in the name_playAll and name_stopAll functions identifies each movie clip prototype by name and stops them when the STOP button is used and plays all clips when the PLAY button is pushed where the current frame IS NOT the last frame or the first frame.

                     

                    With the arrays I added, the name_playAll function now pushes the instance names of all movie clips in the content to the currentClipsArray when the PLAY button is pushed.

                     

                    Each clip I want to ignore pushes its instance name to the ignoreClipArray from the content; in the first frame of the ignore clips, I have the code: _global.ignoreClipArray.push(this._name);

                     

                    I can actually trace out the instance names to two text boxes on the root that I use for developer traces (because traces in the content don't register when the content is pulled into the root GUI).

                     

                    When the content loads into the GUI and I push the PLAY button, I see the instance names of every clip in the content. For content that does not have any clips that I want to ignore, the ignoreClipArray is empty; when the GUI loads content with clips I have identified to be ignored, the ignore array populates with those clip instance names when I press the PLAY button.

                     

                    That all works fine. I am getting exactly the results that I want there.

                     

                    Now I just want to add the ability to compare the complete list of movie clip instances to the list of ignored clips and play only the clips that aren't ignored when the PLAY button is pressed.

                     

                    Again, everything else works just fine right now. The name_playAll function does everything I have incorporated into it when the PLAY button is pushed.

                     

                    I hope that makes more sense.

                     

                    Thanks again for your suggestions!

                    • 7. Re: Is there a way to find a stop(); function call in a frame?
                      kglad Adobe Community Professional & MVP

                      the code i just suggested in message 5 does just that.  it plays all the movieclips in the first array passed to playAllButF, if they are not in the 2nd array argument:

                       

                      playAllButF(allyourmovieclipsarray,yourdonotplayarray);