5 Replies Latest reply on Apr 24, 2011 1:49 PM by LukeElChul

    Please Help Me On This Script

    LukeElChul Level 1

      OK im working on this age of war type game if you dont now what that is its a game where you press buttons to send your troops to battle the computer ive just started but ive hit a problam this is my script for spawning the troops by presing the button ill explain the proplam i have with it under the script.

       

       

       

       

      on (release) {   

      if (spear>=0) {       

      spear = true;

           } else {       

      spear = false;   

      }   

      if (spear == true) {

        this.attachMovie("spearman_mc","spearman_mc",this.getNextHighestDepth, {_x:1.1,_y:485});

      _root.spearman_mc.duplicateMovieClip("spearman_mc_"+"x", x);

           setProperty("spearman_mc_"+"x", _x, 1.1);       

           setProperty("spearman_mc_"+"x", _y, 485);       

      x++;       

      cash-=35;   

      } else {       

      cash-=0;   

        }

      }

       

      spearman_mc is my movieclip what gets created. spear i just put it in the code so i could use it in the if statement i might need to make it a Boolean at the start. NOW i will get to my problam when i press the button it creates the movie clip and i can keep creating them but when i get to 0 Cash (i start with 300) it still keeps creating and goes in to the minuses(-)

        • 1. Re: Please Help Me On This Script
          Ned Murphy Adobe Community Professional & MVP

          What should happen if the cash goes to 0?

           

          Why are you doing both an attachMovie and a duplicateMovieClip?

          1 person found this helpful
          • 2. Re: Please Help Me On This Script
            LukeElChul Level 1

            ive worked it out like i say its like a age of war type game

            what should happen is tht when you click the button called spearman_btn the movie clip spearman should get attachet to a named Xaxis and a named Yaxis for example: setProperty("spearman_mc_"+"x",  _x, 95.1); and then duplicated but ive worked out now i will post another problam tonight.

             

            this is my script now

             

             

             

             

             


            on (release) {   

            if (cash>=9) {       

            this.attachMovie("spearman_mc","spearman_mc",this.getNextHighestDepth, {_x:95.1,_y:485});

            _root.spearman_mc.duplicateMovieClip("man_mc_"+"x", x);

                     setProperty("spearman_mc_"+"x", _x, 95.1);       

                     setProperty("spearman_mc_"+"x", _y, 485);       

            x++;       

            cash-=10;   

            } else {       

            cash-=0;   

               }

            }

             

            the spearman_movie clip costs 10 cash    if this dosent make sense tell me.

            • 3. Re: Please Help Me On This Script
              LukeElChul Level 1

              please click it helped me so i get poins if it help any of you general public or correct anser if you used my script PLZzz.......

              • 4. Re: Please Help Me On This Script
                Ned Murphy Adobe Community Professional & MVP

                You are the only one who can control the points, and cannot get points for your own posting.  You can only give them out to people that help you in your posting.  No one but you sees the buttons for rewarding points.

                • 5. Re: Please Help Me On This Script
                  LukeElChul Level 1

                  ahh thank you for ansering my question now i can move on to my problam in tat script i showed you before

                  this one

                   

                   

                  on (release) {

                       if (cash>=34) {

                           this.attachMovie("spearman_mc","spearman_mc",this.getNextHighestDepth, {_x:95.1,_y:485});

                           _root.spearman_mc.duplicateMovieClip("spearman_mc_"+"x", x);

                           setProperty("spearman_mc_"+"x", _x, 95.1);

                           setProperty("spearman_mc_"+"x", _y, 485);

                          x++;

                           cash-=35;

                       } else {

                          cash-=0;

                      }

                  }

                   

                  how would i make it wait for some time about 3 seconds before it duplicates the movie and another thing when i press the button to attach spearman_mc it spawns spearman_mc at the position given but then when i press the button again it deleats spearman_mc and spawns another spearman_mc then i can keep pressing it and it works fine. so bacicly i press the button the first time and it spawns the MC(movieclip) but the second time i press it it deleats the first one and spawns the duplicate of spearman_mc then it works fine and i can keep pressing the button to spawn them untill i run out of cash.