17 Replies Latest reply on Sep 4, 2007 7:52 AM by nik c

    stopping execution of scripots half way, or arbitrarily

    nik c
      Hi,

      I am not even sure how to explain the issue properly. I'll try. I am working on a site involving 9 video clips. Here is the staging URL (please wait for the video clips to load fully, it will only really work on a broad band connection!!): http://www.multimediaworkshop.co.uk/TDD/002/

      The idea is that on rollover on the individual screens, the heads of the other people look to the 'rollOver screen' . When that screen is clicked as well, and the mouse kept over it, the respective clip will commence playback.

      Issue is: obviously it is possible to swoosh over the screens with the mouse and trigger the scripts in all the screens that make the people look at the 'rollOver screen' many times a second. What then happens is that these scripts seem to all quue up in their execution and that causes undesirable delays.

      The basic coding strategy is: I set up a broadcaster (... .broadcastMessage) on the movie clip of the screen (which is the same for all 9 screens, but instanciated 9 times (with the names a1-3, b1-3, c1-3) to form the grid of screens.

      If a rollover occurs, the listeners and their scripts (for which there is one for each screen) determines if 'its' screen is the rolledOver one or not and takes appropriate action (if it is: it places the screens video on the start frame ready for playback; if not, it seeks the start of the correct 'looking sequence' and starts playing the looking video (these looking sections of the videos are placed in the same video files as the main movie, but before it).

      The actual site is very unfinished: there are issues with the handling of the screens sizes (especially if loading is not complete; and stopping the looking sequences at the rigtht time (ie when the person is looking up, left, right, etc)

      But I hope the main issue I am trying to solve is clear now which is: how do I stop the individual scripts executing when the mouse rolls over multiple screens and only stops on the 6th one, which at the moment leads to a deluge of scripts being executed and the ensuing delays and visual artifacts.

      In other words - is there a way of stopping a script that is currently executing based on the occurance of an event that is external to the script????

      Is delaying the execution for a second or so the answer? If so how would I do that?

      Thanks,
      Nik http://www.multimediaworkshop.co.uk/TDD/002/
        • 1. Re: stopping execution of scripots half way, or arbitrarily
          kglad Adobe Community Professional & MVP
          you just need to code that properly. your screens can be triggered to start "looking" whenever there's a rollover. but the screen they look at should be a variable that only contains a reference to the last rolled over screen.
          • 2. stopping execution of scripots half way, or arbitrarily
            nik c Level 1
            thanks, I am in the process of trying this out now.

            just one thought - that sounds cool for making them look at the right screen all the time, but would that solve the problme of the scripts cueing up to be executed?

            I mean if I sweep the mouse over a few of the screens (e.g. I move it in a circle around the outer screens tow times) I get a lot of scripts running for each screen. That would still be happening though, isn't it?

            ACTUALLY - after looking at my script again. This is pretty much the approach I took: the script that is doing all the work (e.g. sorting out who is looking where) begins like:

            _global.moveScreen = function(tRollOverScreen, tCallingScreen)

            where 'tRollOverScreen' is a reference to the latest rolled Over screen, and 'tCallingScreen' is the screen that is calling the script. Based on the relationship between these 2 variables, the video is directed to go to the respective video section (looking up, right, left, etc). The script works this out almost like a vector: screens rows are a, b, c; screen columns are 1,2,3. If rollOver screen is a1 and calling screen is b2, then go to 'look UP, LEFT', etc., etc.

            Nik C

            Nik C
            • 3. Re: stopping execution of scripots half way, or arbitrarily
              kglad Adobe Community Professional & MVP
              each rollover should terminate the movieclips "looking" at the previous rollover and initiate the "looking" at the current rolled-over movieclip. there will be no queuing and no performance issues.
              • 4. Re: stopping execution of scripots half way, or arbitrarily
                nik c Level 1
                I got this script on the rollOut:

                this.onRollOut = function () {
                // -> broadcastEvent();
                var tOverOut:String = "out";
                _root.screenWatcher.broadcastMessage("resize", this, tOverOut); // "out" indicates it's a rollOut that is happening
                // -> stop all p/b; return to start
                this.flv_vd.stop();
                this.flv_vd.seekToNavCuePoint("Start");
                }

                As you can see from the use of 'this' it is placed on the original screen clip. If you hav3e a look at the site, it kind of terminates the playback effort of each video, but if it doesn't clear the back log of scripts that seems to build up.
                I am beginning to think that the broadcasting thing might not be the right way of going about this problem. It does create an awful lot of messages resulting scripts that are executed. That's 9 for each rollOver, 9 for each rollOut, so if you roll over 5 or 6 screens, you easily have 90 or more scripts at least being initiated ina short time.

                Or am I not seeing the wood for the trees here. It feels like I am missing something obvious .... [ do I need one listener per screen, e.g? from what I see so far, yes?! ]

                Nik C
                • 5. Re: stopping execution of scripots half way, or arbitrarily
                  kglad Adobe Community Professional & MVP
                  you could use a broadcaster, but then you should set-up the listener(s) so it (they) call another function that terminates any previous "looking" that's still executing and start(s) the current "looking".
                  • 6. Re: stopping execution of scripots half way, or arbitrarily
                    nik c Level 1
                    yes, I got the listeners in place - how do you do the terminating? byu simply calling the same script again, but with the new parameters? Sounds not a likely strategy to me, but them I am quite new to Flash!?

                    Thank you very much!

                    Nik C
                    • 7. Re: stopping execution of scripots half way, or arbitrarily
                      kglad Adobe Community Professional & MVP
                      i don't know how you would terminate the "looking" because i don't know your setup.
                      • 8. stopping execution of scripots half way, or arbitrarily
                        nik c Level 1
                        What more would you need to know? The fla is very sparse, the main elements are a movieclip that contains the screen elements such as the graphic and the flv video p/b component.

                        To this movie clip is attached a script page with a few scripts handling the loading of the video (which doesn't do more than count the loaded bytes at the mo), the rollOvers and rollOuts (each of which broadcasts this event, together with the 'this' parameter to identify which of the 9 instances is sending it, and an indication whether it is a RollOVER or RollOUT).

                        Other than that there is a script on the main time line that does all the processing (sorting out which screen has to do what in terms of resizing itself and where it has to send its video)

                        Is there facility to post the .fla - that would be the easiest I guess?
                        Here is a link to it anyways [231KB]:

                        http://www.multimediaworkshop.co.uk/TDD/002/version_6.3_NIK.zip

                        Thanks!

                        Nik
                        • 9. Re: stopping execution of scripots half way, or arbitrarily
                          kglad Adobe Community Professional & MVP
                          then direct your flv's to the correct cue point based on the last rollover.
                          • 10. Re: stopping execution of scripots half way, or arbitrarily
                            nik c Level 1
                            This is what I think am doing anyway?

                            But am I right in assuming that the way I coded it using 'broadcastMessage' and watchers does lead to a deluge of scripts being executed one after the other?

                            I am really not sure how Flash is doing this internally, is it abandoning the execution of a script that runs because it has been triggered by / through a watcher only because the same watcher triggers the same script again?

                            Nik
                            • 11. Re: stopping execution of scripots half way, or arbitrarily
                              kglad Adobe Community Professional & MVP
                              what script is running when a rollover occurs? there should a few lines that execute with each rolloverl.
                              • 12. stopping execution of scripots half way, or arbitrarily
                                nik c Level 1
                                I have attached the code of the main page (the one in the main timeline ) to this message.

                                I would love there to be only a few lines of code on each rollOver, but each screen needs to have these few lines, and everytime there is a rollOver or rollOut, the resizing of each screen needs to be taken care of (either resize to bigger, smaller or to original size), as well as the sending of each video to the correct cue point (and I have not even included the code to stop them at the right point yet, which is probably another set of watchers watching event cue points embedded in the videos)

                                Also not included is the movement of the screens out of the way of the one that is rollOver.

                                Nik
                                • 13. Re: stopping execution of scripots half way, or arbitrarily
                                  kglad Adobe Community Professional & MVP
                                  i would do that differently:



                                  • 14. Re: stopping execution of scripots half way, or arbitrarily
                                    nik c Level 1
                                    looks great I am going to give this a try!
                                    I'll have to put in there a decrease of the size during rollOver as the screens have to get smaller while the roTarget grows bigger.

                                    I'll let you know!
                                    thanks!

                                    Nik C
                                    • 15. stopping execution of scripots half way, or arbitrarily
                                      nik c Level 1
                                      Hi,-

                                      Finally got round to working on this one again.

                                      http://www.multimediaworkshop.co.uk/TDD/002/

                                      is the latest version. I have not figured out how to do the 'moving out of the way' of the screens when a rollOver occurs. the listeners that stop the 'looknig' videos in the respective position (ie looking up, left, down) as long as the rollOver video is on, are still missing as well.

                                      one thing occurred to me though:

                                      if you rollover multiple screens in succession you still get the execution of the the scripts triggered by each rollover in succession, which means you might have finished rolling the mouse over - say -ten screens, but the video is stil mucking about for starting to go to the respective cue points, being stopped, starting to go to the next one, etc, etc.


                                      Nik

                                      ( this:

                                      http://tomdickanddebbie.com/1000h/

                                      is what I am trying to achieve but smoother, faster and with less hanging videos)
                                      • 16. Re: stopping execution of scripots half way, or arbitrarily
                                        kglad Adobe Community Professional & MVP
                                        not the way i set it up.
                                        • 17. Re: stopping execution of scripots half way, or arbitrarily
                                          nik c Level 1
                                          HI,

                                          I have added some code to facilitate the reduction in size.

                                          Nik C