2 Replies Latest reply on Jan 17, 2008 9:26 AM by crackajack

    FLV Help needed: combining onStatus and onMetaData code

    crackajack Level 1
      i have some AS2 code that lets a set of videos play sequentially (see snippet A below), and another piece of AS2 code that helps run a custom video player (snippet B). both sets have onStatus and onMetaData information that i somehow need to rewrite, restack, or collate. any help would be very much appreciated, thanks!!
        • 1. Re: FLV Help needed: combining onStatus and onMetaData code
          dr_ross Level 1
          I't may be because it 10 to 5 but i'm not entirely sure what you're after. Can you try and explain it again, are you trying to amalgamate the hadlers into one?
          • 2. Re: FLV Help needed: combining onStatus and onMetaData code
            crackajack Level 1
            actually the great and powerful david stiller (co-author of "Foundation Flash CS3 for Designers") was kind enough to help me out. here's a portion of his response (the Lee in his response refers to Lee Brimelow, who wrote the code pertaining to the custom player controls):

            First, let's combine the onMetaData thing ...

            // Combined
            ns.onMetaData = function(evt:Object):Void {
            duration = evt.duration;
            ready = true;
            ns.duration = evt.duration; // changed from Lee's

            The name of the parameter between the parentheses of this function is completely arbitrary. If you wanted, you could call it ungabunga. ;) I happened to use evt because it's a personal abbreviation for "event," which is what this param represents. Lee called his info, which makes equally good descriptive sense. The only thing that matters is to use the name you decide while inside the function. In the preceding snippet, I added Lee's line to "my" function and change info.duration to evt.duration, because the parameter he was referening as info is not coming in as evt. Does that make sense? Also -- and this is an aside -- I strongly typed my parameter as an Object (because that's what it is in AS2), and strongly typed the return value of this function as Void, because the function doesn't return any value at all.

            Lee's NetStream instance also happens to be ns, so presumably using ns here is fine.

            The onStatus handler is beefier, but the concept is the same. An important point is that my version kills itself after the videos array has been exhausted. Once the onStatus event handler is deleted, it's deleted, so if Lee's still needs that handler to stick around for some reason (I haven't looked through all his code), that might be a problem. Here's a quick stab at combining them:

            // Combined
            ns.onStatus = function(evt:Object):Void {
            if (evt.code == "NetStream.Play.Start") {
            progressBar.onEnterFrame = videoUpdate;
            if (evt.code == "NetStream.Play.Stop") {
            delete progressBar.onEnterFrame;
            if (ready && this.time > 0 && this.time >= (duration - 0.1)) { //changed from 0.5
            ready = false;
            if (currentVideo < videos.length) {
            } else {
            delete this.onStatus;

            Again, I swapped out his info reference with evt. Notice that I added his if() statements at the top and used the same evt parameter. That might just do it for you.