5 Replies Latest reply on Jun 20, 2008 5:26 AM by PChiranjeevi

    What's the code for close buttun

    Mitar01
      I have created simple slide show of several images, and previous, next and close buttons (converted to symbols). I wrote the code for prev and next, but I don't know what to write for my close button. What I want to do is that on mouse click on "close" button, the slide show closes. So far I got this:

      stop();

      next_btn.onRelease = function() {
      if (_root._currentframe == 5) {
      gotoAndStop (1);
      }
      else{
      nextFrame();
      }
      }

      prev_btn.onRelease = function() {
      if (_root._currentframe == 1) {
      gotoAndStop (5);
      }
      else{
      prevFrame();
      }
      }

      NOTE:prev_btn and next_btn are actually the name of the symbols. For close button it would be close_btn.
      I am using Flash CS3, actionscript 2
      Thank you.
        • 1. Re: What's the code for close buttun
          PChiranjeevi Level 1
          It depends how you want to do it
          I mean Do you really want to remove the Main Movie clip from the stage or Only frame Changes to some place else.

          If you want to remove the main slide show Movie clip then you must attach it from the library. Because you cannot remove a movieclip from the stage which you placed manually. For this you need to use "attachMovie" so the Movie will be placed on stage at runtime and can be removed. So it is dynamic. Static variables cannnot be deleted is on condition for flash.
          if the colse_btn is located inside th Slide show movie then then the code will look like this.
          // if you writing code in the frame
          close_btn.onRlease = function (){
          this._parent.removeMovieClip();//where this refers to the close buton and _parent refers to close_btn's parent i.e. slide show movieCLip
          }
          // if you writing code to the movieclip directly
          on(release){
          this._parent.removeMovieClip();
          }

          or else if you are placing it maually then you need to set its visibility to false so it cannot be acccessable. This is one kind of tricky way to hide something from the stage to create the feel of closing effect.
          • 2. What's the code for close buttun
            PChiranjeevi Level 1
            sorry I have posted twice
            • 3. Re: What's the code for close buttun
              Mitar01 Level 1
              Can I have some more detailed explanation on how to do it because I can't figure it. What did you mean by:

              "If you want to remove the main slide show Movie clip then you must attach it from the library."
              • 4. Re: What's the code for close buttun
                clbeech Level 3
                It sounds as though you want to 'move' something? what exactly to you mean by 'close'? is this an MovieClip or are you using the Slide class (which you're not according to the code above and this is based in the timeline)? if you wish to 'move' something I would use the Tween class, or simply nav to a frame (you should maybe consider using 'labels') that does not contain the elements you are referring to.

                ChintuBabu - that's not quite correct - you can use removeMovieClip() on a MC placed on the Stage in the IDE if you first call swapDepths()
                • 5. Re: What's the code for close buttun
                  PChiranjeevi Level 1
                  clbeech Thats ok
                  But This can be possible in AS2 as for i Know But How can u use the swapdepths [swapChildren OR setChildAT]to a movie clip where you cannot refer the nextHighestDepth in AS3. I haven't tried it yet. but if you have an example then please post it here

                  clbeech; your Idea is great but Why to add one more line of code where it is not necessary.