6 Replies Latest reply on May 17, 2007 9:48 AM by JD Speer

    newbie scope issue

    JD Speer
      I have almost 100 Captivate 2 files that I have had to edit in flash 8 and export as swf and now want to load via another swf. The audio works fine in the exported swf, but is lost when loaded by another swf. The audio handling in the files that come out of Captivate use

      var sound:AdobeCaptivate.rdSound = _parent.soundHandler.attachSound(10154, "05-01.mp3");
      if(_parent.m_moviePaused != true)
      sound.startSound();
      function onUnload() {
      _parent.soundHandler.detachSound(10154);
      }

      I am using

      this.createEmptyMovieClip("img_mc", 999);
      var my_mcl:MovieClipLoader = new MovieClipLoader();

      my_mcl.loadClip("./swf/filename.swf", img_mc);

      to load the exported swf into my player movie.

      If I remove the code to call the audio that Captivate creates and just add the audio event to the timeline it plays fine both stand-alone and from the player swf. I'm pretty sure my problem comes from the use of _parent , but I don't know actionscript well enough to know how to change this.

      Any help would be appreciated.
        • 1. Re: newbie scope issue
          dr_ross Level 1
          Annoying thing i've always found is once you load a movieclip 1 inside movieclip 2, any code you have attaching a sound from library 1 will now refer to library 2.

          So you can either put the sounds in the holders library with the same linkage, or have a movieclip on the stage of movieclip 1 with the sound inside it, and you tell that movieclip to play/stop instead of coding a sound.

          If anyone knows a better fix i'm all ears
          • 2. Re: newbie scope issue
            JD Speer Level 1
            I can not add the sound to the wrapper library as this will balloon out the size of the wrapper. As I said I have almost 100 of these files from captivate. Each swf's audio files are small on their own; but if you had to take a hit all at once this would be to large. So I was hoping to load the audio with each individual swf.
            • 3. Re: newbie scope issue
              mercl Level 1
              try to leave out the _parent altogether
              swf1:
              MyVar
              is within the swf and or clip
              (also for functions within the clip)
              so
              MyVar = "hello";
              function MyFntc() {
              val = MyVar; // will be available to this function
              (val = "hello")
              }

              this.MyVar
              function MyFntc() {
              val = MyVar; // will be available to this function
              (val is "hello")
              }

              MyVar = "hello";
              function MyFntc() {
              val = this.MyVar; // will only be available from within the function
              }

              H.i.H
              M
              • 4. newbie scope issue
                JD Speer Level 1
                I tried this and it breaks the sound completely. The use of _parent ties attaches the sound to the controller.

                I have been trying to use _lockroot; however I don't seem to have the method right. I tried adding

                this._lockroot = true;

                to the main timeline of the swf that gets loaded, it didn't work, which is very frustrating since that seems to be the prefered method of using _lockroot. so I tried adding

                my_mcl._lockroot = true;

                to the timline of the swf that loads the clip and suddenly I get the audio; however I also get the error

                There is no property with the name '_lockroot'.
                my_mcl._lockroot = true;

                Also the controller now works incorrectly. Not sure what to do now.
                • 5. Re: newbie scope issue
                  JD Speer Level 1
                  Update:

                  I couldn't get the _lockroot to work, so I have tried switching my loading method from

                  this.createEmptyMovieClip("img_mc", 999);
                  var my_mcl:MovieClipLoader = new MovieClipLoader();

                  my_mcl.loadClip("./swf/filename.swf", img_mc);

                  to

                  loadMovieNum ("./swf/05toolbar.swf", getnexthighestdepth());

                  Now it plays the audio, the controller works the way it supposed to; only it all pops open in a new browser. Does anybody know how I force this to stay within the conatianer? by the way, if I actually specify a level instead of getnexthighestdepth, it does not play the audio.

                  • 6. Re: newbie scope issue
                    JD Speer Level 1
                    Update

                    I have finally given up and trying to get this to work this way. I have removed the script from Captivate 2 that calls the audio. I have moved the audio to the timeline as an event within each clip. I had to put a stopAllSounds(); on the first frame of each clip and load the audio on the second. That way when the controller moves through the clip the audio does not overlap itself.

                    Not the elegant solution I was looking for, but a solution.