Javascript to unload or stop Flash?
A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Javascript to unload or stop Flash?

  1. #1
    Junior Member
    Join Date
    Dec 2002
    Location
    Montreal, Canada
    Posts
    14

    Javascript to unload or stop Flash?

    Hi all,

    I am curently assembling some Macromedia Captivate Flash movie on one web page for my students.

    When my user clicks on one of my links, a javascript function makes my DIV content visible simulating a modal window. After, when my user clicks on my X icon I then hide the DIV (visibility:hidden).

    All works well but my embedded Flash continues playing! (well I hear the sound cause the DIV is now hidden...)

    How can I flush-unload-stop the player elegantly from a javascript function? I must not run into memory issues cause my students can peek at many videos within a session.

    Thanks for reading!
    Live a 100 years, study a 100 years!

  2. #2
    Senior Member
    Join Date
    Jul 2003
    Posts
    156
    I did this exact thing about a year ago and for the life of me I can't remember off the top of my head. I will look around and try and remember what site it was for then try and find the files. If you haven't got a response by then I will post. I may not get back till tomorrow, but I will.

  3. #3
    Senior Member
    Join Date
    Jul 2003
    Posts
    156
    I just remebered...You have to put your closing "X" in the flash. Then you can stop the movie/sounds whatever and call your javascript function to hide the div.

  4. #4
    Junior Member
    Join Date
    Dec 2002
    Location
    Montreal, Canada
    Posts
    14
    With Macromedia Captivate all is automatic. It assembles the HTML embedding the SWF file.

    Actually I am displaying this HTML file through an Iframe within a DIV for wich I change the VISIBILITY attribute.

    I am producing a lot of short movies and don't want to go into the SWF (yes I have a decompiler!). So in this context I really need to control the movie from the browser's JAVASCRIPT.

    Any Javascript API for Flash out there?
    Live a 100 years, study a 100 years!

  5. #5
    If I understand you correctly, your HTML is Div -> IFrame -> Flash

    A hack could be to change the location of the iframe to a blank page while the div is hidden. This may not be acceptable for you as the flash movie will be restarted every time the div is unhidden.

  6. #6
    Junior Member
    Join Date
    Dec 2002
    Location
    Montreal, Canada
    Posts
    14
    Found a work around!

    When my user clicks on a link, it bumps the current movie by a new one. So I simply built a web page embedding a one frame movie with the Stop_All_Sound(); built in actionscript function!

    Here is some code:


    function loadContent(URL, idName, my_width, my_height) {
    var objetDom = document.getElementById(idName);

    document.getElementById("main").style.visibility = "visible";
    objetDom.src = URL;
    objetDom.width=my_width;
    objetDom.height=my_height;
    }


    function close(idName) {

    loadContent("http://abc.abc.com/stopAllSounds.html","my_DIV",500,500);
    document.getElementById(idName).style.visibility = "hidden";
    }
    =================
    Salut et la prochaine!
    Live a 100 years, study a 100 years!

  7. #7
    Junior Member
    Join Date
    Feb 2008
    Posts
    1

    Thumbs up Can I have the script sample..

    I have been searching around the web and finally I found the right one.... Please can you share the script with me....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width


HTML5 Development Center

Poll by Flashkit.com