SubVI window closure

Hi!
I built a subVI for an Oscilloscope VI that performs signal analysis.
Users should be able to open and close the subVI's window, but I cannot make it work as I wish.
What it should do is:
- open the subVI when an on-off control is clicked and start calculations
- close the subVI's window and stop calculations
- redo this passages every time the user needs it
What I builts does:
- open the subVI with the button and start calculations properly
- when I close the SUBVI window it opens again whith calculations stopped
- after re-closing, if I open the subVI with the button it does not calcuates
- after re-cliking the button it finally starts working again
I have attached the subVI and an example VI reproducing the loop containing the subVI.
Do you know a better (and more correct) way to make it work?
Thanks!
Mike
MikeNuke, PhD student
Politecnico di Milano
Department of Energy, Nuclear Engineering Division
Solved!
Go to Solution.
Attachments:
ExampleOscilloscope.vi ‏29 KB
OscMeas.vi ‏257 KB

I just noticed a nasty race condition you have as well.  If you toggle the button after the terminal was read but before the local variable is written to, your button toggle could be ignored due to the local overwritting your user.
What I would do with this setup would be to launch the subVI as a parallel process.  The VI can maintain its own state and what not.  You could then use User Events and/or Queues to send your data to the other process.
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines

Similar Messages

  • Hide close icon from taskflow inline popups / process window closure

    Hi OTN,
    I would like to know of there is an opportunity to hide "X" close icon from popup window when I run a taskflow in a popup as an inlineDocument?
    Or what is a preferred way to process user window closure to rollback changes?
    In my current application a user always has Cancel button which sets taskflow return parameter as "Cancel" which is then read by dialog return listener.
    The listener would call Rollback if there is "Cancel" returned.
    But "X" close doesn't set any parameter.
    Maybe I sould set "Cancel" as a default return parameter value? Or the right way is to use finalizer?
    Please, advice me.
    Thanks.
    ADF Fusion Web Application
    JDev 11.1.1.3

    You have to define and apply a custom skin. It is easy, read the documentation here:
    http://download.oracle.com/docs/cd/E14571_01/web.1111/b31973/af_skin.htm#BAJFEFCJ
    You can get detailed description of all the supported skin selectors here:
    http://download.oracle.com/docs/cd/E14571_01/apirefs.1111/e15862/toc.htm#ComponentLevelSelectors
    Note, that <tt>af|dialog::close-icon-style {display:none;}</tt> will affect all the popup dialogs, but not only the taskflow popup windows. If you need to apply it only to taskflow popup windows, then use <tt>af|panelWindow::close-icon-style{ display:none; }</tt>. Have a look at Frank's blog post http://blogs.oracle.com/jdevotnharvest/2010/12/how-to_hide_the_close_icon_for_task_flows_opened_in_dialogs.html.
    Dimitar

  • Close subvi window without "close afterwards when originally closed"

    Hi everybody,
    I've got a problem concerning Labview. In my program I need to update a graph in a seperate window. Therefore I made a subvi to display the data. The problem is now to close the window afterwards. The subvi is inside a while loop to get updated data all the time. I tried to use the "close afterwards when originally closed" but then the graph is closed after every loop. But it should be opened during the loops. I want to close the window manually by sending a false or anything else. Does anyone know an answer to my problem? Please help!!!
    Thx
    Thomas

    Hi,
    Please find attached example useful as a reference to your problem solving
    Cheers!
    Ian F
    Since LabVIEW 5.1... 7.1.1... 2009, 2010
    依恩与LabVIEW
    LVVILIB.blogspot.com
    Attachments:
    VS_Pass_Data.zip ‏62 KB

  • Loop rate in main vi slowsdown when subvis window is clicked.

    Hi All,
    I have developed one USB DAQ application with 3 while loops in main vi and 1 subvi with an activex container for video display.
    This video displayer subvi has no function and it has that Activex container to display the video.
    The purpose is to playback acquired signal with the recorded video.
    So I keep both VIs frontpanel opened at all time.
    The speed of the loops in main vi are as follows,
    Loop1: Contains event structure with 250ms timeout terminal.
    Loop2: Contains an while to play the recorded data with the recorded time duration between successive data points.
     may be min of 70 ms delay for each iteration.
    Loop3: Contains another while which run min of 15 ms delay for each iteration.
    The speed problem is as follows,
    When i click on the subvi which contains an activex container, the while loop in Loop2 does not run properly and each iterations delay in millisecond is increasing constantly in terms of  250 milliseconds atleast.
    After releasing mouse button from subvi, the loop agains starts running normally.
    it would be great help for me if somebody can provide a solution for this problem.
    Thanks in advance.
    Thanks,
    Sathish

    I think I know why this happens, I am not sure how te get a workaround.
    The ActiveX interface runs in the  UI thread just like the event structure.
    The event structure forces the whole VI into the UI thread and is only triggered every 250 ms when the ActiveX is claiming all the UI power.
    I think moving the 70 ms. loop into a seperate VI should do.
    (I might be wrong about the above theory)
    Ton
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!

  • Can a remote window be closed when the subvi is finished executing?

    I am dynamically calling subvi's from a main vi with the but when the remote user closes the browser window, it is causing problems with the connection. I would like to be able to programatically close the web window when the called subvi is done running so that i can ensure that the subvi is done when the window closes. Is there a labVIEW command that can be used here? Close FP and setting the FP:state to closed don't close the remote window. Thank you.

    Hi Jeff,
    It appears that you are dynamically calling the subvi on a remote machine and you want to close the front panel of the subvi after it is done running on the remote machine.
    Make sure that in the subvi, under VI properties>>Window appearance>> Customize, Show Front Panel When Called and Close afterwards if originally closed are both checked. This would close the subvi window when it is done running.
    Regards,
    Ankita A.

  • Main VI Menu event calling a subVI front panel

    Hi all,
    I have a subVI whose front panel is loaded upon calling by a main VI.
    I call the subVI using a User-menu event.
    the subvi-properties are set to allow close window and i am not handling a 'panel close' event.
    The problem is....
    when i run the main VI and click on the menu that loads the subVI front panel, subVI window opens, and if i click on the window-close, the main VI hangs.
    i understand that the control remains with the subVI only and never returned to main VI after i close subVI panel.
    but is it the only way to handle the 'panel close event' or any other way out to solve this?

    Try running the VI with highlight execution turned on, and see if anything unexpected is happening, or you could post your vi and let us take a nosey
    Message Edited by yenknip on 09-12-2008 04:30 PM
    - Cheers, Ed

  • Main vi stops when subvi appears

    Hello,
    In my main vi I have a lot of thing happening in it, one of them is giving signals to a USB relay device which I connected with DAQ Assistent.
    This relay is currently working on time pulses of 3 and 6 seconds. 3 off, and 6 on.
    It works fine when I use buttons or other things in my vi, but when I press a button to show graphs in a subvi the relay device stops working.
    The subvi with the graphs are now on my screen and only until I close that subvi, the relay starts working again.
    I changed the properties of the subvi:
    Window appearance - Dialog (instead of custom)
    Is there a way to make sure the relay keeps working, it's quite important...

    After looking into your code, i do not understand why you didnt split up the code initially into two loops. I marked the piece of code you can easily export. You just have to take care about passing the time-intervall between the loops. But this is easy.
    Easiest: If the delay does not change, just get it infront of both loops and pass it to them
    Simple: Use a locale variable. Just take care that ONLY ONE loops writes on this variable.
    Ellegant: Use a functional global variable (also known as LV-2-style variable).
    hope this helps,
    NorbertMessage Edited by Norbert B on 09-17-2007 04:53 AM
    CEO: What exactly is stopping us from doing this?
    Expert: Geometry
    Marketing Manager: Just ignore it.
    Attachments:
    SplitUp.PNG ‏16 KB

  • How can I open a subvi when running a vi in an application (executable file)

    I have a vi that I converted into an executable file.  I would like to run it and at the same time be able to open the front panel of one of its subvis.  Does anybody know how to do that?
    Thanks,
    Jerome.

    You can set the SubVI to "Open Front Panel when Called" and "Close Afterward if Originally Closed" - that makes it a pop-up window. When your main calls it, the subVI window opens up. You do stuff, click the DONE button, and it disappears, and the main is up front again. (Make sure your subVI is MODAL if you do this).
    You can use the VI SERVER to load the VI, given a path to it. You can set the subVI to "Open Front Panel when Loaded", or you can set FRONT PANEL.OPEN to TRUE when you want it to appear, and FALSE when you want it to go away.
    You can make a subpanel on your main, and have the subVI inserted into that.
    Steve Bird
    Culverson Software - Elegant software that is a pleasure to use.
    Culverson.com
    Blog for (mostly LabVIEW) programmers: Tips And Tricks

  • Control-C in SQL*Plus on Windows

    Hi,
    I use the "command-line-looking" sqlplus.exe (not sqplplusw.exe) Client version 10.2.0.1.0 on my Win-XP PC.
    An annoying "feature" of this SQL*Plus, is that it closes when I press ctrl-c.
    For example, when a multiple-lines output is running in the window and I want to stop it (there is no "Cancel" button in this SQL*Plus),
    I have to be carefull not to press ctrl-c too many times.
    Or when I start an Anonymous PL/SQL block - I have no way to end editing without executing it, but to enter some nonsense text and execute to failure.
    Anyone knows how to avoid the window closure, or perform these 2 actions without using control-c ?
    Thanks a lot,
    S.

    instead of starting sqlplus.exe, start a CMD window, and then start sqlplus. if you ctrl-c too many times (or if it registers after the last of the output has been displayed) it will close the sqlplus executable. if you start in a cmd window, and sqlplus.exe closes, you're back to the cmd prompt, and all of you previous output/sql is still there.
    make a shortcut for sqlplus, and for it's "target", use the following:
    cmd.exe /k sqlplus

  • Opening subvi so the main vi is active

    In the main program during execution when appropriate button is clicked subvi with a picture is called (chosen by case structure). The rest of the program (front panel) is blocked until the subvi window is closed - how can I open the subvi with a picture so it remains opened and the program goes further?
    greetings,
    Michal
    Solved!
    Go to Solution.

    You need a nonblocking dialog box. As RavensFan says the VI needs to be launched dynamically. Check the link in my signature, I wrote post about one possible implementation. What I show is just a simple "Are you sure..." kind of dialog, but it shows the basic process.
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • ALV OM. Avoiding pop-up closure

    I created an ALV pop-up using the ALV OM.
    I have to detect the moment when the user closes the window so to make some checks; according to the result of these checks the ALV pop-up must stay open so the user can make other changes.
    Until now I don't succeed in avoiding the window closure when the user, for example, clicks on the close window icon.
    What are the objects to use, or whatever else steps to make, to avoid the window closure?
    Thanks in advance,
    Antonino

  • Activating a Window Without Focus

    Hello,
    I'm using LabVIEW 8.6, I would like to give an unusual behavior to a subVI window when opened: I'd like the window to be activated without giving focus to it. What I mean, is that I would like the window to be able to catch even on the front panel like keystroke or mouse click without giving focus to this window. I'd like the focus to stay on another window.
    A good example of what I want to do is the microsoft visual keyboard installed with Windows: when the visual keyboard in open you can press any button without giving focus to the window. I'd like to reproduce the same behaviour with a labview window.
    I don't think it's possible with properties or invoke node, I think there might be something to do with the use of user32.dll. If anyone as already done that, or knows how to do it, it would be great.
    Thanks for helping.
    Clément
    DAM

    Hi,
    - Have you tried making the main VI modal? Steps are described in this KB
    - To do this programmatically, you will need to use the lvwutil32.dll like here 
    I googled your question and I found some good information this MSDN forum, I think it may help you to apply it to your code.
    Hopefuly this helps.
    Regards, 
    Steve M.
    National Instruments France
    #adMrkt{text-align: center;font-size:11px; font-weight: bold;} #adMrkt a {text-decoration: none;} #adMrkt a:hover{font-size: 9px;} #adMrkt a span{display: none;} #adMrkt a:hover span{display: block;}
    >> Vidéo-t'chats de l'été : présentations techniques et ingénieurs pour répondre à vos questions

  • How do I use a static reference to keep a VI in memory but then call it in parallel?

    Hello all,
    I have a MainVI and I want to call from it a SubVI in parallel so that I can have both windows open and responsive at the same time.  The SubVI may be closed and reopened any number of times, but only one in existance at a time.  I know how to do this using Open VI Reference, providing a relative path to my SubVI, checking its state to see if its already running, and if so bring the window to the front (using Front Panel: Open method with True/Standard inputs), and if not run it using the Invoke:Run method (and optionally opening its front panel programmatically).  This method was working fine.
    Now I have added functional global variables in my SubVI, and I want to keep them in memory inbetween opening the SubVI window.  I can do this by putting a copy of the functional global in my MainVI, even though I don't use it there for anything.  This works fine.
    By accident, I have come across a reference to a Static VI Reference, which sounded like a vast improvement to my methodology, for the following reasons:
    1) Keeps SubVI in memory all the time, eliminating the need to put the functional global in MainVI when it is not used there.
    2) Tells LabVIEW to include SubVI when I build my executable, rather than me having to specifically mark it as Always Include in the build specification.
    3) Eliminates the need to keep the path and SubVI name updated in a string constant in my code, in order to use the Open VI Reference.
    However, trying to implement this solution, I have run into the problem that once you put a strictly-typed static VI reference (strict typing is required to keep it in memory) onto the block diagram, that VI is reserved for execution.  That means I cannot run it using the Invoke:Run method.  I haven't tried just putting it on the diagram directly as a subVI because I need it to run in parallel to the MainVI.  I have searched through these forums extensively, and although there are several references to a static VI reference, none of them say explicitly how to actually run the darn thing!  :-P
    I very much appreciate any insight into my problem.  If I have to go back to the old way it will work fine, but I really like the seeming elegance of this solution.  I hope that it is technically feasible and I'm not misunderstanding something.
    Thank you for your help,
    -Joe
    Solved!
    Go to Solution.

    > If I understand you correctly, they can only really be used for re-entrant VIs. 
    No, a static VI reference can be used anywhere a regular VI reference (property nodes etc.) The reason for the hoop-jumping above is that we are really opening a reference to a CLONE (copy) of the VI identified by the static VI reference.
    > Okay, I tried it, and got the code shown below... Any idea why it isn't working?
    The VI you want to clone can't be on the diagram as a "normal" subVI. When you run your application you should be able to open that VI and see it just sitting there with a run arrow waiting to run. See attached example (LV2009SP1).
    "share clones" vs "preallocate" has to do with whether you want each clone to preserve state (such as in an uninitialized shift register). Generally you use share clones. Occasionally it is useful to have multiple copies on a diagram that each remember some data, like "timestamp of last execution" in a shift register.
    Other VIs in your spawned process don't have to be re-entrant unless they are functions that "wait forever". All the built-in G functions are re-entrant. It's pretty common to use a queue to feed data to a spawned process.
    Spawning a process is more difficult than just running two parallel loops. It's useful because once you've made 1 copy, you can make 50. If you just want to do two things (vs n things) at once, I would just use two loops.
    Attachments:
    SpawnProcess.zip ‏20 KB

  • Pausing swfs and audio in a browser when the tab is out of focus

    I'm trying to code my flash file so that the html will pause all swfs AND audio when the tab is out of foucs.  I found this code on http://frontenddeveloper.net/wiki/index.php?title=JavaScript_and_VBScript_Injection_in_Act ionScript_3 and it works,but not completely. It only pauses the movie clips that are in the Flash file and not any that are exteranlly loaded with audio included.
    How can I adjust it to pause the externally loaded swfs that are loaded to a mc within my main movie clip and the audio OR what should I use in place of this code?  Someone mentioned on a different post that I needed to use a window.onblur funcition, but they didn't give details.
    import flash.display.MovieClip;
    import flash.utils.setTimeout;
    // This is a more "safe than sorry" setting, since multiple domains
    // have entry into my site. Can be removed or hardcoded if you feel
    // secure or insecure, as you see fit.
    flash.system.Security.allowDomain("*");
    // Throw any errors around to make sure somebody actually gets them.
    ExternalInterface.marshallExceptions = true;
    // This is not the most ideal way to toggle animations on and off, but
    // it's thorough, generic, and simple. Iterate all movieclips within
    // clip, shutting them down each in turn. A better, but much more tedious
    // method would be to target specific clips using dotpath notation, telling
    // each in turn to turn off or on depending on what we need.
    // BUT this is just a demo, and what we're really interested in is the
    // event-handling mechanism that actually calls this routine, and not the
    // routine itself.
    function toggleAllClips(doAnim, clip) {
    if ( clip is MovieClip) {
      if (doAnim) {
       clip.play();
      } else {
       clip.stop();
      for (var i = 0; i<clip.numChildren; i++) {
       toggleAllClips(doAnim, clip.getChildAt(i));
    function animOn(e:*=null) {
    toggleAllClips(true, this.mainMC);
    function animOff(e:*=null) {
    toggleAllClips(false, this.mainMC);
    function injectPrep(e:*=null) {
    try {
      ExternalInterface.addCallback("jsanimOn", animOn);
      ExternalInterface.addCallback("jsanimOff", animOff);
    } catch (e) {
      trace(e);
    function injectListeners(e:*=null) {
    try {
      // Object/Embed ID of this movie needs to be inserted into the
      // JavaScript before we actually wrap and send it to the browser:
      var jsfix=js.toString().replace(/xxx/g, ExternalInterface.objectID);
      ExternalInterface.call(jsfix);
    } catch (e) {
      trace(e);
    // Using timeouts ensures the movie is actually done loading before
    // these fire, helping compatibility for a few browser versions.
    setTimeout(injectPrep,0);
    setTimeout(injectListeners,100);
    JAVASCRIPTS
    JavaScript needs to be wrapped in a tag, a cdata, and a closure
    function in order to be wrapped up and sent to the browser.
    Note that an ActionScript function will replace all instances
    of "xxx" with the actual ID used for this SWF.
    We're battling some major bugs and crossbrowser idiosyncrasies
    here:
    1) In Internet Explorer the 'onblur' event is implemented
        incorrectly (as opposed to Firefox/Mozilla browsers). It is
        wrongly fired when focus is switched between HTML elements
        *inside* a window. As a result, we have to use onfocusout
        instead of onblur, and keep track of which element is active.
        If we focusout and the active element is not the previous
        active element, then we haven't actually "blurred" and dont
        want to trigger Flash.
    2) Firefox has problems interpreting both getElementById and
        document["swf"] when dealing with "twicebaked" object/embeds.
        Adobe's method of finding the swf fails to address the fact
        that document["swf"] sometimes returns an array in this
        situation rather than an object ref, and getElementById
        sometimes confuses name and id.
    3) When a window is created in Firefox, it doesn't actually have
        "focus" (event though it appears to) and therefore won't "blur"
        unless you actually click in it first, i.e if you open up a
        window, then immediately send it to the background, it never
        gets the command to halt the flash. So we have to explicitly
        focus the blasted thing to get it to work properly.
    4) Because of irregularities caused by Ajax, the way browsers shut
        down, and other factors, there's a good chance our swf won't
        be there when a blur (or focusout) event occurs. Therefore we
        need an explicit check within the event handler itself.
    5) Finally, we want to wrap everything inside a wrapper-closure
        function, to keep everything safe from being stepped on. Lucky
        us, we have to do this anyways to get everything to fit inside
        a single ExternalInterface.call event.
    var js:XML = <script><![CDATA[
    ( function() {
      var active_element; // tracker for ie fix;
      var bIsMSIE = false;
      // Modified version of Adobe's code resolves a bug in FF:
      function getSWF(movieName) {
        if (navigator.appName.indexOf("Microsoft") != -1) {
          return window[movieName];
        } else {
          // Resolves a bug in FF where an array is sometimes returned instead of a
          // single object when using a nested Object/Embed.
          if(document[movieName].length != undefined){
            return document[movieName][1];
          return document[movieName];
      // Need to check for swf each time we try this because the swf may actually be gone
      // because of ajax or a window closure event. Prevents error dialog from popping up.
      // Future release should check for this condition and then remove the calling event
      // so it doesn't keep triggering.
      function animOff(){
        if (bIsMSIE && (active_element != document.activeElement)) {
          active_element = document.activeElement;
        } else {
          var logoThang = getSWF("xxx");
          if(logoThang){logoThang.jsanimOff();}
      function animOn(){
        if (bIsMSIE && (active_element != document.activeElement)) {
          active_element = document.activeElement;
        } else {
          var logoThang = getSWF("xxx");
          if(logoThang){logoThang.jsanimOn();}
      // Add the listeners. Hear ye, here ye.
      if (typeof window.addEventListener !== "undefined") {
        // Firefox, Mozilla, et al.
        window.addEventListener("blur", animOff, false);
        window.addEventListener("focus", animOn, false);
      } else if (typeof window.attachEvent !== "undefined") {
        // Internet Explorer
        bIsMSIE = true;
        window.attachEvent("onfocus", animOn);
    // Another bug: window.onblur ALWAYS fires in IE, so
    // we have to keep track of what we're clicking using
    // another method:
    active_element = document.activeElement;
    document.attachEvent("onfocusout", animOff);
      // Necessary to trigger toggling in FF if the page hasn't actually been clicked in and the page
      // is sent to the background. Can be commented out if necessary, e.g. if you don't want the page
      // popping to the top or want focus to remain somewhere else like a form field.
      window.focus();
    ]]></script>;

    I added this code and it removes the externally loaded swfs.  I don't want that, I want them to pause and then resume when the tab is back in foucs.  Also, the main code restarts the main movie clip upon refocusing too.
    Added code:
    function toggleAllLoaders(doAnim, loader) {
    if ( loader is Loader) {
      if (doAnim) {
       loader.play();
      } else {
       loader.stop();
      for (var i = 0; i<loader.numChildren; i++) {
       toggleAllLoaders(doAnim, loader.getChildAt(i));
    I added the new function to all of the places that had the "toggleAllClips" function.

  • Pause Sound not working correctly

    Hi guys,
    I'm using a version of the pause sound code found on the adobe/help page, but it's not resuming the sound from the pausePoint.  I have the pause/play function tied to the stage so that my external swfs pause as well.  Here's a clip of my code,
    This is the load audio with swf part:
    var fl_Loader_5:Loader;
    var fl_ToLoad_5:Boolean = true;
    var channel:SoundChannel = new SoundChannel();
    var snd:Sound = new Sound();
    var req_1:URLRequest = new URLRequest("audio/Introduction.mp3");
    introductionButton.addEventListener(MouseEvent.CLICK, fl_ClickToLoadUnloadSWF_5);
    function fl_ClickToLoadUnloadSWF_5(event:MouseEvent):void
      SoundMixer.stopAll();
      fl_Loader_5 = new Loader();
      fl_Loader_5.load(new URLRequest("captivate/Introduction.swf"));
      parent.addChild(fl_Loader_5);
      fl_Loader_5.x = 100;
      fl_Loader_5.y = -288;
    snd.load(req_1);
      channel = snd.play();
      fl_Loader_6.unloadAndStop();
      fl_Loader_7.unloadAndStop();
      fl_Loader_8.unloadAndStop();
      fl_Loader_9.unloadAndStop();
      fl_Loader_10.unloadAndStop();
      introductionButton.removeEventListener(MouseEvent.CLICK, fl_ClickToLoadUnloadSWF_5);
    This is the stage pause and audio pause part:
    flash.system.Security.allowDomain("*");
    ExternalInterface.marshallExceptions = true;
    var originalFrameRate:uint = stage.frameRate;
    var standbyFrameRate:uint = 0;
    function toggleAllClips(doAnim, mainMC) {
    if ( parent is MovieClip){
      if (doAnim) {
    parent.stage.frameRate = originalFrameRate;
    channel = snd.play(pausePosition);
      } else {
    var pausePosition:int = channel.position;
    channel.stop();
    parent.stage.frameRate = standbyFrameRate;
      for (var i = 0; i<mainMC.numChildren; i++) {
       toggleAllClips(doAnim, mainMC.getChildAt(i));
    How do I better target the pausePoint? Do I need an equation or should I reposition the code?
    Also, the first time the stage resumes and the audio restarts from the beggining, it doesn't stop on the next pause and then a second audio track comes in on the following resume, on and on.  What gives?

    FOUND IT!!! A co-worker and I set down with your new code and brainstormed and it came down to adding another instane of the "currentSound = null;"  Here's that section of the code adjusted :
    var originalFrameRate:uint = stage.frameRate;
    var standbyFrameRate:uint = 0;
    var pausePosition:int;
    function toggleSound(b:Boolean):void{
    if(b){
      channel = currentSound.play(pausePosition);
      pausePosition = 0;
    } else {
      pausePosition = channel.position;
      channel.stop();
    function toggleAllClips(doAnim, mainMC) {
    if (parent is MovieClip){
      if (doAnim) {
    parent.stage.frameRate = originalFrameRate;
    channel = currentSound.play(pausePosition);
    pausePosition = 0;
    currentSound = null;
      } else {
    pausePosition = channel.position;
    channel.stop();
    parent.stage.frameRate = standbyFrameRate;
      for (var i = 0; i<MovieClip.(parent.parent.parent.mainMC).numChildren; i++) {
       toggleAllClips(doAnim, parent.getChildAt(i));
    I had assumed that nulling out any of the references to the original snd_1 would kill all the audio, but it didn't, it just stopped the duplicate.  Here's all of my code in case anyone has the same issue:
    Header 1
    import flash.display.Loader;
    import flash.display.MovieClip;
    import flash.utils.setTimeout;
    import com.adobe.captivate.flash.rdSound;
    import com.adobe.captivate.events.*;
    import flash.display.Sprite;
    import flash.media.Sound;
    import flash.media.SoundChannel;
    import flash.net.URLLoader;
    import flash.net.URLRequest;
    stop();
    var fl_Loader:Loader = new Loader();
    var fl_ToLoad:Boolean = true;
    parent.addChild(fl_Loader);
    fl_Loader.x = 100;
    fl_Loader.y = -288;
    var channel:SoundChannel = new SoundChannel();
    var snd_1:Sound = new Sound();
    var snd_2:Sound = new Sound();
    var snd_3:Sound = new Sound();
    var snd_4:Sound = new Sound();
    var snd_5:Sound = new Sound();
    var snd_6:Sound = new Sound();
    var currentSound:Sound;
    //SoundMixer.stopAll();
    /*var req_1:URLRequest = new URLRequest("audio/Introduction.mp3");
    var req_2:URLRequest = new URLRequest("audio/Safety.mp3");
    var req_3:URLRequest = new URLRequest("audio/Compartments.mp3");
    var req_4:URLRequest = new URLRequest("audio/Dual.mp3");
    var req_5:URLRequest = new URLRequest("audio/Switch.mp3");
    var req_6:URLRequest = new URLRequest("audio/Installation.mp3");*/
    //channel.addEventListener(Event.SOUND_COMPLETE,soundCompleteF);
    function soundCompleteF(e:Event):void{
    currentSound = null;
    SoundMixer.stopAll();
    introductionButton.addEventListener(MouseEvent.CLICK, fl_ClickToLoadUnloadSWF_5);
    function fl_ClickToLoadUnloadSWF_5(event:MouseEvent):void
      SoundMixer.stopAll();
      fl_Loader.load(new URLRequest("captivate/Introduction.swf"));
      snd_1.load(new URLRequest("audio/Introduction.mp3"));
      //channel = snd_1.play();
    //currentSound = snd_1;
      //snd_2.close();
      //snd_3.close();
      //snd_4.close();
      //snd_5.close();
      //snd_6.close();
      if(channel.hasEventListener(Event.SOUND_COMPLETE)){
      channel.removeEventListener(Event.SOUND_COMPLETE,soundCompleteF);
      channel=null;
      channel = snd_1.play();
      //snd_1.play();
      channel.addEventListener(Event.SOUND_COMPLETE,soundCompleteF);
        currentSound = snd_1;
        snd_2.close();
        snd_3.close();
        snd_4.close();
        snd_5.close();
        snd_6.close();
        introductionButton.removeEventListener(MouseEvent.CLICK, fl_ClickToLoadUnloadSWF_5);
    safetyButton.addEventListener(MouseEvent.CLICK, fl_ClickToLoadUnloadSWF_6);
    function fl_ClickToLoadUnloadSWF_6(event:MouseEvent):void
      SoundMixer.stopAll();
      fl_Loader.load(new URLRequest("captivate/Safety Considerations.swf"));
      snd_2.load(new URLRequest("audio/Safety.mp3"));
        channel = snd_2.play();
        currentSound = snd_2;
       if(channel.hasEventListener(Event.SOUND_COMPLETE)){
      channel.removeEventListener(Event.SOUND_COMPLETE,soundCompleteF);
      channel=null;
      channel = snd_2.play();
      channel.addEventListener(Event.SOUND_COMPLETE,soundCompleteF);
        currentSound = snd_2;
        snd_1.close();
        snd_3.close();
        snd_4.close();
        snd_5.close();
        snd_6.close();
    compartmentsButton.addEventListener(MouseEvent.CLICK, fl_ClickToLoadUnloadSWF_7);
    function fl_ClickToLoadUnloadSWF_7(event:MouseEvent):void
      SoundMixer.stopAll();
      fl_Loader.load(new URLRequest("captivate/Compartments.swf"));
      snd_3.load(new URLRequest("audio/Compartments.mp3"));
        channel = snd_3.play();
        currentSound = snd_3;
       if(channel.hasEventListener(Event.SOUND_COMPLETE)){
      channel.removeEventListener(Event.SOUND_COMPLETE,soundCompleteF);
      channel=null;
      channel = snd_3.play();
      channel.addEventListener(Event.SOUND_COMPLETE,soundCompleteF);
        currentSound = snd_3;
        snd_1.close();
        snd_2.close();
        snd_4.close();
        snd_5.close();
        snd_6.close();
    dualButton.addEventListener(MouseEvent.CLICK, fl_ClickToLoadUnloadSWF_8);
    function fl_ClickToLoadUnloadSWF_8(event:MouseEvent):void
      SoundMixer.stopAll();
      fl_Loader.load(new URLRequest("captivate/Dual Control Mechanism.swf"));
      snd_4.load(new URLRequest("audio/Dual.mp3"));
        channel = snd_4.play();
        currentSound = snd_4;
       if(channel.hasEventListener(Event.SOUND_COMPLETE)){
      channel.removeEventListener(Event.SOUND_COMPLETE,soundCompleteF);
      channel=null;
      channel = snd_4.play();
      channel.addEventListener(Event.SOUND_COMPLETE,soundCompleteF);
        currentSound = snd_4;
        snd_1.close();
        snd_2.close();
        snd_3.close();
        snd_5.close();
        snd_6.close();
    switchButton.addEventListener(MouseEvent.CLICK, fl_ClickToLoadUnloadSWF_9);
    function fl_ClickToLoadUnloadSWF_9(event:MouseEvent):void
      SoundMixer.stopAll();
      fl_Loader.load(new URLRequest("captivate/Switch Machine Operation.swf"));
      snd_5.load(new URLRequest("audio/Switch.mp3"));
        channel = snd_5.play();
        currentSound = snd_5;
       if(channel.hasEventListener(Event.SOUND_COMPLETE)){
      channel.removeEventListener(Event.SOUND_COMPLETE,soundCompleteF);
      channel=null;
      channel = snd_5.play();
      channel.addEventListener(Event.SOUND_COMPLETE,soundCompleteF);
        currentSound = snd_5;
        snd_1.close();
        snd_2.close();
        snd_3.close();
        snd_4.close();
        snd_6.close();
    installButton.addEventListener(MouseEvent.CLICK, fl_ClickToLoadUnloadSWF_10);
    function fl_ClickToLoadUnloadSWF_10(event:MouseEvent):void
      SoundMixer.stopAll();
      fl_Loader.load(new URLRequest("captivate/Installation and Adjustments.swf"));
      snd_6.load(new URLRequest("audio/Installation.mp3"));
        channel = snd_6.play();
        currentSound = snd_6;
       if(channel.hasEventListener(Event.SOUND_COMPLETE)){
      channel.removeEventListener(Event.SOUND_COMPLETE,soundCompleteF);
      channel=null;
      channel = snd_6.play();
      channel.addEventListener(Event.SOUND_COMPLETE,soundCompleteF);
        currentSound = snd_6;
        snd_1.close();
        snd_2.close();
        snd_3.close();
        snd_4.close();
        snd_5.close();
    // This is a more "safe than sorry" setting, since multiple domains
    // have entry into my site. Can be removed or hardcoded if you feel
    // secure or insecure, as you see fit.
    flash.system.Security.allowDomain("*");
    // Throw any errors around to make sure somebody actually gets them.
    ExternalInterface.marshallExceptions = true;
    // This is not the most ideal way to toggle animations on and off, but
    // it's thorough, generic, and simple. Iterate all movieclips within
    // clip, shutting them down each in turn. A better, but much more tedious
    // method would be to target specific clips using dotpath notation, telling
    // each in turn to turn off or on depending on what we need.
    // BUT this is just a demo, and what we're really interested in is the
    // event-handling mechanism that actually calls this routine, and not the
    // routine itself.
    var originalFrameRate:uint = stage.frameRate;
    var standbyFrameRate:uint = 0;
    var pausePosition:int;
    function toggleSound(b:Boolean):void{
    if(b){
      channel = currentSound.play(pausePosition);
      pausePosition = 0;
    } else {
      pausePosition = channel.position;
      channel.stop();
    function toggleAllClips(doAnim, mainMC) {
    if (parent is MovieClip){
      if (doAnim) {
    parent.stage.frameRate = originalFrameRate;
    channel = currentSound.play(pausePosition);
    pausePosition = 0;
    currentSound = null;
      } else {
    pausePosition = channel.position;
    channel.stop();
    //SoundMixer.stopAll();
    //currentSound = null;
    parent.stage.frameRate = standbyFrameRate;
      for (var i = 0; i<MovieClip.(parent.parent.parent.mainMC).numChildren; i++) {
       toggleAllClips(doAnim, parent.getChildAt(i));
       //toggleSound(true);
    /*function toggleSoundPause(currentSound, mainMC) {
    if(currentSound){
    if(pausePosition == 0){
      currentSound.play(pausePosition);
      pausePosition = 0;
    } else {
      pausePosition = channel.position;
      channel.stop();
    function animOn(e:*=null) {
    toggleAllClips(true, parent.getChildByName("mainMC"));
    toggleSound(true);
    function animOff(e:*=null) {
    toggleAllClips(false, parent.getChildByName("mainMC"));
    toggleSound(false);
    function injectPrep(e:*=null) {
    try {
      ExternalInterface.addCallback("jsanimOn", animOn);
      ExternalInterface.addCallback("jsanimOff", animOff);
    } catch (e) {
      trace(e);
    function injectListeners(e:*=null) {
    try {
      // Object/Embed ID of this movie needs to be inserted into the
      // JavaScript before we actually wrap and send it to the browser:
      var jsfix=js.toString().replace(/xxx/g, ExternalInterface.objectID);
      ExternalInterface.call(jsfix);
    } catch (e) {
      trace(e);
    // Using timeouts ensures the movie is actually done loading before
    // these fire, helping compatibility for a few browser versions.
    setTimeout(injectPrep,0);
    setTimeout(injectListeners,100);
    JAVASCRIPTS
    JavaScript needs to be wrapped in a tag, a cdata, and a closure
    function in order to be wrapped up and sent to the browser.
    Note that an ActionScript function will replace all instances
    of "xxx" with the actual ID used for this SWF.
    We're battling some major bugs and crossbrowser idiosyncrasies
    here:
    1) In Internet Explorer the 'onblur' event is implemented
        incorrectly (as opposed to Firefox/Mozilla browsers). It is
        wrongly fired when focus is switched between HTML elements
        *inside* a window. As a result, we have to use onfocusout
        instead of onblur, and keep track of which element is active.
        If we focusout and the active element is not the previous
        active element, then we haven't actually "blurred" and dont
        want to trigger Flash.
    2) Firefox has problems interpreting both getElementById and
        document["swf"] when dealing with "twicebaked" object/embeds.
        Adobe's method of finding the swf fails to address the fact
        that document["swf"] sometimes returns an array in this
        situation rather than an object ref, and getElementById
        sometimes confuses name and id.
    3) When a window is created in Firefox, it doesn't actually have
        "focus" (event though it appears to) and therefore won't "blur"
        unless you actually click in it first, i.e if you open up a
        window, then immediately send it to the background, it never
        gets the command to halt the flash. So we have to explicitly
        focus the blasted thing to get it to work properly.
    4) Because of irregularities caused by Ajax, the way browsers shut
        down, and other factors, there's a good chance our swf won't
        be there when a blur (or focusout) event occurs. Therefore we
        need an explicit check within the event handler itself.
    5) Finally, we want to wrap everything inside a wrapper-closure
        function, to keep everything safe from being stepped on. Lucky
        us, we have to do this anyways to get everything to fit inside
        a single ExternalInterface.call event.
    var js:XML = <script><![CDATA[
    ( function() {
      var active_element; // tracker for ie fix;
      var bIsMSIE = false;
      // Modified version of Adobe's code resolves a bug in FF:
      function getSWF(movieName) {
        if (navigator.appName.indexOf("Microsoft") != -1) {
          return window[movieName];
        } else {
          // Resolves a bug in FF where an array is sometimes returned instead of a
          // single object when using a nested Object/Embed.
          if(document[movieName].length != undefined){
            return document[movieName][1];
          return document[movieName];
      // Need to check for swf each time we try this because the swf may actually be gone
      // because of ajax or a window closure event. Prevents error dialog from popping up.
      // Future release should check for this condition and then remove the calling event
      // so it doesn't keep triggering.
      function animOff(){
        if (bIsMSIE && (active_element != document.activeElement)) {
          active_element = document.activeElement;
        } else {
          var logoThang = getSWF("xxx");
          if(logoThang){logoThang.jsanimOff();}
      function animOn(){
        if (bIsMSIE && (active_element != document.activeElement)) {
          active_element = document.activeElement;
        } else {
          var logoThang = getSWF("xxx");
          if(logoThang){logoThang.jsanimOn();}
      // Add the listeners. Hear ye, here ye.
      if (typeof window.addEventListener !== "undefined") {
        // Firefox, Mozilla, et al.
        window.addEventListener("blur", animOff, false);
        window.addEventListener("focus", animOn, false);
      } else if (typeof window.attachEvent !== "undefined") {
        // Internet Explorer
        bIsMSIE = true;
        window.attachEvent("onfocus", animOn);
    // Another bug: window.onblur ALWAYS fires in IE, so
    // we have to keep track of what we're clicking using
    // another method:
    active_element = document.activeElement;
    document.attachEvent("onfocusout", animOff);
      // Necessary to trigger toggling in FF if the page hasn't actually been clicked in and the page
      // is sent to the background. Can be commented out if necessary, e.g. if you don't want the page
      // popping to the top or want focus to remain somewhere else like a form field.
    // window.focus();
    ]]></script>;
    Thanks you SOOO MUCH for your help.  There is no way I could have done this alone and now I have a better understanding about referencing vars.
    Thanks,
    Elena

Maybe you are looking for

  • Receive java.lang.NullPointerException (JCA-12563) on SCA with Stored Procedure dbAdapter (SOA Suite 12.1.3)

    Hi, I'm new to the Oracle SOA Suite and have been creating very simple SCA WebServices (async and sync) prototypes to INSERT, UPDATE and Poll Oracle 9i and 11g databases. So far, everything works and passes the tests from EM. I cannot get the Stored

  • Setting for MobileONE (M1) MMS

    Just to share this information to any M1 user on the iPhone3G Setting->General->Network->Cellular Data Setting APN: miworld Username: 65 Password: user123 MMSC: http://mmsgw:8002/ MMS Proxy: 172.16.14.10:8080 MMS Max Message Size: Once you input the

  • Can anyone explain this Calendar beheaviour?

    This is my code public static void main(String[] args) { Calendar checkDate = Calendar.getInstance(); System.out.println(checkDate.getTime()); checkDate.set(Calendar.HOUR, 23); System.out.println(checkDate.getTime()); checkDate.set(Calendar.MINUTE, 5

  • Native sequencing problem

    Hi all, I'm using Oracle9i database together with TopLink 9.0.4 and I can't get started native sequencing. I've created a sequence using following script: CREATE SEQUENCE "ITMS"."SEQUENCE" INCREMENT BY 1 START WITH 1 MAXVALUE 1.0E28 MINVALUE 1 NOCYCL

  • Sorry to say IE7 gives a better experience in this instance for me

    I love my Mac but the constant keyboard taps I have to make to make a new tab are time consuming and annoying. Why does Safari not load with a dead tab - in hand, similar to IE? and when you use that secondary tab tab another greyed out tab is auto g