8 Replies Latest reply on Sep 7, 2012 7:39 AM by adninjastrator

    Frame Rate in AS2 ???

    gaurawerma

      Can anybody tell me how to calculate frame rate of an external movieclip in AS2 ?

       

      Thanks

        • 1. Re: Frame Rate in AS2 ???
          moccamaximum Level 5

          If you mean by calculate, to get the framerate, its simple: in as2 the loaded movieclip inherits the framerate of the loading parent (your own file).

          If you mean by calculate, to get the framerate, the original programmer intended to use, you will need a swf-decompiler.

          If you mean by calculate, to get the framerate the users browser/computer will be able to actually play your movie, ask again.

          • 2. Re: Frame Rate in AS2 ???
            gaurawerma Level 1

            Hi, thanks for replying..

            The loaded file has sound in it.. so the parent file will be played in the same rate as of the child clip.

            In my case the external clip can vary in the frame rates.

             

            I am using an elapse timer on the play-progress bar of that movie clip so I need to know the frame rate of the clip /stage using AS2.

            • 3. Re: Frame Rate in AS2 ???
              moccamaximum Level 5

              In as2 there is no way to set the framerate dynamically. So if you have Movieclips with different framerates you will have to go for a compromise.

              If you feel comfortably with as3, then check this out. If you go through all the trouble because you somehow fear the sound of your loaded movieclips get messed up...that would only be the case if you need a tight integration of animation and sound, like for a music video or something, even if you set the sound of soundLaver to stream, the sound will never be affected by your movies framerate. To give you a more specific advise you will have to make more clear what you are trying to achieve

              • 4. Re: Frame Rate in AS2 ???
                gaurawerma Level 1

                I am making a SWF file player.

                The SWF files are used instead of FLVs..

                I have a play-progress bar in the player that can also be dragged.

                 

                The problem I am facing is to display the elapsed time.. In case of flvs it's easy and straight to know the elapsed time but here in my case it does not seems to be an easy task..

                If the user drags the play progress bar and I had the external swf files of the same frame rate as of the parent then I could have calculated the elapsed time just by using getTimer()..

                 

                But, external clips may vary in frame rates.. and it's getting difficult for me to find the solution.

                • 5. Re: Frame Rate in AS2 ???
                  Ned Murphy Adobe Community Professional & MVP

                  If you use AS2, your main swf player file defines the frame rate for any other swf files you load into it.  Regardless of what frame rate the loaded files were designed for, they will play at the frame rate of the player.

                  • 6. Re: Frame Rate in AS2 ???
                    moccamaximum Level 5

                    OK, obviously you need a workaround, my proposal.

                     

                    If you have the sourcecode for the loaded swf-files

                     

                    write down all the totalframes length (if you have multiple scenes, sum them up)

                    then for the play progressbar write an enter_frame event that gets the percentage of your loaded movie

                     

                    for example: you have a movie with 1000 frames and a framerate of 25 (=40 seconds of animation)

                    that is loaded in your 30 fps main movie.

                     

                    You won´t be able to influence the running time (it will only run 33 seconds) but you will be able to set the progressbar according to the percentage of the loaded movieclip, so instead of saying gotoAndPlay(framenumber),

                    you must set the progressbar dimension to the _totalframes property of your loaded movie,

                    then in the enter_frame function you get the position of the movie via _currentframe and set the position of the

                    progressbar-knob (or whatever you`re using) to the percentage of the time the movie has played

                     

                    it will look similar to that

                     

                    _root.on(enterFrame){

                         getProgress();

                    }

                     

                    function getProgress():void{

                       myPb.knob._x = myPb._width * (loadedMovie._currentframe/loadedMovie._totalframes);

                    }

                     

                    for the ProgressKnob, that the user can drag to get to aposition within the loaded mc use a setter like

                     

                    dragKnob.on(MouseDrag){

                       setProgress();

                    }

                     

                    function setProgress():void{

                      var position:Number =  myPb.knob;

                      var totalLength = myPb._width;

                      var percentage:Number = position/totalLength;

                       loadedMovie.gotoAndPlay(Math.round(percentage*loadedMovie._totalframes));

                    }

                     

                    Problem could be, that the EnterFrame function could block the setProgress function (may be you should get the progress only every 20 frames or so)

                    (Another reason to switch to AS3)

                    • 7. Re: Frame Rate in AS2 ???
                      Triynko

                      "Regardless of what frame rate the loaded files were designed for, they will play at the frame rate of the player."

                       

                      My main movie is doing just the opposite.  It's frame rate is temporarily slowing down to match that of a loaded swf.  Could this be because the loaded swf has embedded video and audio using the sync to stream  (rather than event) option?

                      • 8. Re: Frame Rate in AS2 ???
                        adninjastrator Level 4

                        Yes, the main document will then take on the frame rate of the .swf with the video embedded into it.

                        You can understand why... in order for the video to look and sound anywhere near normal, the frame rate must be that of the original video.

                        But why are you using .swf files to play the videos? especially if you have multiple frame rates?

                        You can use AS3 or simply play the videos as external .flv files in AS2. Then the main doc can have one frame rate and each external .flv can be played at whatever it's original frame rate is.... so you can display videos with different frame rates in AS2... provided you play them as external .flv files.

                        And since you want the progress bar and timer... you'll be killing two birds with one stone.

                        Best wishes,

                        Adninjastrator