6 Replies Latest reply on Mar 10, 2008 8:55 PM by jason.williamson

    Simple If . . . Else Script Needed

    cdeatherage Level 3
      I want to add a simple if . . . else action to a couple of buttons on some Flash slide shows I've created. Unfortunately, I'm not comprehending Action Script well enough to be able to correct the syntax errors I've run into, and I've not been able to find online a discussion or example of what I want to accomplish.

      I've attached the last code I tried. What I want to do is write a script that will return to the home page if the "back" button is clicked on the first slide and on the "next" button if on the last slide, else the script should move between the previous (or next) slide.

      Seems like it ought to be simple, but I just can't figure out what I've overlooked. Thanks for looking at this for me.

      Chris
        • 1. Re: Simple If . . . Else Script Needed
          i_am_captivate Level 1
          Hello,

          What I would do in your situation is put the actions for the buttons on the main timeline.

          on(release) is for button\movieclip instances only, if you try to use it on the main timeline it will throw out errors to you...

          I woulud do something like the following:

          HTH,

          Doug
          • 2. Re: Simple If . . . Else Script Needed
            cdeatherage Level 3
            Doug,

            Thanks. I'll try that, but I'm not sure it covers everything. I do have the "back" and "next" buttons on the main page . . . primarily so as not to insert them on each slide and troubleshoot them moving around the stage. What I was hoping for was a simple script that moved to the next or previous slide but would redirect to the home page if the condition of "next" or "previous" was no longer met. Maybe explaining it that way makes more sense than my OP.

            Chris
            • 3. Re: Simple If . . . Else Script Needed
              jason.williamson
              Try this
              Check out the tutorial on how to build XML slideshows at: http://www.gotoandlearn.com/
              I use this ALL THE TIME its a really easy to use slide show example

              Then use the substitute the attached code in appropriate places and your away laughing! (if tried it and it works!)

              Cheers
              Jason
              • 4. Re: Simple If . . . Else Script Needed
                cdeatherage Level 3
                Jason,

                Thanks for this. I think it is what I was looking for. Will test it out and let you know.

                Chris
                • 5. Re: Simple If . . . Else Script Needed
                  cdeatherage Level 3
                  Jason,

                  I tried your code, and I get the following:

                  **Error** Symbol=presentation, layer=Buttons, frame=1:Line 2: Statement must appear within on handler
                  back_btn.onRelease = function () {

                  If I insert a handler at the beginning, it seems accepted but when I test in a browser, it doesn't work. Any ideas why it doesn't?

                  Thanks,

                  Chris
                  • 6. Re: Simple If . . . Else Script Needed
                    jason.williamson Level 1
                    Did you follow the Tutorial? The entire code must be insert on the Actions Layer not on a symbol and the button symbols must be given the instance names as per the Action Script (back_btn etc). Im not sure what the problem could be if you did this. Are the buttons (next & back) embeded in another movie clip or in parent scene? if in movie clip the movie clip must have an instance name and that instance name must be added before any reference to the buttons ie myslideshowmovieclip.backbutton = function etc
                    Can you discribe the how you have it all working/layout ie layer and whats in them and instance names etc?
                    Sorry if this is a bit confusing but im a bit of a rookie