2 Replies Latest reply on Apr 13, 2010 1:49 AM by Harry Kunz

    something block

    huray Level 1

      I attachMovie on a button to a movie clip(z) to visible on position  (300,300). If there is something on (300,300), that movie clip(z) has to go somewhere else like (300,400). Script as follow:


      if (something._x==300&&something._y==300){z._x=300;z._y=400;}


      My problem: what to substitute "something". "Something" can be a movie clip/text/graphic/button & etc ?

        • 1. Re: something block
          Muhammad Taqi Kirmani Level 1

          I think you will need to loop through. As your syntax says that you still use AS2, let me write a code to help you out.


          // Code Begins


          for(a in _root){ // If you are inside a movieClip you may need to change "_root" accordingly

               if(_root[a]._x==300 && _root[a]._y==300){






          //Code Ends


          Hope this helps.


          Best of Luck

          • 2. Re: something block
            Harry Kunz Level 4

            You can use hitTest(x,y) with point parameters before you attach the movieclip or you can use hitTest(mc) after the attachMovie statement to check if there is an object at that spot and reposition it to another spot. I'll give you an example for the first situation where you check the point before attaching:


            var fOccupied:Boolean = false;



            for(var sMc:String in mcHolder)


                var mcObstacle:Object = mcHolder[sMc];

                var fHit:Boolean = mcObstacle.hitTest(300, 300);


                if(true == fHit)


                   fOccupied = true;






            if(true == fOccupied) //attachMovie at 300,400

            else //attachMovie at 300,300