Hello,

I have 10 items on screen and only 2 of them have to match. so there is no
problem saying itemA.hiTest(itemB). But now I have to know if
itemA.hitTest(itemB)
+ itemC.

The only way i got it to work is by having itemC onEnterFrame check if the
mouse is on top of it. The issue here is that I have 8 items that are
constantly runing the onEnterFrame and I was wondering if I could have some
advice on how to avoid that.

Here is some of the code:

//basic code:
for (i:Number = 1; i < 10; i++)
{
......code here

   this["food" + i + "_single"].onRelease = this["food" + i +
"_single"].onReleaseOutside = function ()
   {
       //If Success
       if (object.hitTest(receiver)){
           var id:Number = this._name.charAt(4);
           this._parent["food"+id].gotoAndStop("highlight");
           makeItDissapear(itemNumFinal, this._width,this._height,
_root._ymouse);
       }
       else
       {
           returnToOrigin (itemNumFinal, _root._xmouse, _root._ymouse);
       }
   }
};


//Extra Items
for (var j:Number = 1 ; j < 8 ; j++)
{
   var idName2:String = "ram" + j;
   this.attachMovie ( idName2, idName2, this.getNextHighestDepth() + j)
   this["ram" + j]._x = ramInfo[j][0];
   this["ram" + j]._y = ramInfo[j][1];

   this["ram" + j].onEnterFrame = function() {
       if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
       trace("hit" + this._name);
       }
   }

};

It all works puurfectly but I was trying to find a way to optimize and not
have 8 items checking for hitText constantly.

TIA

--
...helmut

<http://helmutgranda.com>
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to