5 Replies Latest reply on Sep 3, 2006 10:33 AM by

    Need Help So Bad

      Hello All,

      I need help for this ;

      i want to draw movie clips at specific coordinates when i click a button. i cant imagine how to do. i need a simple example at least. i found that code part and put in button action but only 1 mc has drawn on button! :(
      on(press){
      x = 10;
      y = 10;
      var maxNum = 3;
      var num = 1;
      for (a=1; a<=maxNum; a++) {
      for (b=1; b<=maxNum; b++) {
      _root.ball.duplicateMovieClip("ball"+num, num);
      _root["ball"+num]._x = x;
      _root["ball"+num]._y = y;
      x = x+82;
      num++;
      }
      x = 10;
      y = y+64;
      }
      }


      please help me..
        • 1. Re: Need Help So Bad
          please at least show me the way in few sentences or give me advice what subject i should learn to be able to do such application.
          • 2. Re: Need Help So Bad
            2m Level 2
            I really would like to help, but you would have to elaborate a bit on what you want.
            "i want to draw movie clips at specific coordinates when i click a button"
            isn't very helpfull. For one thing the term "draw" in such a context usualy refers to the socaled drawing api, where you draw e.g. lines without using the drawing tool, but with actionscript only.
            The next thing is, that the code you provide does someting totally differnt, it duplicates an alreay present clip. From you description I'd think that making a previously invisible clip visible and move it would be much closer.

            So ples discribe in your terms what you want the stage to look loke before you prees your button and what should happen when you press it. In as much detail as possible. Then somebody might be able to help.
            1 person found this helpful
            • 3. Re: Need Help So Bad
              oh thanks for your advice 2m. i try to describe problem again;
              i want ,for example, 3x3 boxes on stage. i have a movie clip that is square box.
              when i click button, i want to put 9 instances of that mc to the stage starting from x:10 y:10. but i couldnt do it:(

              i hope ths time i described better
              thanks for your advice
              • 4. Re: Need Help So Bad
                Level 7
                arkhon13 wrote:
                > oh thanks for your advice 2m. i try to describe problem again;
                > i want ,for example, 3x3 boxes on stage. i have a movie clip that is square
                > box.
                > when i click button, i want to put 9 instances of that mc to the stage
                > starting from x:10 y:10. but i couldnt do it:(
                >
                > i hope ths time i described better
                > thanks for your advice
                >


                Make sure you assign the movieclip of the box you will add to the stage
                a linkage name. You can do this by right-clicking the movieclip in your
                library panel and choosing "Linkage" from the menu. In the textfield
                labeled "identifier" give the movieclip a name. I use "box" in my
                example below.

                click on your button that was placed on the stage to give it focus and
                add the following code to the actionscript window.

                on (release) {
                attachMovie("box", "box1_mc", getNextHighestDepth(), {_x:10,_y:10});
                attachMovie("box", "box2_mc", getNextHighestDepth(), {_x:30,_y:10});
                attachMovie("box", "box3_mc", getNextHighestDepth(), {_x:50,_y:10});
                attachMovie("box", "box4_mc", getNextHighestDepth(), {_x:10,_y:30});
                attachMovie("box", "box5_mc", getNextHighestDepth(), {_x:30,_y:30});
                attachMovie("box", "box6_mc", getNextHighestDepth(), {_x:50,_y:30});
                attachMovie("box", "box7_mc", getNextHighestDepth(), {_x:10,_y:50});
                attachMovie("box", "box8_mc", getNextHighestDepth(), {_x:30,_y:50});
                attachMovie("box", "box9_mc", getNextHighestDepth(), {_x:50,_y:50});
                }

                That's it. Just edit the _x and _y for each instance to place each
                instance in the appropriate locations. You could also create a for loop
                if you really need to for a computation reason like dynamically checking
                the size of the boxes to establish their placement. Otherwise, if
                everything is known at design-time stick with the nine rolled-out lines
                as it will execute slightly faster and usually a bit easier to read.

                Good Luck,

                James O'Reilly - JOR
                www.jamesor.com




                1 person found this helpful
                • 5. Need Help So Bad
                  thank you soo much for your answer.

                  i checked getNextHighestDepth() on web , they says "mc" will be rendered in front of all other instances at the same level. i wanted to try this function.
                  i attached another "mc" on those boxes using getNextHighestDepth() but new "mc" is not in front of those boxes:( how can i bring new "mc" in front of boxes?????i used this code that will be triggered when i click "box_mc" ;

                  on(press){
                  _root.attachMovie("newmc","newmc"+_root.count,getNextHighestDepth(), {_x:this._x,_y:this._y+100});
                  _root.count++;
                  }