13 Replies Latest reply on Apr 8, 2007 12:08 AM by kglad

    depth management

    Sketchsta Level 1
      Hey guys, this is my first time trying to use mx.transitions so if im doing something wrong there, please point it out..

      the idea is, each Folder Image will be a separate page which will load external swf files, but i need to get the animations working first..
      I can get each folder to move to depth(1); no problem, but i would like it to go back to it's original position when a different folder is clicked.
      how would i say for example, when a button is clicked, whatever is in depth(1); remove back to original depth, and the corresponding folder symbol move to depth(1);

      the folder symbols are on separate layers, on _root timeline...do they have to be on the same layer?
      this is the code i have to bring them to depth(1);

      btn.onRelease = function(){
      _root.six.swapDepths(1);
      }
      this works, but i dont know how to move it back to original depth when a different folder comes into depth(1);

      I would also like the symbols to have a _alpha property of 40, then if they are in depth(1); Tween _alpha to 100. and Tween back to 40 if not in depth(1);
      this is what i have on _root timeline, trying to achieve this.. it's not working tho. when i test movie, they tween to _alpha 100 and stay there.
        • 1. Re: depth management
          kglad Adobe Community Professional & MVP
          if _root.six is the first movieclip to be swapped into depth 1 and _root.seven is then swapped into depth 1, _root.six will be swapped into _root.seven's original depth.

          if that works for you, you need do nothing. if that doesn't work and you must have _root.six return to its original depth you can use the getInstanceAtDepth(1) method to return the movieclip at depth 1 (_root.six), swap _root.seven to depth 1 and then swap _root.six to its original depth. you can create a movieclip property to store each movieclip's original depth and assign it at the start of your swf.

          for your _alpha tween use double equal (==) to test for equality. you're using the assignment operator.
          • 2. depth management
            Sketchsta Level 1
            how do i create properties to store the original depth?

            and how can i set this out?
            I dont know enough about depth to know exactly what to try, all i can tell you is that i want the click of a button to bring a folder to depth(1); and when another button is clicked for a different folder, the first folder goes back to original depth, and the second folder moves to depth(1);

            do i need to use getInstanceAtDepth() for every button onRelease?

            i can post the .swf if you want to have a better idea f what im trying to do.

            and I was using (==) from the beginning, but that had no effect at all, (everytime i use a if() statement, i always used (==) but this time it didnt work, so i thought it may be because it's different when using the Tween class)
            when usinh (==) it will not tween the _alpha at all, only when i use single (=) it will tween to 100, and stay there. Which i understand why, now..

            what im confused about, is that i have that code for 2 movieClips,
            if(six.depth==1){
            new Tween(six,"_alpha",ease, 1, 100, 1, true);
            }else{new Tween(six,"_alpha",ease, 1, 40, 1, true);
            }

            and
            if( five.depth.......

            now, as i understand it, both of those cant be at the same depth, yet both tween to _alpha 100, and both do nothing if i add (==)

            • 3. Re: depth management
              kglad Adobe Community Professional & MVP
              yes, you would use the code to return movieclips to their original depth every place you're swapping depths. if you find you're reusing the same code repeatedly, define a function that contains the code you need and save yourself some typing:

              • 4. Re: depth management
                Sketchsta Level 1
                thanx dude, thats just what i wanted. how do you call a function from a different timeline tho?

                say i have your function on _root timeline, and my buttons are in a movieCLip 2 childs up.
                so something like... _root.navigation_mc.btn_mc.btn for example.. if the onRelease code is on btn_mc timeline, how can i call the function from _root.


                have you got any ideas about the _alpha issue on _root? i want to give the impression that the folders behind are merging through the folders infront, by increasing _alpha of the folder coming at depth(1);

                what in my code, would keep it from working?
                the folders are on separate layers, on the first frame of _root timeline. and so is the code.
                as i sad before, i have that code for 2 folders, but they dont wait for the condition of the if() statement to be met...
                and if i use double equals sign (==) they dont work at all.
                • 5. Re: depth management
                  kglad Adobe Community Professional & MVP
                  you can call a function that's on the _root timeline from anywhere in the same _level by using:

                  _root.swapDepthsF(_root.six); // for example

                  if you want to fade up the movieclip that's moved to depth 1 and fade down the movieclip that's been moved back to its original depth use:

                  • 6. Re: depth management
                    Sketchsta Level 1
                    no luck.. it doesnt fade at all. i'll have another look at this tomorrow, i can barely keep my eyes open..

                    about the function call, so you cant call a function thats located on a different timeline?

                    i added your function on the same frame thats got the code for each button, and im calling it onRelease.
                    each button ( 6 of them ) is on it's own timeline, the code for each button is on each buttons timeline.
                    I hope that makes sense..

                    anyway, thanx again for your help. I'll have a better look at it and maybe i can find out why it's not fading in and out.
                    it's also not going back to the original depth sometimes, but i think thats a fault of mine somewhere.
                    HERE is the SWF if you want to have a look

                    maybe you can think of a better way to achieve this.
                    • 7. Re: depth management
                      kglad Adobe Community Professional & MVP
                      are you importing the tween class? and try using the full

                      mx.transitions.easing.Elastic.easeOut

                      in case you haven't defined "ease".
                      • 8. depth management
                        Sketchsta Level 1
                        hey dude,

                        i havent use the Tween class before so im not exactly sure how and what to change. im learning as i go.. but i think the easing is being defined because im using the exact same code for _rotation as _alpha, and the _rotation works good.

                        heres the whole code for each button. I have this on each button's timeline.
                        it's still not going back the original depth everytime.

                        is there a problem on how im calling your function?
                        the --- new Tween(_root.six, "_alpha", easing, 40, 100, 1, true); --- i added to see if it would work, which it does..but not changing back to _alpha 40

                        just for the sake of trying, i even changed the ease in your function to easing so that it will be the same as what i used...but that made no difference.. so i changed it back.
                        • 9. Re: depth management
                          kglad Adobe Community Professional & MVP
                          that may give you a tween, but that's because the tween class probably has a default easing when you fail to properly define one. so, i doubt you're going to see any easing, but a tween you'll see.

                          in any case, if you don't care about easing, you can use:

                          • 10. Re: depth management
                            Sketchsta Level 1
                            GENIUS!!! =)

                            thanx a whole lot dude.. works like a charm now, and i think i like all this Tween class, im gonna use it alot more.

                            How do I properly define easing?
                            I saw in the help docs something about each type of easing and Tween, being accessed like you target symbols in AS.. Is that what you mean?
                            if so, where can i find all the types of easings and Tweens, and the elastic thing?

                            so many things for me to play with... i LOVE it... =)

                            you're right, i dont need easing for this particular project, but i know it will be handy in the future.


                            one more thing... if you dont mind..
                            i had a dynamic text field inside each folder movieClip, which loaded text from a txt file, but see how im using _rotation for rollOver and out.. i made the text load on rollOver, which works..., but the textField always dissapears when the _rotation starts..
                            any ideas why this is happening?

                            I tried to just type something in there, and set it to staticText aswell, but that dissapears too..

                            • 11. Re: depth management
                              kglad Adobe Community Professional & MVP
                              under "tween class/using the tween class" there's a list of the easing classes and methods. to use correctly:

                              • 12. Re: depth management
                                Sketchsta Level 1
                                kool i found it.
                                Thanx alot kglad, as always...pure genious. =)
                                • 13. Re: depth management
                                  kglad Adobe Community Professional & MVP
                                  you're welcome.