13 Replies Latest reply on May 14, 2006 3:23 PM by Kate_Allan

    Movie Clip as button not working

    Kate_Allan
      Hi all,

      I have some text in a keyframe - I converted the text to a movieclip then in frame on of the action script line i put
      healthbutton.onRelease=function() {
      getURL(www.thewebsite.co.nz/thewebpage.htm);
      }

      I publish and preview and nothing happens the cursor doesn't change when you hold the mouse over it and it doesn't go anywhere or even try to when you click on it.

      In the published html file i get this
      <!--text used in the movie-->
      <!--
      Health &
      Wellness
      Health &
      Wellness
      Health &
      Wellness
      Health &
      Wellness
      Health &
      Wellness
      Health &
      Wellness
      X heaps

      Any ideas where i have gone wrong?

      Many thanks
      Kiwidesign
        • 1. Re: Movie Clip as button not working
          tonyhigham Level 1
          without being able to see the source, the most obvious problem would be that you forgot to name your instance, or had a typo when you named it...
          • 2. Re: Movie Clip as button not working
            Kate_Allan Level 1
            The instance name was healthbutton as was the movie clip name.
            Any ideas what it would repeat the text in the html file?

            Kiwidesign
            • 3. Movie Clip as button not working
              TimSymons Level 1
              Was the actionscript inside the movieclip you created? if so, then try:

              this.onRelease = function() {

              getURL("www.thewebsite.co.nz/thewebpage.htm");

              };

              Tim
              • 4. Re: Movie Clip as button not working
                Kate_Allan Level 1
                Hi,

                No the action script for the movie clip is in the first frame of the actions layer on the main timeline.

                Kiwidesign
                • 5. Re: Movie Clip as button not working
                  abeall Level 3
                  Why is the ActionScript not on or inside the movieclip?

                  It sounds to me like a an issue of trying to assign AS to to a movieclip that either does not exist yet, or a keyframe is going to override immediantly after the script is attached.
                  • 6. Re: Movie Clip as button not working
                    Kate_Allan Level 1
                    I am still very much a learner in this area of web development, i have recently done a tutorial in Flash 8 Professional training from the source book where it was creating a gallery - the images they used as buttons the made movie clips then used action script in the first frame of actions layer in the same form as i tried to use - it works perfectly for the gallery.

                    I am more than willing to do it differently if what i am doing is wrong.

                    thanks for all the help thus far.
                    • 7. Re: Movie Clip as button not working
                      abeall Level 3
                      Here's the deal. If you are assigning actionscript to a movieclip on frame 1, then movieclip *must* exist on frame 1. If it does not, the AS fails.

                      Additionally, keyframe animation can mess things up. If you put the AS inside the movieclip and refer to "this", you don't have to worry about any of that.
                      • 8. Re: Movie Clip as button not working
                        Kate_Allan Level 1
                        Thanks - that makes sense:
                        I converted the text to a movieclip then added actionscript to the movie clip on the timeline (not in the actions layer)
                        this.onRelease = function() {
                        getURL("www.guyassociates.co.nz/health_wellness.htm");
                        };

                        When I try to publish it i get the following error

                        **Error** Scene=Scene 1, layer=Health txt, frame=15:Line 1: Statement must appear within on/onClipEvent handler
                        this.onRelease = function() {

                        Total ActionScript Errors: 1 Reported Errors: 1
                        • 9. Re: Movie Clip as button not working
                          tonyhigham Level 1
                          in my experience, this error usually occurs when you have placed your code ON a symbol instead of on a frame...
                          make sure your code is on a frame IN the movie and not ON the movieclip itself

                          if you want to keep it on the clip, which isn't advisable, you ahve to write it the old way:

                          on(release){
                          getURL("www.guyassociates.co.nz/health_wellness.htm");
                          }
                          • 10. Re: Movie Clip as button not working
                            abeall Level 3
                            If you put it directly on the movieclip, you need to use an on() or onClipEvent() handler so it knows when to execute the code. So it would look like this:

                            onClipEvent(load){
                            this.onRelease = function() {
                            getURL("www.guyassociates.co.nz/health_wellness.htm");
                            };
                            }

                            Or, what would make more sense to use the on(release) event:

                            on(release){
                            getURL("www.guyassociates.co.nz/health_wellness.htm");
                            }

                            The alternative is to put the code you had *inside* the movieclip. Open the movieclip, and put the code actually on frame 1 of the the movieclip. The advantage of this is that you don't have to worry about keyframes messing anything up(since it will be the same on every keyframe since it's inside it). The disadvantage is your code is now hidden a little more. The nice thing about Flash 8, however, is that the Actions panel shows you everywhere ActionScript is.

                            cheers
                            • 11. Re: Movie Clip as button not working
                              Kate_Allan Level 1
                              I have tried all these ideas with no luck in the html out put i am still getting
                              <!--url's used in the movie-->
                              <!--text used in the movie-->
                              <!--
                              Health &
                              Wellness
                              -->
                              (repeated many times)
                              The strange thing is that its not even text any more its a movie clip and there are 6 other text boxes on the movie and only one of those ever shows up in the long list of Health & Wellness.

                              I am very puzzled but appreciate all the help i am being given.

                              Cheers
                              Kiwidesign
                              • 12. Movie Clip as button not working
                                Kate_Allan Level 1
                                Ok - figured out why all the repeated text - I had the movie clip on a key frame then at the end of the movie I had put a frame so - and i'm guessing here I guess it was repeating the movie clip on each frame and thus repeating the text (Although Still not sure why its in the text part if its a movie clip)
                                The problem with it now though is it only exists on that frame and so disappears after it.


                                Now to get the movie clip working as a button : )

                                Kiwidesign
                                • 13. Re: Movie Clip as button not working
                                  Kate_Allan Level 1
                                  Hi all,

                                  Thanks for all the help. I got the movie clips working by using the following code inside the movie clip on frame one

                                  this.onRelease = function() {
                                  getURL("health_wellness.htm");
                                  };

                                  The only thing i need to sort now is why in the published html file the text health_wellness appears like 30 times under the text used in movie (and nothing appears in the urls used in movie)

                                  I think it has something to do with the number of frames the movie clip is covering but i don't know any other way the movie clip will last the entire movie other than adding a frame or keyframe at the end of the movie.

                                  Any help on this issue would be greatly appreciated.

                                  Kiwidesign