dcsimg
A Flash Developer Resource Site

Page 1 of 2 12 LastLast
Results 1 to 20 of 26

Thread: How to stop the FLV sound, not playing in all pages?

Hybrid View

  1. #1
    Junior Member
    Join Date
    Jan 2010
    Posts
    10

    How to stop the FLV sound, not playing in all pages?

    I followed a tutorial using AC3 and flash CS4, to build a website for myself. Want to have a video file in my site with back ground music and sound effect. I did fine doing it but there is some problem I cannot figure out. My movie clip starts nice but half way through when I go to other pages, the sound and music plays in all the other pages. I have zero knowledge about coding and English is my second language. How can I stop that playing in other pages? I am trying hard to see if someone had same problem like I do but can's find anyone posted any thing.
    Would someone please help me out on this? I am so frustrated.
    Please help me out! I really really appreciate your help.


    This is the code I have for that page with video on it.

    var modelingboardTween:Tween = new Tween(modelingboard_mc, "y", Elastic.easeOut, 710, 0, 3, true);

    modelingboardTween.addEventListener(TweenEvent.MOT ION_FINISH,donePlaying);

    function donePlaying(e:TweenEvent):void{
    trace("done playing!");
    modelingboard_mc.modelingVideo.play();

    }


    and this is the code I have in my first frame for all the pages.


    stop();

    //Animate in the homeboard_mc from right to left, using the Tween class.

    //Flash - go get code that's going to make the tween work...
    import fl.transitions.Tween;
    import fl.transitions.TweenEvent;
    import fl.transitions.easing.*;

    //homeboard_mc animation - animate in...
    var homeboardTween:Tween = new Tween(homeboard_mc, "x", Elastic.easeOut, 1130, 160, 3, true);




    //handle events for buttons...
    modeling.addEventListener(MouseEvent.CLICK, clickSection);
    home.addEventListener(MouseEvent.CLICK, clickSection);
    animation.addEventListener(MouseEvent.CLICK, clickSection);
    artwork.addEventListener(MouseEvent.CLICK, clickSection);
    contact.addEventListener(MouseEvent.CLICK, clickSection);
    function clickSection(evtObj:MouseEvent){
    //trace shows what's happening.. in the output window
    trace ("The "+evtObj.target.name+" button was clicked!")
    //go to the section clicked on...
    gotoAndStop(evtObj.target.name);
    }

  2. #2
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    From the video page how do you navigate to other pages?
    - The right of the People to create Flash movies shall not be infringed. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  3. #3
    Junior Member
    Join Date
    Jan 2010
    Posts
    10

    Navigation

    Hi thanks for your reply.
    For navigation I have buttons on the top. Lets say I am in modeling page when a video is playing, then I go to another page after click on one of those buttons and the music from previous page plays in every other page I visit. Is that any way I can send you my swf file so you can see what I am talking about??

  4. #4
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    Into the button script of the navigation buttons you must add something like

    modelingboard_mc.modelingVideo.stop();

    or

    modelingboard_mc.modelingVideo.close();

    However, you need to check
    1. the path to the videoplayer and
    2. the button scripts need to be in the location/frame where the videoplayer is. If the scripts are in a location where is not videoplayer you will get an error.
    - The right of the People to create Flash movies shall not be infringed. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  5. #5
    Junior Member
    Join Date
    Jan 2010
    Posts
    10
    Yeah the path for the video is inside that modelingboard_mc and it starts at frame 10 in the time line. So I went to that frame, select it in my action/labels layer and added your code, but it doesn't work. I did go to other pages and added your code but it messed up every thing else. I am trying every thing to make it work but I don't know what to do?

  6. #6
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    What kind of videoplayer do you have, the component or custom video? Did you do a trace like
    trace(modelingboard_mc.modelingVideo);
    Last edited by cancerinform; 01-09-2010 at 02:27 PM.
    - The right of the People to create Flash movies shall not be infringed. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  7. #7
    Junior Member
    Join Date
    Jan 2010
    Posts
    10
    yeah it's a flv file which has no stop or play and it plays after the page loaded. I did the encode with flash encoder 8, when I imported it to flash cs4, I choose none so doesn't have any skin, it plays as it starts. You see if the video didn't have music or sound that would work just fine but I want to use it for my demo reel and it has to have sounds. I cannot take those off.

  8. #8
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    Are you using the component from the component menu?
    - The right of the People to create Flash movies shall not be infringed. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  9. #9
    Junior Member
    Join Date
    Jan 2010
    Posts
    10
    for the buttons do you mean? I did design them. I don't think from here I can do it. I need someone to take a look at my file.

  10. #10
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    No for playing the flv. How do you play it?
    - The right of the People to create Flash movies shall not be infringed. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  11. #11
    Junior Member
    Join Date
    Jan 2010
    Posts
    10
    ohh sorry dude,
    yes it is a component. Under windows_ Component inspector I clicked on autoplay and set it to false instead of true. But no matter what I change in component inspector, it doesn't work and the music still playing in every page I visit. I was able to make the video stop any time I visit other page and go back to video section again but the music wont stop.

  12. #12
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    Then modelingboard_mc.modelingVideo.pause() or modelingboard_mc.modelingVideo.stop() should work. However by using trace(modelingboard_mc.modelingVideo); make sure that the path is correct.
    - The right of the People to create Flash movies shall not be infringed. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  13. #13
    Junior Member
    Join Date
    Jan 2010
    Posts
    10
    I entered the code you gave me like this:

    var modelingboardTween:Tween = new Tween(modelingboard_mc, "y", Elastic.easeOut, 710, 0, 3, true);

    modelingboardTween.addEventListener(TweenEvent.MOT ION_FINISH,donePlaying);

    function donePlaying(e:TweenEvent):void{
    trace("done playing!");
    modelingboard_mc.modelingVideo.play();
    modelingboard_mc.modelingVideo.pause();


    }


    but now the video doesn't play at all. It stops before start. Is that a code to tell flash to not play in other pages?
    Man I really really appreciate that you take time doing this with me. If we get it to work I will gladly offer you some money if you want. But so far no luck.

  14. #14
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    modelingboard_mc.modelingVideo.pause(); or stop() will of course stop the video and yes, that is what you need to place into the button scripts for the buttons when you exit the video frame(s).
    - The right of the People to create Flash movies shall not be infringed. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  15. #15
    Junior Member
    Join Date
    Jan 2010
    Posts
    10
    sorry man for not getting it. Like I said I've never done coding and English is my second language. Forgive my stupidity. But again I did try before going to button mc trying to add that stop in there but it messes up all the other pages. I did it now when you told me and same thing happened. It doesn't work. My buttons are made of three different images. I made one button out of them. Should I try and make it only one image and then make that a button or that is not a problem? God I wanna die...

  16. #16
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    Ok, don't die, we don't do funerals on Flashkit.
    Post your fla or a simplified example with buttons and video component.
    ...And English is my second language too
    - The right of the People to create Flash movies shall not be infringed. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  17. #17
    Junior Member
    Join Date
    Jan 2010
    Posts
    10
    Thanks man I sent it to you.

  18. #18
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    I am showing this, since this is a forum and others may also be interested in the solution.

    The main problem is that when the frame with the videoplayer is left the video does not stop or at least the audio continues. Here is the solution. You create a Boolean var playVideo and set it false in frame 1. In frame 10 you set it to true and add a listener, which listens to frame changes. Here is the modified code for frame 10:
    PHP Code:
    playVideo true;

    modelingboard_mc.modelingVideo.play ();
    modelingboard_mc.addEventListener (Event.EXIT_FRAMEframeExit);

    function 
    frameExit (e:Event):void
    {
        if (
    playVideo == false)
        {
            
    e.currentTarget.removeEventListener(Event.EXIT_FRAMEframeExit);
            
    modelingboard_mc.modelingVideo.stop ();
        }

    However, if we leave it like this and just add
    playVideo = false;
    in the listener function of all the buttons except for modeling we will get an error, because the frame with the video has left and then the videoplayer is null. So we need to add a delay in the response to go to another frame. Here is the modified script of frame 1:
    PHP Code:
    import flash.utils.setTimeout;
    //
    stop ();
    var 
    playVideo:Boolean false;
    //handle events for buttons...
    modeling.addEventListener (MouseEvent.CLICKclickSection);
    home.addEventListener (MouseEvent.CLICKclickSection);
    animation.addEventListener (MouseEvent.CLICKclickSection);
    artwork.addEventListener (MouseEvent.CLICKclickSection);
    contact.addEventListener (MouseEvent.CLICKclickSection);
    function 
    clickSection (evtObj:MouseEvent)
    {
        if (
    evtObj.currentTarget.name != "modeling")
        {
            
    playVideo false;
        }
        var 
    myTime:int setTimeout(closeVideo,500);
        function 
    closeVideo ():void
        
    {
            
    trace ("The "+evtObj.target.name+" button was clicked!");
            
    gotoAndStop (evtObj.target.name);
        }

    We have a delay of 500ms to leave the video frame, which is enough time to stop the video from playing.
    - The right of the People to create Flash movies shall not be infringed. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  19. #19
    Junior Member
    Join Date
    Jan 2010
    Posts
    10
    This is great. It did work for me. Thank you so much for the time you spent.

  20. #20
    Junior Member
    Join Date
    Nov 2010
    Posts
    5
    hi. i am doing a uni project and have the same problem.
    i've read though all the posts but i find it very hard to understand the actionscript as this is the first time using it.
    i have a video playing on a page but when i use the back button the video is still playing(you can hear it) the video is in a flv video playback so doesn't have any actionscript for it. the only action script i've got for that page is the back button.
    Is there anyway to stop the flv playback when the back button is clicked?
    Thank you

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