11 Replies Latest reply on May 5, 2011 8:09 AM by Ned Murphy

    Problems with moving layers front/back

    pixelfetisch

      Hey everyone!

       

      I am very new to Flash, very very new to actionscript and I basically started programming in general 2 days ago, and I have a Problem with layers in a project. I tried learning through books but mostly with youtube tutorials but I'm stuck here.

       

      Here's the .swf file: http://dl.dropbox.com/u/14319641/Flashprojekte/Variuscard%20Headertest.swf

       

      And here is the original .fla file: http://dl.dropbox.com/u/14319641/Flashprojekte/Variuscard%20Headertest.fla

       

      Two Problems:

       

      1. I want the cards to be flying BEHIND the Logo but in front of the shadow - so that it looks like the logo is upfront and the Rest (cards and shadow) is in the back. I have 3 layers (Logo, Action, Shadow) but no matter how I move them around it won't go to the back...

       

      2. I would like to have a second fountain let's say from right to left... can I just copy/paste the code? Seems like not..

       

      Can anyone help me on this one? Pleeeeez ?

       

      Mike

        • 1. Re: Problems with moving layers front/back
          relaxatraja Level 5

          Use Depth management to swapping those things. your attached file is developed in CS5.5. Atleast make is possible to open in CS5

          • 2. Re: Problems with moving layers front/back
            Ned Murphy Adobe Community Professional & MVP

            If you want to up your chances of getting help, include your code in your posting.  Not everyone is willing/able to download/open files.

             

            If you are dynamically adding objects, they do not have a home in the timeline unless you place them into one.   You need to either target them into objects that live in specific layers or you need to control the depths at which objects reside.  It will probably be easier for you to target them into empty movieclips that you manually place on the stage in specific layers.

            • 3. Re: Problems with moving layers front/back
              pixelfetisch Level 1

              oops sorry about that, I uploaded the file as cs5 now! But the code is below as well!

              • 4. Re: Problems with moving layers front/back
                pixelfetisch Level 1

                Hey Ned!

                I thought so, in fact I'm not even sure where I placed this code, I just followed a tutorial. As a matter of fact I have to click on the layer "Actions" in order to see the code in the code-window. The other layers are empty. Maybe that helps? .. I know that I created a movie clip of that symbol (the card) then deleted it from the scene (as I had it in the library already) - linked it to actionscript (2.0) and started coding..

                 

                So I guess now I have to tell that code to be on a certain layer, not just in the root or above all..  but how?

                 

                vctest.jpg

                 

                 

                Here is the code:

                 

                timer = 0;
                timerMax = 2;
                particleCount = 0;
                gravity = 0.1;

                doStuff = function()  {
                //particle code
                this._x += this.xSpeed;
                this.ySpeed += gravity;
                this._y += this.ySpeed;
                this._rotation += this.rot;
                this._alpha -= 0.4;
                this._xscale = this.yscale += 5
                if(this._x > 1050) {
                  this.removeMovieClip();
                }
                // Die "Bounce" Funktion: Am unteren Rand mit Rotationsumkehr
                if(this._y >= 200) {
                   this.ySpeed *= -1;
                   this.rot *= -1;
                  }

                //Eine "Mouseover" Funktion wenn man ins Bild fährt

                if(_ymouse < 180 && _xmouse < 950 && _ymouse > 30 && _xmouse > 50) {
                 
                  particle._y = _ymouse;
                  particle._x = _xmouse;
                 
                }else{
                  particle._y = 150;
                  particle._x = -300
                }

                }
                onEnterFrame = function() {
                timer++;
                if(timer ==timerMax) {
                  //generate particle
                  particle = _root.attachMovie("particle", "p_" + particleCount, _root.getNextHighestDepth());
                  //particle._x = _xmouse;
                  //particle._y = _ymouse;
                  particle._x = -300;
                  particle._y = 150;
                 
                  particle.xSpeed = random (10) +1;
                  particle.ySpeed = random (6) - 7;
                  particle.rot = random (30) - 15;
                  particle.bigness = random(200) +30;
                  particle._yscale = particle._xscale = particle.bigness;
                  particle.onEnterFrame = doStuff;
                  timer = 0;
                  particleCount++;
                 
                   }

                }

                • 5. Re: Problems with moving layers front/back
                  Ned Murphy Adobe Community Professional & MVP

                  As I described, since you are dynamically adding content, if you want to control which layer it apeears in, you'll need to create an empty movieclip and place it in that layer and then target your particles to be added to that movieclip.  Let's say you name that movieclip "mc".  Then your line where you add the new objects would be changed to...

                   

                  particle = mc.attachMovie("particle", "p_" + particleCount, mc.getNextHighestDepth());

                   

                  The layer for the code is usually best left as the top layer, though it usually doesn't matter... that makes it consistent with general practices and easier to know where to find it.

                  • 6. Re: Problems with moving layers front/back
                    pixelfetisch Level 1

                    Sorry for sounding improperly dumb when asking these questions but I'm really really new to this.

                     

                    I made a new movieclip (just a box.. because I don't know how to make an "empty" movieclip) - in the layer that I want the particles to be - named it "mc" - linked to actionscript (in properties) and changed the code as below.

                     

                    now there are no particles at all.. I'm doing something wrong..

                    • 7. Re: Problems with moving layers front/back
                      Ned Murphy Adobe Community Professional & MVP

                      To create an empty movieclip you just select Insert -> New Symbol and select movieclip and OK.  Then just exit the editing mode for that movieclip by selecting Edit -> Edit Document.  You will now have a new empty movieclip in your library.

                       

                      With the desired layer selected, drag an instance of that movieclip from the library to the upper left corner of the stage and then assign it an instance name of "mc" in the Properties panel.

                       

                      I don't have CS5.5, so I don't know if what I described selecting has been altered in the new design.

                      • 8. Re: Problems with moving layers front/back
                        pixelfetisch Level 1

                        vvvvery nice!

                        thank you so so much that saved my day. Now I know what I did wrong, I never gave that movieclip an instance name! no wonder it wouldn't work...

                         

                        I've got the feeling I'll spend a lot of time in this form, very helpfull indeed

                        • 10. Re: Problems with moving layers front/back
                          pixelfetisch Level 1

                          oh by the way, any easy way (copy/paste layer?) to

                          make a second or third fountain in the scene?

                          • 11. Re: Problems with moving layers front/back
                            Ned Murphy Adobe Community Professional & MVP

                            Create a new layer and put a fountain in that layer.

                             

                            To copy/paste frames you can select the desired frames in the timeline, right click and select Copy Frames and then select the destination frame and right click and select Paste Frames