3 Replies Latest reply on Sep 22, 2006 3:07 PM by Juankpro

    multiple functions using onRelease

      New to the forum here.
      Been using flash for several years -- more of a designer than programmer - though I have a moderate understanding of Action Script.

      using someone else's code -- free -- open source

      I need someone who understands using functions and setting variables to -- PLEASE HELP!

      Rather long script -can't/shouldn't post entire script according to forum rules. I have a link to the entire flash file below if someone could please download it and look at this protoype. It is just a VERY ROUGH sketch -- graphics will later be rendered in Swift3D and Photoshop (just used some off-the-web images for mock up -- not fully animated yet).

      LINK: http://www.blaineturner.com/flashforum/myTestFLA.html

      I need to accomplish two things:
      1) when a button is pressed - move (scroll) the _y position of the movie clips -- that works fine.
      2) when button is pressed - set a variable so the correct content number is set, and the movie clip with the content starts playing based on the contentIndex variable.

      here's a sample of what I mean:

      //set the button actions
      _global.contentIndex=0, arrayIndex=0;


      _global.contentIndex=1, arrayIndex=1;

      _global.contentIndex=2, arrayIndex=2;

      --- AND SO ON...

      The scroll works off of an array - it works fine.
      But you have to click twice to get the contentIndex variable to be recognized and enacted, and the only way I even get it to work at all is by having a MC on the stage that uses this:

      if (_global.contentIndex == 1) {
      }else if (_global.contentIndex != 1){
      _global.contentIndex = 0;

      Problem is in the onRelease = function() -- I think.

      COMPLICATED?? LONG POST?? YES! -- don't know how else to ask / explain.

      Thanks in advance!!!
      ">FLASH FUNCTION QUESTION (.zip) file
        • 1. multiple functions using onRelease
          This is not the best way to do it, you know why? Because you can never predict which one is going to run first, the onRelease placed on the button, or the mouseUp placed on the content. Even if you can, the player might change the rules in the future. So the first time runs your onMouseUp first and then the onRelease, so when the onMouseUp runs the variables are not set yet. The second time you click the vars are already set because of the previous click and the mouseUp works.

          It is not good to place the code in two different places try placing it all inside the buttons. If the code repeats itself a lot try placing it on a function like the code I am sending you.

          I have kept the first line after every on(release) not because it is necesary but because I don´t know if you are needing this for other purposes. If you see you don´t really need it, you can delete this line manually:

          This code calls a function when pressing the buttons. I created a variable that holds the currently selected content, so when you press a button you place the current content to frame 1, then set the current content to be the content you are selecting, finally you place the now current content to frame 2 and further:

          • 2. Re: multiple functions using onRelease
            btagalen1992 Level 1
            It makes sense. I will have to wait unfortunately until Monday to try it out. If I have additional problems can I email you? OR do you check through your posts | replies routinely?
            • 3. Re: multiple functions using onRelease
              Juankpro Level 2
              I am used to be here some months and other months I don't. But in case of any question you can mail me to juankpro@hotmail.com