7 Replies Latest reply on Apr 26, 2006 5:20 PM by Craig Grummitt

    stop() in frame script not working.

    monkinetic
      Hello,

      I have a three frame pre-load movie. Frame 2 has an actionscript that loads an FLV file using a variation on the sample code on preloading FLV files. At the top of this script I have

      stop();

      Hoping to stop the movie and allow the pre-load to happen, before using a loader to load the full movie in frame 3. Well, nothing happens. The movie happily continues on to frame 3. I've tried "goToAndStop(2)", "goToAndPlay(2)", and "pause()". This is so simple, and it's making me nuts. What am I missing?

      Sincerely,

      --Steve



      stop ();

      // store the root of the web site to get video from
      var URL_ROOT = "thesite";

      var connection_nc:NetConnection = new NetConnection();
      connection_nc.connect(null);
      var stream_ns:NetStream = new NetStream(connection_nc);
      my_video.attachVideo(stream_ns);
      stream_ns.play(URL_ROOT + "thevideo.flv");

      var loaded_interval:Number = setInterval(checkBytesLoaded, 500, stream_ns);

      function checkBytesLoaded(my_ns:NetStream) {
      var pctLoaded:Number = Math.round(my_ns.bytesLoaded / my_ns.bytesTotal * 100);
      loaded_txt.text = "LOADED " + pctLoaded + "%";
      //progressBar_mc.bar_mc._xscale = pctLoaded;
      if (pctLoaded>=100) {
      clearInterval(loaded_interval);
      goToAndPlay (3);
      }
      }
        • 1. Re: stop() in frame script not working.
          Level 7
          Steve,


          > I have a three frame pre-load movie. Frame 2 has an
          > actionscript that loads an FLV file using a variation on
          > the sample code on preloading FLV files.

          Not sure what you mean by "the sample code," so we'll have to see if
          that information helps illuminate your issue.

          > At the top of this script I have
          >
          > stop();

          Okay.

          > Hoping to stop the movie and allow the pre-load to
          > happen, before using a loader to load the full movie
          > in frame 3. Well, nothing happens.

          Odd. I mean, stop() stops the timeline it's in -- every time.
          Something must be going one that you're either not mentioning or don't know
          to mention.

          > The movie happily continues on to frame 3. I've tried
          > "goToAndStop(2)", "goToAndPlay(2)", and "pause()".

          gotoAndStop() is the correct capitalization. I'm curious why you tried
          pause(), though. There isn't a pause() function in the ActionScript
          Language Reference ... did you look that up, somewhere?

          > stop ();

          So far, this stops the timeline it's in (presumably the main timeline).

          > // store the root of the web site to get video from
          > var URL_ROOT = "thesite";

          Declares a variable and sets its value to "thesite".

          > var connection_nc:NetConnection = new NetConnection();
          > connection_nc.connect(null);
          > var stream_ns:NetStream = new NetStream(connection_nc);
          > my_video.attachVideo(stream_ns);
          > stream_ns.play(URL_ROOT + "thevideo.flv");

          This should open an FLV from the address "thesitethevideo.flv" (I assume
          you're only using sample data here -- that your actual code provides a real
          URL).

          > var loaded_interval:Number = setInterval(checkBytesLoaded, 500,
          > stream_ns);

          This declares a variable and sets it to the return value of
          setInterval().

          > function checkBytesLoaded(my_ns:NetStream) {
          > var pctLoaded:Number = Math.round(my_ns.bytesLoaded / my_ns.bytesTotal
          > *
          > 100);
          > loaded_txt.text = "LOADED " + pctLoaded + "%";
          > //progressBar_mc.bar_mc._xscale = pctLoaded;
          > if (pctLoaded>=100) {
          > clearInterval(loaded_interval);
          > goToAndPlay (3);

          Change your case to gotoAndPlay(3) -- but also, you may need to path
          this correctly. We're scoped to a function that is scoped setInteval().
          From this vantage point, Flash may not know which timeline you mean to send
          to frame 3.

          > }
          > }

          On the face of it, I agree, your stop() function should certainly
          succeed. Some good, old fashioned trouble shooting is in order, here. Use
          the /* ... */ syntax to comment out everything in this frame except the
          stop() and see what happens. If it stops, then slowly pull lines of
          ActionScript back out of those comments until the timeline fails to stop.
          If it never stops in the first place, we'll have to narrow down other
          possibilities, whatever they are.


          David
          stiller (at) quip (dot) net
          Dev essays: http://www.quip.net/blog/
          "Luck is the residue of good design."


          • 2. Re: stop() in frame script not working.
            monkinetic Level 1
            Hi David,

            >Originally posted by: David Stiller
            >Steve,

            >Not sure what you mean by "the sample code," so we'll have to see if
            >that information helps illuminate your issue.

            The code I used was from the documentation: Livedocs on preloading FLV files

            > Odd. I mean, stop() stops the timeline it's in -- every time.
            > Something must be going one that you're either not mentioning or don't know
            > to mention.

            It's very possible - I'm (obviously) pretty new to Flash and this is due tomorrow. Sigh.

            >gotoAndStop() is the correct capitalization. I'm curious why you tried
            >pause(), though. There isn't a pause() function in the ActionScript
            >Language Reference ... did you look that up, somewhere?

            I saw pause() somewhere but I'm betting it was in the FLV controls documentation, and in my brain I added it to the timeline control api. Thanks for the correction.

            >This should open an FLV from the address "thesitethevideo.flv" (I assume
            >you're only using sample data here -- that your actual code provides a real
            >URL).

            Yes.

            >Change your case to gotoAndPlay(3) -- but also, you may need to path
            >this correctly. We're scoped to a function that is scoped setInteval().
            >From this vantage point, Flash may not know which timeline you mean to send
            >to frame 3.

            This is something I've been wondering aboiut, how to make sure that I'm address frames and assets appropriately. If I want to go to frame 3 of my main timeline, how would I do that? (Assuming I can get my timeline to stop and run the code!)

            >On the face of it, I agree, your stop() function should certainly succeed.
            >Some good, old fashioned trouble shooting is in order, here. Use
            >the /* ... */ syntax to comment out everything in this frame except the
            >stop() and see what happens.

            I had tried that before, and did so again. No change, which is what was freaking me out.

            >If it stops, then slowly pull lines of ActionScript back out of those comments until the timeline
            >fails to stop. If it never stops in the first place, we'll have to narrow down other
            >possibilities, whatever they are.

            >David

            I've uploaded the file I'm working on ( working file) - if you can take a look I'd be really grateful. Thanks for the help,

            --Steve
            • 3. Re: stop() in frame script not working.
              Craig Grummitt Level 3
              I just had a go with your sample code - i'm not sure about flash slide presentations as i never use them so i took it out of that and it seemed to work fine - the flv downloaded gradually showing a percent loaded text box and then when it hit 100% it went to frame 3. (the flv doesn't play in frame 3 but i assume you're aware of that)

              in subsequent plays, the flash player went quickly to frame 3, which may be where you're thinking there's a problem..? i think this is happening because flash has cached the flv. unfortunately when testing movies, regardless of whether 'simulate download' is turned on, this doesn't appear to affect flv's, which appear to be either local/cached and play immediately or not local/cached and take some time to load/play.

              Craig
              • 4. Re: stop() in frame script not working.
                monkinetic Level 1
                Craig,

                Thanks, I think you're right, but I'm not sure. Thanks for the pointer. Question for you, David, whomever:

                I have about 17mb of video to download - approx 1 video for each of 10 screens. Any suggestions on the best way to preload them? The method I'm using now works for one of the videos, but I'm not certain of the best way to do multiple.

                Thanks,

                --Steve
                • 5. Re: stop() in frame script not working.
                  Level 7
                  Steve,

                  > I've uploaded the file I'm working on
                  > ( http://bookdev.com/tmp/mpl_loader.zip) - if you can take
                  > a look I'd be really grateful.

                  I opened your file to take a look. I don't know how I missed it
                  earlier, but I didn't realize you were using a Slide Presentation (screens)
                  format. For all I know, this may change the playing field. I personally
                  don't use the screens feature, since the timeline metaphor -- the
                  traditional Flash Document under File > New -- has been around forever. I'm
                  afraid I simply don't know if timelines are handled the same way in screens.
                  I *think* they are, but I'm not an authority on the topic.

                  Is there a specific reason you're using screens over a more traditional
                  approach? (Not trying to sway you ... just curious.)

                  > I have about 17mb of video to download - approx 1 video
                  > for each of 10 screens. Any suggestions on the best way to
                  > preload them? The method I'm using now works for one of
                  > the videos, but I'm not certain of the best way to do multiple.

                  For video content, the best way I can think of is to break your video
                  content into as many files as possible -- which it sounds like you've
                  already done. Then load those files dynamically, which you're already
                  doing. Video starts playing before the file has completely downloaded, so
                  ... yeah, honestly, that's the approach I would use.


                  David
                  stiller (at) quip (dot) net
                  Dev essays: http://www.quip.net/blog/
                  "Luck is the residue of good design."


                  • 6. Re: stop() in frame script not working.
                    monkinetic Level 1
                    David,

                    >Is there a specific reason you're using screens over a more traditional
                    >approach? (Not trying to sway you ... just curious.)

                    Honestly, it has more to do with the fact that I'm new to Flash, was creating a presentation (originally) and it seemed an easy way to get keyboard navigation. Looking at it now, I may need to collect all my assets and start over with a new timeline-based project, just to remove the screens as a factor. It seems most folks who know what they're doing, are doing it in the timeline. :-)

                    >For video content, the best way I can think of is to break your video
                    >content into as many files as possible -- which it sounds like you've
                    >already done.

                    Yes, I've got 10 .flv files that were converted from the original QuickTime .movs.

                    >Then load those files dynamically, which you're already doing.
                    >Video starts playing before the file has completely downloaded, so
                    >... yeah, honestly, that's the approach I would use.

                    Thanks. The thing I'm not understanding right now is this -- the code that loads the first video uses setInterval() to track the loading progress, but I only really know how do that once. Ideally I'd like to pre-load all 10, and show the user a percentage of the total 17mb that has to load. Then, after each of the movies has loaded, forward the user to the first (screen/page/whatever). Any hints on this would be appreciated.

                    Thanks guys for all the help,

                    --Steve
                    • 7. stop() in frame script not working.
                      Craig Grummitt Level 3
                      Are you saying the videos are sequential? If so, call me crazy and controversial, but i would actually consider combining them into one FLV for the simplicity of streaming one file.

                      If the videos are not sequential, and if you would like to give the user the chance to go to the video they want to see before all 10 are loaded, then i wouldn't preload anything - otherwise whatever you're preloading would be competing with the stream of whatever the user tries to view. Check out http://www.macromedia.com/devnet/flash/articles/prog_download.html

                      If there is a sequence to the videos but the user can skip videos, then this is getting complicated. You're on the right track setting up an array of video filenames. When the currently loading video reaches 100%, the next video would begin loading. when the user skips or the video completes, the next video would begin playing/streaming. If the user skips and the video they were viewing hadn't completed downloading, then i would close the stream they were viewing so that it doesn't compete with the new stream. (i would set up a different netstream for each video.)

                      you could of course force the user to wait until all 17mb is downloaded but I wouldn't recommend that one coz that's going to be at least an hour that your 56k modem users are going to be staring at a progress bar...

                      a couple of other comments:

                      at the moment your code is waiting until the video is 100% loaded and then it goes to frame 3 - is there any point to this?

                      you of course realise that there's no video playing yeah? and the action script on frame 2 assumes that there is a video asset on the stage with the instance name "my_video"?

                      good luck with it!
                      Craig