7 Replies Latest reply on Sep 29, 2006 2:04 PM by Nickels55

    Run SWF on mouseover

      I’m very new at this, but I have created a flash file and added it to a web page and would like it to start running when someone mouses over the image. Can anybody explain if or how I can do it in very easy terms?
      Thanks for any help anybody can provide.
        • 1. Re: Run SWF on mouseover
          Realtoast Level 1
          I am no expert, myself. But, one way to do this would be to:
          1. keep your main timeline clean. In other words, don't make your main movie in the main timeline. Instead, make your movie a movieclip that you would then place in frame 1 of the main timeline; give it an instance name. Be sure to put a stop(); action in the first frame of your movieclip, so it doesn't take off on its own.
          2. create an invisible button object. Place the invisButton object on top of that [instanceName] movie clip (on its own layer) that you have placed on the stage.
          3. select the invisible button, and open your actions panel. Place the following code in the invis button's action panel (I've used a_mc as my instance name of the movieclip)

          on (rollOver) {
          on (rollOut) {

          Now, when you publish your movie, the swf will play only when mouse is over it.

          Notice that I put actionscript in the last frame of the movieclip, directing it to gotoAndPlay(2). This keeps the movie playing as long as the mouse is over.

          Click here for a sample .fla
          • 2. Re: Run SWF on mouseover
            ChrisFlynn Level 1
            Create a new scene that will come before you're current movie.

            Create 2 layers, one called 'actions', the other 'btn'. In the actions layer, add a stop();

            If you don't already have a label where you movie starts, I'd add a layer with just a label on it, call it "Start".

            Create a transparent button, by creating a new button, and putting only a 25x25 box in the hit area, the rest of the keyframes should remain blank.

            Drag that button from your library to your btn layer in your new scene. The button will have a blueish tint to it. Make that button the size of your Flash movie.

            Add this actonscript to your button

            gotoAndPlay("Start"); //<-- Or whatever the label is at the start of your movie

            Hope that helps.

            • 3. Re: Run SWF on mouseover
              skateblade Level 1
              Thank's for the response
              I'll try and do it see if I can do and get it to work.
              • 4. Re: Run SWF on mouseover
                skateblade Level 1
                Thanks for the help yesterday
                I tried adding the button as described and I get this error:

                **Error** Scene=Scene 1, layer=btn, frame=1:Line 1: Mouse events are permitted only for button instances

                I added this code to the first layer: stop();

                I added this code to the second layer, btn layer:


                Have any ideas what I’m doing wrong?
                • 5. Re: Run SWF on mouseover
                  Nickels55 Level 2

                  add that code by clicking on the button and making it active, not on the layer

                  on the layer it looks like this:
                  *buttonInstanceName*.onRollover = function() {
                  • 6. Re: Run SWF on mouseover
                    skateblade Level 1
                    Sounds great thanks, But how do I make the button active.

                    I am a newbie and have down loaded the trial version and I'm using the Flash pro.
                    This is a lot harder that I thought it was going to be.
                    Thanks for help you can provide
                    • 7. Re: Run SWF on mouseover
                      Nickels55 Level 2
                      I mean actually select the button before you add the actionscript. This attaches the script directly to the button as opposed to just having it on the layer. If you click on the layer and add action script then it is not really attached to anything. If you click on the button then add the code then the code is directly attached to the button.

                      Hope that makes sense.