5 Replies Latest reply on Nov 11, 2010 6:13 AM by Ned Murphy

    layering AS effects in app design

    ICEmultimedia1

      whats up guys? relatively new to the forum and flash in general. Very well adept to pretty much every other adobe CS program. That said, I have a small project Im doing for school I needed some help with if you dont mind. Im designing this sort of thanksgiving planner app (very cheeseball lol) and I have some falling leaves made with some actionscript. I would like to sort of layer this effect so it is behind my interface and only appears in a rectangular window on the application. I tried masking it out but that didnt seem to work, as I figured the AS probably overrides this. Here is the code I am working with;

       

      width = 550;
      height = 400;
      total = 200;
      for (var t = 0; t != total; t++) {
          var mc = _root.attachMovie("snowflake", "snowflake"+t, _root.getNextHighestDepth());
          mc._x = (Math.random()*(width+20))-10;
          mc._y = (Math.random()*(height+20))-10;
          mc.yspeed = (Math.random()*1.75)+0.25;
          mc.speed = (Math.random()*3)+2;
          mc._xscale = mc._yscale=(mc.speed+mc.yspeed)*10;
          mc.onEnterFrame = function() {
             var angle = Math.atan2(_root._xmouse-(width/2), _root._ymouse)+1.5707963267949;
             this._y += Math.sin(angle)*this.speed+this.yspeed;
             this._x += Math.cos(angle)*this.speed;
             if (this._x>width+10) {
                this._x = -10;
             } else if (this._x<0-10) {
                this._x = width+10;
             }
             if (this._y>height+10) {
                this._y = -10;
             } else if (this._y<0-10) {
                this._y = height+10;
             }
          };
      }

      Any help would be much appreciated.  Thanks -ICE
        • 1. Re: layering AS effects in app design
          Ned Murphy Adobe Community Professional & MVP

          If I am understanding your intent, if you create an empty movieclip symbol and place it on the stage on a layer below whatever other content you intend to be above it, and give it an instance name, say mcHolder, then you can change your code as follows, noting that I changed the width and height to define the area the flakes will occupy just to show they control the viewed size...

           

          width = 300;
          height = 200;
          total = 200;
          for (var t = 0; t != total; t++) {
              var mc = mcHolder.attachMovie("snowflake", "snowflake"+t, mcHolder.getNextHighestDepth());

          • 2. Re: layering AS effects in app design
            ICEmultimedia1 Level 1

            thanks for the quick response Ned, I really appreciate that. However, Im still having some issues with getting the effect just to stay in this rounded rectangluar window. I created the movie clip, named it the same as you had just so there was no confusion and made it transparent. In terms of actual programming, I understand why this should work, but Ive been banging my head up against the wall for a couple hours now not being able to figure out why it doesnt. Below please find a crude visual representation of what Im trying to do. Im sure youre extremely busy but any further assistance would be great. Thanks -ICE

             

            explanation.jpg

            • 3. Re: layering AS effects in app design
              Ned Murphy Adobe Community Professional & MVP

              The way your code was originally, it was adding things to the main timeline into depths that would be above any other content in the timeline. The key to all of this is to get that snowstorm contained into something that lives on the timeline, and not creating the snow on the timeline itself.  That movieclip will simply act as a container for your snow that you can use to confine it to a layer.

               

              When I say create an empty movieclip, I mean exactly that.  Just create a movieclip symbol with nothing in it at all and place it on the stage.  Do not make anything about it transparent.  The size of the container is defined by the area your code specifies for the snow to be within (300x200 for the example I provided).

               

              You could also add a mask layer above that movieclip's layer to further control what of that snowstorm is visible.  Based on your diagram, you would use the green shape as your mask on a layer above the snow's movieclip.

              • 4. Re: layering AS effects in app design
                ICEmultimedia1 Level 1

                wow Ned, thank you very much for your in depth explanation, I implemented your technique and it worked as I wanted. I really appreciate your help on this. Thanks -ICE

                • 5. Re: layering AS effects in app design
                  Ned Murphy Adobe Community Professional & MVP

                  You're welcome