6 Replies Latest reply on Apr 25, 2009 6:44 AM by kglad

    onMetaData

    izdo89

      This line of code (that worked in previous versions of Flash) is not working in CS4. Does anyone know how I need to write it?

       

      ns["onMetaData"] = function(obj){
          duration = obj.duration;
      }

       

      If anyone knows, I'd appreciate a heads up. Thanks!

        • 1. Re: onMetaData
          kglad Adobe Community Professional & MVP

          that should work if you define ns correctly as your netstream instance.  did you?

          • 2. Re: onMetaData
            izdo89 Level 1

            Yes. Here is my entire code for the file:

             

            //Attach Video
            var nc:NetConnection = new NetConnection();
            nc.connect(null);
            var ns:NetStream = new NetStream(nc);

             

            videoOne.attachVideo(ns);
            ns.play("bear.f4v");
            //End Attach Video

             

            //Program Controls
            var muteCount:Number = 1;

             

            controls.stopButton.onRelease = function(){
                ns.seek(0);
                ns.pause();
                this._parent.playToggle.gotoAndStop(2);
            }

             

            //Mute and Play have AS on them

             

            _root.createEmptyMovieClip("bearSound",getNextHighestDepth());
            bearSound.attachAudio(ns);
            var so:Sound = new Sound(bearSound);
            so.setVolume(100);
            //End Program Controls

             

            //Programm Scrubber
            var videoInterval = setInterval(videoStatus,100);
            var amountLoaded:Number;
            var duration:Number;
            var scrubInterval;

             

            I declared 'duration' here because I needed to keep working.

             

            duration = 12;
            /*
            ns["onMetaData"] = function(obj){
                duration = obj.duration;
            }
            */


            function VideoStatus(){
                amountLoaded = ns.bytesLoaded / ns.bytesTotal;
                controls.scrubber.loadbar._width = amountLoaded * 233;
                controls.scrubber.scrub._x = (ns.time / duration) * 223;
            }

             

            controls.scrubber.scrub.onPress = function(){
                clearInterval(videoInterval);
                scrubInterval = setInterval(scrubIt,10);
                this.startDrag(false,2,this._y,223,this._y);
            }

             

            controls.scrubber.scrub.onRelease = controls.scrubber.scrub.onReleaseOutside = function(){
                clearInterval(scrubInterval);
                videoInterval = setInterval(videoStatus,100);
                this.stopDrag();
            }

             

            function scrubIt(){
                ns.seek(Math.floor((controls.scrubber.scrub._x/223) * duration));
            }
            //End Programm Scrubber

             


            I'm also having some issues with the 'setInterval' functions I'm using, but I have a different forum set up for that (http://forums.adobe.com/message/1917492#1917492).

            • 3. Re: onMetaData
              kglad Adobe Community Professional & MVP

              duration looks fine.  what makes you think it's not?

              1 person found this helpful
              • 4. Re: onMetaData
                izdo89 Level 1

                Well, the scrubber doesn't seem to be reacting to the total time. It doesn't move at all. I can move it, but it doesn't affect the video.

                • 5. Re: onMetaData
                  izdo89 Level 1

                  Sorry, got everything figured out! Thanks for your help. It was a typo i made in my script. Haha, sorry! Thanks.

                  • 6. Re: onMetaData
                    kglad Adobe Community Professional & MVP

                    you're welcome.