1 Reply Latest reply on Apr 15, 2010 7:36 AM by Ned Murphy

    about actionscript 3.0


      hi, this is my codes and I have two things to ask, hope someone can help me because I am a beginner to use actionscript and really need help.


      1) I want to count the number of movieclips(in different class) added. That is, may be I have 10 clicks, how many bigfish and smallfish are created. What function is suitable to call for doing this.


      2) I have a problem on the hittest, it comes out "no hit" only but I still can see the movieclips overlap. And if I want to modify that only check whether smallfish is overlap with bigfish, what should I do? Also, there are functions inside the movieclip itself to give motion.



      stage.addEventListener(MouseEvent.CLICK, addFish);

      function addFish(evt:MouseEvent):void{
          var classNames:Array = ["bigfish", "smallfish"];
          var ClassRef:Class = Class(getDefinitionByName(classNames[Math.floor(Math.random()*classNames.length)]));
          var classInstance:* = new ClassRef();
          //classInstance.addEventListener(Event.ENTER_FRAME, isKill);

      function checkForOverLapF(dobj:DisplayObject):void{
          for(var i:uint=0;i<numChildren;i++)
          }trace("not hit");

        • 1. Re: about actionscript 3.0
          Ned Murphy Adobe Community Professional & MVP

          For the first part, I would just create two arrays, one for big fish and one for small fish.  As each fish gets added,  I would store a reference to it in the appropriate array.  You could use the class name as part of the array variable name to make storing easier.


          With the first part done, then you only need to check against the appropriate array... if it's a small fish, you test for hits using only the bigfish array.


          Someone else may have a different idea, so wait for others to offer some.