7 Replies Latest reply on Jun 16, 2009 11:48 AM by kglad

    MC not playing on first hover

    MicahPotter

      I have some movieclips that play when you hover over them and rewind when you mouse out. Now I've added a click event to the MCs also and now the first time you hover over them, nothing happens. But the second time works just fine.The MCs that don't have the click event work fine using the same code.

       

      Any Ideas, I've been fighting this for too long now.

       

      Thanks in advance

       

      you can view the movie at www.micahanderica.com/mynewwalk

        • 1. Re: MC not playing on first hover
          kglad Adobe Community Professional & MVP

          show the over, out and click handlers for one of your problematic buttons.

          • 2. Re: MC not playing on first hover
            MicahPotter Level 1

            ~This code is at the root level.~

             


            var victim:MovieClip;
            var my_sound:Sound = new Sound();
            var soundPlaying:Boolean = false;
            var mute:Boolean = false;
            var contentOpen:Boolean = false;

            function rewind(passed_mc:MovieClip, frame_count:Number) {
            _root.circles_back_mc.onEnterFrame = function() {
              if (frame_count>0) {
               passed_mc.prevFrame();
               frame_count--;
              }
            };
            }//Rewind Function

            function mcRollOver(passed_mc:MovieClip, start_frame:Number, stop_frame:Number, frame_count:Number) {

            frame_count = stop_frame-start_frame;
            passed_mc.onRollOver = function() {
              if (passed_mc._currentFrame == start_frame) {
               passed_mc.play();
              }
            };
            if (!passed_mc.hitTest(_xmouse, _ymouse, true)) {
              if (passed_mc._currentFrame == stop_frame) {
               rewind(passed_mc,frame_count);
              }
            }
            }//mcRollOver Function

            function chooseVictim():MovieClip{
            if(service_times_mc.hitTest(_xmouse, _ymouse, true)){
              victim = service_times_mc;  
            }else if(the_series_mc.hitTest(_xmouse, _ymouse, true)){
              victim = the_series_mc;  
            }else if(pasco_ymca_mc.hitTest(_xmouse, _ymouse, true)){
              victim = pasco_ymca_mc;  
            }else if(giving_online_mc.hitTest(_xmouse, _ymouse, true)){
              victim = giving_online_mc;  
            }else if(connection_groups_mc.hitTest(_xmouse, _ymouse, true)){
              victim = connection_groups_mc;  
            }else if(children_youth_mc.hitTest(_xmouse, _ymouse, true)){
              victim = children_youth_mc;  
            }else if(get_involved_mc.hitTest(_xmouse, _ymouse, true)){
              victim = get_involved_mc;  
            }else if(about_us_mc.hitTest(_xmouse, _ymouse, true)){
              victim = about_us_mc;  
            }else if(online_campus_mc.hitTest(_xmouse, _ymouse, true)){
              victim = online_campus_mc;  
            }
            return(victim);
            }//chooseVictim Function

            stop();


            this.onEnterFrame = function() {

            mcRollOver(chooseVictim(),35,45);

            if(!soundPlaying){
              my_sound.loadSound("mynewwalk.mp3", true);
              my_sound.start(0, 9999);
              my_sound.setVolume(10);
              soundPlaying = true;
            }


            mute_mc.addEventListener(MouseEvent.CLICK, handleClick);


            mute_mc.onRelease = function() {
              //popThickBox("newwalkonline.html?KeepThis=true&TB_iframe=true&height=800&width=800");
              if(!mute){
               my_sound.setVolume(0);
               mute = true;
              }else{
               my_sound.loadSound("mynewwalk.mp3", true);
               my_sound.start(0, 9999);
               my_sound.setVolume(10);
               mute = false;
              }
            }; 
            };

             

            This code works up until I put the following code inside one of the MCs.:

             

            import flash.external.ExternalInterface;
            onRelease = function() {
            ExternalInterface.call("tb_show" , null, "online_campus.php?KeepThis=true&TB_iframe=true&height=800&width=800", false);};
            stop();

            • 3. Re: MC not playing on first hover
              kglad Adobe Community Professional & MVP

              there are several problems with that code. 

               

              1.  your rewind function will "rewind", at most, one movieclip at a time.   you should use a child mc of passed_mc for you enterframe loop.

               

              2.  frame_count shouldn't be passed to mcRollOver.  that parameter is never used.

               

              3. the if-condition in passed_mc.onRollOver isn't correct.  you should check if the _currentframe is less stop_frame to determine whether to play() or not.

               

              4. you're calling mcRollOver repeatedly and in an enterframe loop and you don't want to repeatedly defined passed_mc.onRollOver

               

              5.  mute_mc is using as3 code to detect a mouse click and the rest of the code is as2.

               

              6.  mute_mc has an onRelease method that's repeatedly defined in an enterframe loop.

               

              7.  i'm not sure what you mean by that last onRelease but you can only have one onRelease per movieclip so if that's applied to a movieclip that already has an onRelease method the previous will be voided.

              • 4. Re: MC not playing on first hover
                MicahPotter Level 1

                ~updated code~

                 

                import flash.external.ExternalInterface;

                 

                var victim:MovieClip;
                var my_sound:Sound = new Sound();
                var soundPlaying:Boolean = false;
                var mute:Boolean = false;
                var contentOpen:Boolean = false;

                function rewind(passed_mc:MovieClip, frame_count:Number) {
                passed_mc.timer_mc.onEnterFrame = function() {
                  if (frame_count>0) {
                   passed_mc.prevFrame();
                   frame_count--;
                  }
                };
                }//Rewind Function

                function mcRollOver(passed_mc:MovieClip, start_frame:Number, stop_frame:Number) {

                var frame_count = stop_frame-start_frame;

                if (passed_mc.hitTest(_xmouse, _ymouse, true)) {
                  if (passed_mc._currentFrame < stop_frame) {
                   passed_mc.play();
                  }
                }

                if (!passed_mc.hitTest(_xmouse, _ymouse, true)) {
                  if (passed_mc._currentFrame == stop_frame) {
                   rewind(passed_mc,frame_count);
                  }
                }
                }//mcRollOver Function

                function chooseVictim():MovieClip{
                if(service_times_mc.hitTest(_xmouse, _ymouse, true)){
                  victim = service_times_mc;  
                }else if(the_series_mc.hitTest(_xmouse, _ymouse, true)){
                  victim = the_series_mc;  
                }else if(pasco_ymca_mc.hitTest(_xmouse, _ymouse, true)){
                  victim = pasco_ymca_mc;  
                }else if(giving_online_mc.hitTest(_xmouse, _ymouse, true)){
                  victim = giving_online_mc;  
                }else if(connection_groups_mc.hitTest(_xmouse, _ymouse, true)){
                  victim = connection_groups_mc;  
                }else if(children_youth_mc.hitTest(_xmouse, _ymouse, true)){
                  victim = children_youth_mc;  
                }else if(get_involved_mc.hitTest(_xmouse, _ymouse, true)){
                  victim = get_involved_mc;  
                }else if(about_us_mc.hitTest(_xmouse, _ymouse, true)){
                  victim = about_us_mc;  
                }else if(online_campus_mc.hitTest(_xmouse, _ymouse, true)){
                  victim = online_campus_mc;  
                }
                return(victim);
                }//chooseVictim Function

                if(!soundPlaying){
                my_sound.loadSound("mynewwalk.mp3", true);
                my_sound.start(0, 9999);
                my_sound.setVolume(10);
                soundPlaying = true;
                }//start sound

                mute_mc.onRelease = function() {
                //popThickBox("newwalkonline.html?KeepThis=true&TB_iframe=true&height=800&width=800");
                if(!mute){
                  my_sound.setVolume(0);
                  mute = true;
                }else{
                  my_sound.loadSound("mynewwalk.mp3", true);
                  my_sound.start(0, 9999);
                  my_sound.setVolume(10);
                  mute = false;
                }
                };//mute_mc onrelease

                pasco_ymca_mc.onRelease = function() {
                ExternalInterface.call("tb_show" , null, "ymca.php?KeepThis=true&TB_iframe=true&height=100%&width=100%", false);
                };

                giving_online_mc.onRelease = function() {
                ExternalInterface.call("tb_show" , null, "giving_online.php?KeepThis=true&TB_iframe=true&height=100%&width=100%", false);
                };

                get_involved_mc.onRelease = function() {
                ExternalInterface.call("tb_show" , null, "get_involved.php?KeepThis=true&TB_iframe=true&height=100%&width=100%", false);
                };

                about_us_mc.onRelease = function() {
                ExternalInterface.call("tb_show" , null, "about_us.php?KeepThis=true&TB_iframe=true&height=100%&width=100%", false);
                };

                connection_groups_mc.onRelease = function() {
                ExternalInterface.call("tb_show" , null, "connection_groups.php?KeepThis=true&TB_iframe=true&height=100%&width=100%", false);
                };

                children_youth_mc.onRelease = function() {
                ExternalInterface.call("tb_show" , null, "children_youth.php?KeepThis=true&TB_iframe=true&height=100%&width=100%", false);
                };

                online_campus_mc.onRelease = function() {
                ExternalInterface.call("tb_show" , null, "online_campus.php?KeepThis=true&TB_iframe=true&height=100%&width=100%", false);
                };

                service_times_mc.onRelease = function() {
                ExternalInterface.call("tb_show" , null, "service_times.php?KeepThis=true&TB_iframe=true&height=100%&width=100%", false);
                };

                the_series_mc.onRelease = function() {
                ExternalInterface.call("tb_show" , null, "the_series.php?KeepThis=true&TB_iframe=true&height=100%&width=100%", false);
                };

                 


                stop();

                this.onEnterFrame = function() {

                mcRollOver(chooseVictim(),35,45);

                };

                 

                ~all seems to be working fine except rewind will still only rewind one mc at a time. (www.micahanderica.com/mynewwalk)~

                Thank you for your help!

                • 5. Re: MC not playing on first hover
                  kglad Adobe Community Professional & MVP

                  mcRollOver is being called repeatedly.  therefore, rewind is being called repeatedly and your onEnterFrame is being defined repeatedly.

                  1 person found this helpful
                  • 6. Re: MC not playing on first hover
                    MicahPotter Level 1

                    Thanks for your help K.

                    I've got it now.

                    • 7. Re: MC not playing on first hover
                      kglad Adobe Community Professional & MVP

                      you're welcome.