4 Replies Latest reply on Nov 15, 2006 2:01 AM by arunbe

    Directory structure problem...

    DIY_Lobotomy Level 1
      Hello. I'm sure this is an issue of how I'm setting this up, so hopefully someone can check this code and see what I'm doing wrong...

      Okay, here's my setup - I have an MC called "videos_mc". Within that is a video object called "theVideo". Here is a snippet of code that works totally fine when placed on the first frame of my movie:

      var nc:NetConnection = new NetConnection();
      nc.connect(null);
      var ns:NetStream = new NetStream(nc);
      videos_mc.theVideo.attachVideo(ns);
      ns.play("al-i.anixter.com/videos/SCS/copper/mod1/CMP.flv");


      I put it on the first frame just to test it, but I really need it to work within a funciton when a button ("cmp_btn") is pressed. That button is ALSO within the "videos_mc" (so, in the same clip as the "theVideo" object. Here's the code I have for that that is NOT working. Can someone tell me why and/or fix it?!:

        • 1. Re: Directory structure problem...
          arunbe Level 1
          Hi,

          I saw you code....
          This is the right way to play flv files dynamically.
          Coz, you the netstream and the netconnection are activated newly at each time of your function.
          So, you declare the code like this.
          • 2. Re: Directory structure problem...
            Level 7
            >> Here's the code I have for that that is NOT working. Can
            >> someone tell me why and/or fix it?!:

            What do you mean by "not working"? Do you mean the incorrect video
            loads? Nothing loads? The video disappears? Nothing seems to happen? ;)
            This might be as simple as scope -- as in, your button code doesn't "see"
            the highlightDot() function from it's current position and point of view.

            One of the first things you can do is put a trace() function inside
            highlightDot() to see if that function gets triggered.

            function highlightDot(flv:String) {
            trace("highlightDot() has been triggered");
            var nc:NetConnection = new NetConnection();
            // etc.

            Makes sense, right? You need to narrow down where this is breaking,
            first.

            > I saw you code....
            > This is the right way to play flv files dynamically.
            > Coz, you the netstream and the netconnection are activated
            > newly at each time of your function.

            I think arunbe mean to say "this is not the right way," because the next
            bit is right: you don't want to re-instantiate your NetStream and
            NetConnection objects each time. They're only needed once -- the
            NetStream.play() can then load as many different FLV files as you please.

            All your highlightDot() function really needs to do is invoke
            NetStream.play() -- and honestly, you don't even need the extra custom
            function for that. Just have the button's onRelease handler invoke
            NetStream.play() directly.


            David Stiller
            Adobe Community Expert
            Dev blog, http://www.quip.net/blog/
            "Luck is the residue of good design."


            • 3. Re: Directory structure problem...
              DIY_Lobotomy Level 1
              Cool - thanks, guys. Yeah - what arun said was correct and fixed my issue...

              >> Just have the button's onRelease handler invoke NetStream.play() directly.

              When I pasted my code into the thread, I edited it a lot. There's a bunch of other stuff going on in that function, but it was irrelevant to my question, so I took it out. But yeah - that's why that line of code is inside a function and not just on the button...

              Thanks again!...
              • 4. Re: Directory structure problem...
                arunbe Level 1
                always welcome....