Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jun 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Stop sound in a loaded swf from main gallery file

    Have a gallery that loads external files (as per following script). The gallery loads six different .swf's. Each .swf has its own sound file that can be controlled to play or stop from withing each file.

    play_btn.addEventListener(MouseEvent.CLICK,clickhandler);
    stop_btn.addEventListener(MouseEvent.CLICK,clickhandler)
    function clickhandler(event:MouseEvent):void{
    swapChildren(play_btn,stop_btn);
    }

    Would like to be able to control the sound of each of the loaders. When the main file opens it loads the first file by default. All other files are loaded using the loaders 2-3-4-5-6.
    The sound of each individual file can be played and stopped using the play_btn and stop_btn
    within the file. However, if another loader is selected while a sound is playing it continues to play over the new loaded file. If the new file sound is played, it plays over the previous sound.
    My goal is to be able to stop any on stage sound when a new loader is selected.

    Can you please help???

    Thanks.

    Look forward to your repply.

    SCRIPTS --

    // Set the name of the external folder your big pics and thumbs are in
    var galleryFolder:String = "db1_1";
    /////////////////////////////////////////////////////////////////////////////////////////

    // Thumbs Setup, Create loader instances for each thumb
    var pic1ldr:Loader = new Loader();
    var pic2ldr:Loader = new Loader();
    var pic3ldr:Loader = new Loader();
    var pic4ldr:Loader = new Loader();
    var pic5ldr:Loader = new Loader();
    var pic6ldr:Loader = new Loader();

    // Set the URLRequest for each little thumbnail, notice how we reference "galleryFolder"
    var thumb1Req:URLRequest = new URLRequest(galleryFolder + "/thumbs/Table01.jpg");
    var thumb2Req:URLRequest = new URLRequest(galleryFolder + "/thumbs/Table02.jpg");
    var thumb3Req:URLRequest = new URLRequest(galleryFolder + "/thumbs/Table01.jpg");
    var thumb4Req:URLRequest = new URLRequest(galleryFolder + "/thumbs/Table02.jpg");
    var thumb5Req:URLRequest = new URLRequest(galleryFolder + "/thumbs/Table01.jpg");
    var thumb6Req:URLRequest = new URLRequest(galleryFolder + "/thumbs/Table02.jpg");

    // Load each URLRequested thumb image into its pic loader
    pic1ldr.load(thumb1Req);
    pic2ldr.load(thumb2Req);
    pic3ldr.load(thumb3Req);
    pic4ldr.load(thumb4Req);
    pic5ldr.load(thumb5Req);
    pic6ldr.load(thumb6Req);


    // Then add the above to the stage movieclips waiting there to finally display thumbs
    // These become your buttons, we code them out now below to make them full fledged buttons
    thumbLoader1.addChild(pic1ldr);
    thumbLoader2.addChild(pic2ldr);
    thumbLoader3.addChild(pic3ldr);
    thumbLoader4.addChild(pic4ldr);
    thumbLoader5.addChild(pic5ldr);
    thumbLoader6.addChild(pic6ldr);


    // Set each button to show mouse hand pointer on ROLL_OVER like it should
    thumbLoader1.buttonMode = true;
    thumbLoader2.buttonMode = true;
    thumbLoader3.buttonMode = true;
    thumbLoader4.buttonMode = true;
    thumbLoader5.buttonMode = true;
    thumbLoader6.buttonMode = true;


    // Add event listeners for each thumb CLICK function
    thumbLoader1.addEventListener(MouseEvent.CLICK, thumb1click);
    thumbLoader2.addEventListener(MouseEvent.CLICK, thumb2click);
    thumbLoader3.addEventListener(MouseEvent.CLICK, thumb3click);
    thumbLoader4.addEventListener(MouseEvent.CLICK, thumb4click);
    thumbLoader5.addEventListener(MouseEvent.CLICK, thumb5click);
    thumbLoader6.addEventListener(MouseEvent.CLICK, thumb6click);

    // Add event listeners for each thumb ROLL_OVER function
    thumbLoader1.addEventListener(MouseEvent.ROLL_OVER, thumb1over);
    thumbLoader2.addEventListener(MouseEvent.ROLL_OVER, thumb2over);
    thumbLoader3.addEventListener(MouseEvent.ROLL_OVER, thumb3over);
    thumbLoader4.addEventListener(MouseEvent.ROLL_OVER, thumb4over);
    thumbLoader5.addEventListener(MouseEvent.ROLL_OVER, thumb5over);
    thumbLoader6.addEventListener(MouseEvent.ROLL_OVER, thumb6over);

    // Add event listeners for each thumb ROLL_OUT function
    thumbLoader1.addEventListener(MouseEvent.ROLL_OUT, thumb1out);
    thumbLoader2.addEventListener(MouseEvent.ROLL_OUT, thumb2out);
    thumbLoader3.addEventListener(MouseEvent.ROLL_OUT, thumb3out);
    thumbLoader4.addEventListener(MouseEvent.ROLL_OUT, thumb4out);
    thumbLoader5.addEventListener(MouseEvent.ROLL_OUT, thumb5out);
    thumbLoader6.addEventListener(MouseEvent.ROLL_OUT, thumb6out);


    // Set what happens to white backgrounds on their OVER state
    function thumb1over(event:MouseEvent):void { whiteBG1.gotoAndPlay("over"); }
    function thumb2over(event:MouseEvent):void { whiteBG2.gotoAndPlay("over"); }
    function thumb3over(event:MouseEvent):void { whiteBG3.gotoAndPlay("over"); }
    function thumb4over(event:MouseEvent):void { whiteBG4.gotoAndPlay("over"); }
    function thumb5over(event:MouseEvent):void { whiteBG5.gotoAndPlay("over"); }
    function thumb6over(event:MouseEvent):void { whiteBG6.gotoAndPlay("over"); }


    // Set what happens to white backgrounds on their OUT state
    function thumb1out(event:MouseEvent):void { whiteBG1.gotoAndPlay("out"); }
    function thumb2out(event:MouseEvent):void { whiteBG2.gotoAndPlay("out"); }
    function thumb3out(event:MouseEvent):void { whiteBG3.gotoAndPlay("out"); }
    function thumb4out(event:MouseEvent):void { whiteBG4.gotoAndPlay("out"); }
    function thumb5out(event:MouseEvent):void { whiteBG5.gotoAndPlay("out"); }
    function thumb6out(event:MouseEvent):void { whiteBG6.gotoAndPlay("out"); }


    // Assign variable names and URLRequest for each big pic here
    var img1Req:URLRequest = new URLRequest(galleryFolder + "/a80a.swf");
    var img2Req:URLRequest = new URLRequest(galleryFolder + "/a81_Flag.swf");
    var img3Req:URLRequest = new URLRequest(galleryFolder + "/a82.swf");
    var img4Req:URLRequest = new URLRequest(galleryFolder + "/a83.swf");
    var img5Req:URLRequest = new URLRequest(galleryFolder + "/a83a.swf");
    var img6Req:URLRequest = new URLRequest(galleryFolder + "/a84.swf");


    // Assign variable name for the Loader, for use in our functions below
    var big_pic:Loader = new Loader();
    // Set first big pic into the frame now so it is not empty at start up, and display caption 1 with the next 3 lines
    big_pic.load(img1Req);
    frame_mc.addChild(big_pic);
    // Now we code out each thumb button function, what it does when clicked
    // I will comment out and explain the first, all the rest are almost identical to the first
    function thumb1click(event:MouseEvent):void {
    big_pic.load(img1Req);
    if(frame_mc.numChildren>1){
    frame_mc.removeChildAt(1);
    }
    frame_mc.addChild(big_pic);
    stage.frameRate = 60;
    }
    function thumb2click(event:MouseEvent):void {
    big_pic.load(img2Req);
    if(frame_mc.numChildren>1){
    frame_mc.removeChildAt(1);
    }
    frame_mc.addChild(big_pic);
    stage.frameRate = 60;
    }

    function thumb3click(event:MouseEvent):void {
    big_pic.load(img3Req);
    if(frame_mc.numChildren>1){
    frame_mc.removeChildAt(1);
    }
    frame_mc.addChild(big_pic);
    stage.frameRate =60;
    }
    function thumb4click(event:MouseEvent):void {
    big_pic.load(img4Req);
    if(frame_mc.numChildren>1){
    frame_mc.removeChildAt(1);
    }
    frame_mc.addChild(big_pic);
    stage.frameRate =60;
    }
    function thumb5click(event:MouseEvent):void {
    big_pic.load(img5Req);
    if(frame_mc.numChildren>1){
    frame_mc.removeChildAt(1);
    }
    frame_mc.addChild(big_pic);
    stage.frameRate =60;
    }
    function thumb6click(event:MouseEvent):void {
    big_pic.load(img6Req);
    if(frame_mc.numChildren>1){
    frame_mc.removeChildAt(1);
    }
    frame_mc.addChild(big_pic);
    stage.frameRate =30;

  • #2
    New to the CF scene
    Join Date
    Jul 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    اندي لوماكس تمتلك وتدير مجد تصميم الموقع واحدة من أبرز شركات تصميم مواقع الإنترنت في مانشستر. وقد عمل دون كلل في صناعة الإنترنت لأكثر من 10 عاما، ونصحت المئات من الشركات حول مواقعها على شبكة الإنترنت واستراتيجيات التسويق عبر الإنترنت. توفر مجد تصميم المواقع وتطوير الشبكة
    عند البدء في بناء عملك على الانترنت والبحث عن شركة تصميم مواقع الإنترنت التي من شأنها تنفيذ جميع الاحتياجات الخاصة بك لموقع على شبكة الإنترنت يجب أن نفهم أن ذلك هو خطوة خطيرة جدا لأنك تكليف عملك جنبا إلى جنب مع سمعتها والمستقبل.
    شركات تصميم وبرمجة المواقع|شركات تصميم مواقع


  •  

    Tags for this Thread

    Posting Permissions

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