2 Replies Latest reply on Aug 17, 2006 7:54 AM by olally

    hitTest

    olally
      Hi Bhanu

      in the fla , there is a movieclip called "mc1" on the stage,
      inside which we have one more movieclip called "mc2"

      I'm dynamically attaching movieclips (squares) in a for loop on to the "mc2"

      you can see the code , if you double click the " mc1" on the stage ,
      and i have written an onPress handler there for mc1, l should have the onpress handler in the same place , ie inside the mc1 movieclip.. because we are using it for other purposes

      the need is we are implementing dynamic flow charts,
      for that when i click on the black bordered square box i need to highlight the square

      I tried to implement the hittest functionality..but it isn't working

      can anyone help me on this , please reply me to {himabinduatluri@yahoo.co.in} , i can send u the fla

      thank you very much
        • 1. Re: hitTest
          aniebel Level 2
          Can you post the AS?
          • 2. Re: hitTest
            olally Level 1
            Hi can I attach files in forums..?


            this is the code i have inside the "mc1" movieclip
            //
            var eventMC:MovieClip = this.mc2.attachMovie("sqr_mc", "sqr_mc", 1);
            eventMC._x = 30;
            eventMC._y = 30;
            onPress = function () {
            trace(this);
            if (this.hitTest(eventMC)) {
            trace("you hit the event"+eventMC);
            }
            };
            var names:Array = new Array("aaa", "bbb", "ccc");
            var xaxis:Array = new Array("10", "70", "140");
            var yaxis:Array = new Array("10", "10", "10");
            var layer = 0;
            for (var i = 0; i<names.length; i++) {
            attachEvents(String(names ), Number(xaxis), Number(yaxis ));
            }
            function attachEvents(name:String, x:Number, y:Number) {
            var eventMC:MovieClip = this.mc2.attachMovie("sqr_mc", name, layer++);
            eventMC._x = x;
            eventMC._y = y;
            }

            "mc2" is inside the "mc1" and im attaching the square MCs to "mc2" from "mc1" , sorry if I am confusing..

            mc1->mc2->square MCs

            thank you very much
            -Bindu