HitTest

I'd like to send text and have the movie stop moving when hiting a

Page 1 of 1

4 Replies - 6330 Views - Last Post: 25 January 2007 - 09:33 AM

#1 Maxx  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 16-September 06

HitTest

Posted 20 September 2006 - 05:55 PM

If I try to use the same code on another movie clip only one will work at a time.
Any idea's why this is and how to have more than one hittest.

I have the code on a single frame of a movie clip.
I have another movie called box2_mc.

The user uses the key board to move the movie.

I'd like to send text and have the movie stop moving when hiting any of the 4 diffrent boundry movies.

Any idea's
:huh:


 onClipEvent (enterFrame) {
	if(hitTest(_root.box2_mc)) {
		_root.limittext= "Collision Detected";
	} else {
		_root.limittext= "";
		gotoAndStop (1);
		
	}
}  


Is This A Good Question/Topic? 0
  • +

Replies To: HitTest

#2 Maxx  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 16-September 06

Re: HitTest

Posted 21 September 2006 - 09:37 AM

Here's the answer, KGlad at Adobe's forum helped me out.
there's a reason you can only have one onEnterFrame handler at any one time.

"...of course, it makes no sense to have more than one and is wasteful of cpu resources to have more than one, but the main reason is the flash developers don't allow it and i'm not what all went into their decision.

you can attach onEnterFrame handler to different movieclips and each of them can detect hitTests against any other movieclilps. that's also not as efficient as having one handler to do the testing."
-Kglad

You can view the message at http://www.adobe.com...r...&forumid=15.


 onClipEvent (enterFrame) {
	if(this.hitTest(_root.box1_mc)||this.hitTest(_root.box2_mc)||this.hitTest(_root.box3_mc)||this.hitTest(_root.box4_mc))  {
		_root.limittext= "Collision Detected";
	} else {
		_root.limittext= "";
		gotoAndStop (1);
		
	}
}


Was This Post Helpful? 0
  • +
  • -

#3 pioSko  Icon User is offline

  • still.dreaming
  • member icon

Reputation: 23
  • View blog
  • Posts: 1,888
  • Joined: 06-June 03

Re: HitTest

Posted 26 September 2006 - 12:54 AM

Yes, you have to be carefull with onEnterFrame(). It can waste a LOT of system resources if not used properly. The more scripting you do the more tricks and new techniques you'll develop in order not to use it. Like using onmousemove() instead or switching it on/off only when needed. (exmaple: using delete onEnterFrame;).

Sometimes, though there's no way around it. A good way of testing efficiency is to open up the Windows Manager and watching the graph of the processor while testing the Flash movie. If it uses to much processor power then changes are needed.

Stay clear of giving bitmaps alpha transparancies and moving large chunks of text. Those are very hungry for processor power.
Was This Post Helpful? 0
  • +
  • -

#4 iRock  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 24-January 07

Re: HitTest

Posted 24 January 2007 - 03:41 PM

Im a bit of a noob.... how can i make a game play the "gameover" keyframe when 2 objects collide?
Was This Post Helpful? 0
  • +
  • -

#5 reyco1  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 2
  • View blog
  • Posts: 43
  • Joined: 20-March 05

Re: HitTest

Posted 25 January 2007 - 09:33 AM

if(mc1.hitTest(mc2)){
_root.gotoAndPlay("gameover");
}


This post has been edited by reyco1: 25 January 2007 - 09:35 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1