10 Replies Latest reply on Jan 3, 2011 1:36 PM by kglad

    Level for a movie clip - that is dragged to the stage

    sus3135 Level 1

      Is there any way to set the depth level for a movie clip that is dragged to the stage, rather than created in Action Script.

       

      Thanks

        • 1. Re: Level for a movie clip - that is dragged to the stage
          kglad Adobe Community Professional & MVP

          use swapDepths().

          1 person found this helpful
          • 2. Re: Level for a movie clip - that is dragged to the stage
            prodigalmaster Level 2

            This is in the wrong section if I understand what you mean.

             

            In flash interface just right click the movieclip and hover over 'arrange' then change its depth  to either set to back, set to front, go back 1, go forward 1 etc.

            • 3. Re: Level for a movie clip - that is dragged to the stage
              sus3135 Level 1

              Tried "Arrange" and it didn't work.   Sorry, guess I should have posted my code.  It's kind of a hybred.  Got the menu being created through Action Script 2 and the buttons being dragged in from the library.  Scrolling works:  but can't get the buttons to stay on top of the menu.  Thanks for your help.

               

              Here's the code I'm using:

               

              var menuArray:Array = ["Welcome", "Diverse Workforce, Diverse Plans","Local Benefits", "What Makes Us Unique", "Resources","Retirement Benefits", "Retirement Plan", "PPO", "Health Benefits", "Smart Choices", "Insurance & Other Benefits", "Other Benefits", "Financial Planning", "Life Events", "You Can Take It With You", "Services & Resources", "Deadlines"];
              var clipArray:Array = ["exported0.swf", "exported1.swf", "exported2.swf", "exported3.swf", "exported4.swf", "exported5.swf", "exported6.swf", "exported7.swf", "exported8.swf", "exported9.swf", "exported10.swf", "exported11.swf", "exported12.swf", "exported13.swf", "exported14.swf", "exported15.swf", "exported16.swf"];

              var slideListXML:XML = new XML();
              slideListXML.ignoreWhite = true;
              var currentContent:String;
              slideListXML.onLoad = function() {
              var tempArray = new Array();
              for (var i:Number = 0; i < this.firstChild.childNodes.length; ++i) {
                tempArray[i] = new Object();
                tempArray[i].swfName = this.firstChild.childNodes[i].firstChild.nodeValue;
                tempArray[i].textName = this.firstChild.childNodes[i].attributes.theText;
                //trace(this.firstChild.childNodes[i].attributes.theText);
              }
              }
              slideListXML.load("playlist.xml");

              prev_mc._alpha = 75;
              //next_mc._alpha = 75;


              var nowPlaying:Object = new Object();
                  nowPlaying.clip = " ";
              nowPlaying.j = " ";
              nowPlaying.imaginary = "preSelected";

              function lightsOut():Void{
              for (var i = 0; i < menuArray.length; ++i){
              var name:String = "selected" + i + "_mc";
              if (name != ("selected" + nowPlaying.j + "_mc")){
              display_mc.list_mc[name].gotoAndPlay("preSelected");
                }
              }
              }

              function lightsOn():Void{
                  for (var i = 0; i < menuArray.length; ++i){
                   var name:String = "selected" + i + "_mc";
                   if (name != ("selected" + nowPlaying.j + "_mc")){
                   display_mc.list_mc[name].gotoAndPlay("preSelected");
                   }
                   else if (name == ("selected" + nowPlaying.j + "_mc")){
                   display_mc.list_mc[name].gotoAndPlay("selected");
                   }
                   else if (nowPlaying.j == " "){
                   display_mc.list_mc[0].gotoAndPlay("selected")
                  
                   }
                  }
                 }
              //var for scroll

              //build Menu
              function buildMenu()
              {
              var spacing:Number =72.8;
              for (var i = 0; i < menuArray.length; ++i)
                {
                 var name:String = "selected" + i + "_mc";
                 var x:Number = i * spacing;
                 display_mc.list_mc.attachMovie("selected", name, i);
                 display_mc.list_mc[name]._x = x;
                 display_mc.list_mc[name].label_txt.text = menuArray[i];
                  
                 // This is the RollOver function
                
                 display_mc.list_mc[name].onRollOver = function()
                  {
                  this.gotoAndPlay("rO");
                  }
               
                 // This is the RollOut function
                
                 display_mc.list_mc[name].onRollOut = function()
                  {
                   for (var i = 0; i < menuArray.length; ++i)
                   if (this._name == "selected" +i+ "_mc")
                   {
                    if (nowPlaying.clip == "exported" + i + ".swf")
                    {
                     this.gotoAndPlay("selected");
              //       trace("this was the chosen clip");
                    }
                    else
                    {
                     this.gotoAndPlay("preSelected");
                    }
                   }
                  }
                 
                 display_mc.list_mc[name].onPress = function()
                  {
                   nowPlaying.imaginary = "playing";
                   for (var i = 0; i < menuArray.length; ++i)
                    {
                     if (this._name == "selected" + i + "_mc")
                      {
                       empty_mc.loadMovie("exported"+ i + ".swf");
                       nowPlaying.clip = "exported" + i + ".swf";
                       nowPlaying.j = i;
                       this.gotoAndPlay("selected");
                       lightsOut();
                       loadStory();
                      }
                    }
                  } 
                
                 }
                
                
                
                 }
              var startingX:Number = display_mc.list_mc._x;
              //var depth:Number = 1;
              var right:Number=600;
              var direction:String;
              function scroll( ) {
              var speed: Number = 10;
              if (direction == "left") {
                if(display_mc.list_mc._x - speed + display_mc.list_mc._width > (startingX + right)){
                 display_mc.list_mc._x -=speed;
                }else{
                 display_mc.list_mc.x = (startingX +left) - display_mc.list_mc_width;
                }
              } else if (direction == "right") {
                if (display_mc.list_mc._x  + speed <startingX) {
                 display_mc.list_mc._x += speed;
                }else{
                 display_mc.list_mc._x = startingx;
                }
                }
              }
               
                
              function getStarted():Void{
                empty_mc.loadMovie("exported"+ 0 + ".swf");
                nowPlaying.clip = "exported" + 0 + ".swf";
                nowPlaying.j = 0;
                display_mc.list_mc.selected0_mc.gotoAndPlay("selected");
              }

               

              print_mc.onPress = function(){
              getURL("Placeholder.pdf",_blank);
              }

              prev_mc.onPress = function():Void {
              if (nowPlaying.j > 0){
              nowPlaying.j = nowPlaying.j -1
              nowPlaying.clip = "exported" + nowPlaying.j + ".swf"
              empty_mc.loadMovie("exported" + nowPlaying.j + ".swf");
              lightsOn();
              loadStory();
              }
              }

              next_mc.onPress = function():Void {
              if (nowPlaying.j < (menuArray.length -1)){
              nowPlaying.j = nowPlaying.j +1
              nowPlaying.clip = "exported" + nowPlaying.j + ".swf"
              empty_mc.loadMovie("exported" + nowPlaying.j + ".swf");
              lightsOn();
              loadStory();
              }
              }

              prev_mc.onRollOver = function():Void {
              if ((nowPlaying.j > 0) && (nowPlaying.j != "")){
              this._alpha = 75;
              }
              }

              prev_mc.onRollOut = function():Void {
              if ((nowPlaying.j > 0) && (nowPlaying.j != "")) {
              this._alpha = 100;
              }
              }

              next_mc.onRollOver = function():Void {
              if ((nowPlaying.j <= menuArray.length) && (nowPlaying.j != "")){
              this._alpha = 75;
              }
              }

              next_mc.onRollOut = function():Void {
              if ((nowPlaying.j <= menuArray.length) && (nowPlaying.j != "")){
              this._alpha = 100;
              }
              }

              // Here are the properties of script_ta

              // Create the new StyleSheet object.
              var my_styles:TextField.StyleSheet = new TextField.StyleSheet();
              my_styles.setStyle("html", {fontFamily:"Arial,Helvetica,sans-serif", fontSize:"10px", color:"#0000FF"});
              my_styles.setStyle("body", {color:"#000000", fontSize:"18px"});

              // Set the TextAreaInstance.styleSheet property to the newly defined
              // styleSheet object named styles.
              script_ta.styleSheet = my_styles;
              //script_ta.border =


              //Load the initial story, picture and title into the frames

              function loadStory(){
                var my_lv:LoadVars = new LoadVars();
                my_lv.onData = function(src:String) {
                    if (src != undefined) {
                        script_ta.text = src;
                    } else {
                        script_ta.text = "Error loading text.";
                    }
                };

                my_lv.load("script" + nowPlaying.j + ".htm");
              //  trace("story loaded");
              }

              buildMenu();
              //trace(menu built);
              getStarted();
              loadStory();

              var scrollButtonPressed:Boolean = false;

              display_mc.button_right_mc.onPress = function() {
              scrollButtonPressed = true;
              direction = "right";
              };
              display_mc.button_right_mc.onRelease = function() {
              scrollButtonPressed = false;
              };
              display_mc.button_left_mc.onPress = function(){
              scrollButtonPressed = true;
              direction = "left";
              };
              display_mc.button_left_mc.onRelease = function(){
              scrollButtonPressed = false;
              };
              this.onEnterFrame = function(){
              if (scrollButtonPressed) {
                scroll ();
              }
              };

              display_mc.list_mc.selected0_mc.gotoAndPlay("selected");

              • 4. Re: Level for a movie clip - that is dragged to the stage
                kglad Adobe Community Professional & MVP

                use swapDepths().

                1 person found this helpful
                • 5. Re: Level for a movie clip - that is dragged to the stage
                  sus3135 Level 1

                  Ok, can you help me think through this?  The button is a movie clip called button_left_mc. It is placed in a clip called MenuBarMine.  The menu is built in an empty movie clip called list_mc which is alsocontained in a movie clip called MenuBarMine.  Which movie clip would I be swapping depth with?

                   

                  Thank you.

                  • 6. Re: Level for a movie clip - that is dragged to the stage
                    kglad Adobe Community Professional & MVP

                    it's hard to say without knowing what's being moved "over" your buttons.  but you will use one of:

                     

                    // if something in MenuBarMine.list_mc is moved over your button:

                    MenuBarMine.list_mc.button_left_mc.swapDepths(MenuBarMine.list_mc.getNextHighestDepth());

                     

                    // if something in MenuBarMine is moved over MenuBarMine.list_mc:

                    MenuBarMine.list_mc.swapDepths(MenuBarMine.getNextHighestDepth());

                     

                    // if something in the current scope is moved over MenuBarMine:

                    MenuBarMine.swapDepths(getNextHighestDepth());

                    1 person found this helpful
                    • 7. Re: Level for a movie clip - that is dragged to the stage
                      sus3135 Level 1

                      Thanks for replying.  So, there has to be some sort of action - mouse over, etc.  for the swap to happen.  I'd like for it to happen from the start up of the program.  For the buttons to always be on top of MenuBarMine.list_mc.  Can I use onLoad for this action?

                       

                      Thanks again.

                      • 8. Re: Level for a movie clip - that is dragged to the stage
                        sus3135 Level 1

                        Ok.  Got it and it works.  Thanks for your help, kglad.

                        • 9. Re: Level for a movie clip - that is dragged to the stage
                          sus3135 Level 1

                          Thought I had it.  Ran into a snag.  Using this code:

                           

                          display_mc.button_left_mc.swapDepths(getNextHighestDepth());

                           

                          Have two buttons

                           

                          display_mc.button_left_mc

                           

                          display_mc.button_right_mc

                           

                          Either one of them will swap  - but not both together.  (although they both scroll just fine)

                           

                          Should I put both  button_mc together into a different mc?

                          • 10. Re: Level for a movie clip - that is dragged to the stage
                            kglad Adobe Community Professional & MVP

                            use:

                             


                             

                            display_mc.button_left_mc.swapDepths(display_mc.getNextHighestDepth());

                             

                            display_mc.button_right_mc.swapDepths(display_mc.getNextHighestDepth())

                             


                            1 person found this helpful